diff options
author | Matthew Sotoudeh <matthewsot@outlook.com> | 2017-07-30 00:59:32 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthewsot@outlook.com> | 2017-07-30 00:59:32 -0700 |
commit | 173c79c5a11126240c3377493ee74386839bb05c (patch) | |
tree | fa830aba496debebd744b8fb0cfcfc129e31e1ab | |
parent | 59d92d38a3a575c59d9b001a7b9a05cf72a1a088 (diff) |
fixed loops
-rw-r--r-- | editor/.editor.html.swo | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | interpreter/interpreter.js | 12 |
2 files changed, 10 insertions, 2 deletions
diff --git a/editor/.editor.html.swo b/editor/.editor.html.swo Binary files differnew file mode 100644 index 0000000..44c9a44 --- /dev/null +++ b/editor/.editor.html.swo diff --git a/interpreter/interpreter.js b/interpreter/interpreter.js index 086fd0f..fe3daed 100644 --- a/interpreter/interpreter.js +++ b/interpreter/interpreter.js @@ -42,9 +42,17 @@ Yaepl.prototype.globalScope = { "or": function (a, b) { return (a || b); }, "and": function (a, b) { return (a && b); }, "jump-bwd": function (b) { - for (var i = b.targetIndex; i < this.fullText.length; i++) { - this.interpretLine(this.fullText[i], function () {}, false); + var lines = this.fullText; + var yaepl = this; + function interpretLine(l) { + yaepl.interpretLine(lines[l], function () { + l++; + if (l < lines.length) { + interpretLine(l); + } + }, false); } + interpretLine(b.targetIndex); }, "jump-bwd-if": function (a, b) { if (!a) return; |