- );
-}
-
-export default Wrapper;
diff --git a/packages/webamp-modern/src/index.js b/packages/webamp-modern/src/index.js
index 82af9da9..09da3f17 100644
--- a/packages/webamp-modern/src/index.js
+++ b/packages/webamp-modern/src/index.js
@@ -3,14 +3,13 @@ import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import "./index.css";
import App from "./App";
-import Debugger from "./debugger";
import { create } from "./store";
const store = create();
ReactDOM.render(
- {window.location.pathname === "/debugger" ? : }
+ ,
document.getElementById("root")
);
diff --git a/packages/webamp-modern/src/maki-interpreter/interpreter.js b/packages/webamp-modern/src/maki-interpreter/interpreter.js
index dc51d204..9c0bddd6 100644
--- a/packages/webamp-modern/src/maki-interpreter/interpreter.js
+++ b/packages/webamp-modern/src/maki-interpreter/interpreter.js
@@ -11,16 +11,7 @@ function coerceTypes(var1, var2, val1 /* val2 */) {
return val1;
}
-// Note: We implement `interpret` as a generator in order to support pausing
-// execution in the debugger. This allows the caller granular control over the
-// execution timing of the virtual machine while also allowing the VM to divulge
-// some of its internal state before each command is exectued.
-//
-// In "production" we syncrnously call `.next()` on the generator until it's
-// empty, ignoring all yeilded values. In the debugger we use the yielded data
-// to populate the UI, and -- when stepping -- pause execution by waiting
-// between calls to `.next()`.
-export function* interpret(start, program, stack = []) {
+export function interpret(start, program, stack = []) {
const { commands, methods, variables, classes } = program;
function popStackValue() {
@@ -49,11 +40,6 @@ export function* interpret(start, program, stack = []) {
let ip = start;
while (ip < commands.length) {
const command = commands[ip];
- // This probably incurrs some perf cost. If it does, we can pass in a flag
- // to enable it only when we are debugging. When we are not, (in prod) we
- // can just jump right over it and we will execute straight through to the
- // return value on the first call to `.next()`.
- yield { i: ip, command, stack, variables, commands };
switch (command.opcode) {
// push
@@ -160,12 +146,9 @@ export function* interpret(start, program, stack = []) {
methodArgs.push(aValue);
}
const obj = popStackValue();
- const ret = obj[methodName](...methodArgs);
- let value;
- if (isPromise(ret)) {
- value = yield ret;
- } else {
- value = ret;
+ let value = obj[methodName](...methodArgs);
+ if (isPromise(value)) {
+ throw new Error("Did not expect maki method to return promise");
}
if (value === null) {
// variables[1] holds global NULL value
@@ -180,7 +163,7 @@ export function* interpret(start, program, stack = []) {
// Note: We proxy all yielded values from the child `interpret` out to
// the caller, while capturing the return value, (`value`) for use within the
// VM.
- const value = yield* interpret(offset, program, stack);
+ const value = interpret(offset, program, stack);
stack.push(value);
break;
}
diff --git a/packages/webamp-modern/src/maki-interpreter/virtualMachine.js b/packages/webamp-modern/src/maki-interpreter/virtualMachine.js
index 64b89065..a64d5b4d 100644
--- a/packages/webamp-modern/src/maki-interpreter/virtualMachine.js
+++ b/packages/webamp-modern/src/maki-interpreter/virtualMachine.js
@@ -1,29 +1,8 @@
import parse from "./parser";
import { getClass, getFormattedId } from "./objects";
import { interpret } from "./interpreter";
-import { isPromise } from "../utils";
-// Note: if this incurs a performance overhead, we could pass a flag into the VM
-// to not yield in production. In that case, we would never even enter the
-// `while` loop.
-async function runGeneratorUntilReturn(gen) {
- let val = gen.next();
- while (!val.done) {
- val = gen.next();
- if (isPromise(val.value)) {
- gen.next(await val.value);
- }
- }
- return val.value;
-}
-
-export function run({
- runtime,
- data,
- system,
- log,
- debugHandler = runGeneratorUntilReturn,
-}) {
+export function run({ runtime, data, system, log }) {
const program = parse(data);
// Replace class hashes with actual JavaScript classes from the runtime
@@ -50,12 +29,7 @@ export function run({
// TODO: Handle disposing of this.
// TODO: Handle passing in variables.
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.
- debugHandler(interpret(commandOffset, program, args.reverse()));
+ interpret(commandOffset, program, args.reverse());
});
});