Skip to content

Commit

Permalink
Convert null MAKI objects to global NULL value (#866)
Browse files Browse the repository at this point in the history
* Coerce null MAKI objects to 0

* use global NULL value
  • Loading branch information
jberg authored and captbaritone committed Nov 30, 2019
1 parent e586479 commit 0297eb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions modern/src/maki-interpreter/interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modern/src/maki-interpreter/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0297eb7

Please sign in to comment.