Convert null MAKI objects to global NULL value (#866)

* Coerce null MAKI objects to 0

* use global NULL value
This commit is contained in:
jberg 2019-08-19 09:10:46 -07:00 committed by Jordan Eldredge
parent e58647964b
commit 0297eb726a
2 changed files with 9 additions and 3 deletions

View file

@ -161,11 +161,17 @@ export function* interpret(start, program, stack = []) {
}
const obj = popStackValue();
const ret = obj[methodName](...methodArgs);
let value;
if (isPromise(ret)) {
stack.push(yield ret);
value = yield ret;
} else {
stack.push(ret);
value = ret;
}
if (value === null) {
// variables[1] holds global NULL value
value = variables[1];
}
stack.push(value);
break;
}
// callGlobal

View file

@ -17,7 +17,7 @@ class Variable {
if (this._unsubscribeFromValue != null) {
this._unsubscribeFromValue();
}
if (this.global && this.typeName === "OBJECT" && value !== null) {
if (this.global && this.typeName === "OBJECT" && value !== 0) {
this._unsubscribeFromValue = value.js_listenToAll(
(eventName, ...args) => {
this._emitter.trigger(eventName.toLowerCase(), ...args);