Skip to content

Commit

Permalink
Fix hook variable passing and initial stack setup (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
jberg authored and captbaritone committed Aug 9, 2019
1 parent adce725 commit 54c6dc6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion modern/src/Emitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Emitter {
}

trigger(eventName, ...args) {
this._globalHooks.map(cb => cb(eventName, args));
this._globalHooks.map(cb => cb(eventName, ...args));
if (this._hooks[eventName] == null) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions modern/src/maki-interpreter/interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ function main({ runtime, data, system, log, debugHandler }) {
// const logger = log ? printCommand : logger;
// TODO: Handle disposing of this.
// TODO: Handle passing in variables.
variable.hook(method.name, () => {
variable.hook(method.name, (...args) => {
// Interpret is a generator that yields before each command is exectued.
// `handler` is reponsible for `.next()`ing until the program execution is
// complete (the generator is "done"). In production this is done
// synchronously. In the debugger, if execution is paused, it's done
// async.
handler(interpret(commandOffset, program, []));
handler(interpret(commandOffset, program, args.reverse()));
});
});

Expand Down
8 changes: 5 additions & 3 deletions modern/src/maki-interpreter/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ class Variable {
this._unsubscribeFromValue();
}
if (this.global && this.typeName === "OBJECT" && value !== null) {
this._unsubscribeFromValue = value.js_listenToAll((eventName, args) => {
this._emitter.trigger(eventName, args);
});
this._unsubscribeFromValue = value.js_listenToAll(
(eventName, ...args) => {
this._emitter.trigger(eventName, ...args);
}
);
}
this._value = value;
}
Expand Down
2 changes: 1 addition & 1 deletion modern/src/runtime/MakiObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MakiObject {
}

js_trigger(eventName, ...args) {
this._emitter.trigger(eventName, args);
this._emitter.trigger(eventName, ...args);
}

js_listenToAll(cb) {
Expand Down

0 comments on commit 54c6dc6

Please sign in to comment.