feat: 新增defineProperty全局变量

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-05-11 10:20:28 +08:00
parent d0de120867
commit 9a15a0ab1f
2 changed files with 9 additions and 2 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>pw.yumc</groupId> <groupId>pw.yumc</groupId>
<artifactId>MiaoScript</artifactId> <artifactId>MiaoScript</artifactId>
<version>0.6.0</version> <version>0.6.5</version>
<developers> <developers>
<developer> <developer>
<id>502647092</id> <id>502647092</id>

View File

@ -11,7 +11,14 @@
global.engineLoad = load; global.engineLoad = load;
global.noop = global.engineDisable = engineDisable = function () { }; global.noop = global.engineDisable = engineDisable = function () { };
global.load = load = function __PreventGlobalLoadFunction__() { throw new Error('Internal engine system not allow use `load` function!'); } global.load = load = function __PreventGlobalLoadFunction__() { throw new Error('Internal engine system not allow use `load` function!'); }
global.setGlobal = function (key, value) { global[key] = value; }; global.setGlobal = function (key, value, config) {
if (config) {
config.value = value;
Object.defineProperty(global, key, config)
} else {
global[key] = value;
}
};
// Init console and require // Init console and require
global.console = engineLoad('classpath:core/console.js')(logger); global.console = engineLoad('classpath:core/console.js')(logger);
console.log("Loading Engine at Thread", java.lang.Thread.currentThread().name) console.log("Loading Engine at Thread", java.lang.Thread.currentThread().name)