summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lcode.js1
-rw-r--r--src/lparser.js10
2 files changed, 6 insertions, 5 deletions
diff --git a/src/lcode.js b/src/lcode.js
index 752eedf..aefad20 100644
--- a/src/lcode.js
+++ b/src/lcode.js
@@ -359,7 +359,6 @@ const luaK_patchclose = function(fs, list, level) {
** line information. Return 'i' position.
*/
const luaK_code = function(fs, i) {
- // console.log(`${i.opcode}\t${i.A}\t${i.B}\t${i.C}\t${i.Ax}\t${i.Bx}\t${i.sBx}`);
let f = fs.f;
dischargejpc(fs); /* 'pc' will change */
/* put new instruction in code array */
diff --git a/src/lparser.js b/src/lparser.js
index 73caf70..bdaa160 100644
--- a/src/lparser.js
+++ b/src/lparser.js
@@ -1128,11 +1128,11 @@ const assignment = function(ls, lh, nvars) {
const cond = function(ls) {
/* cond -> exp */
- let v = expdesc();
+ let v = new expdesc();
expr(ls, v); /* read condition */
if (v.k === expkind.VNIL) v.k = expkind.VFALSE; /* 'falses' are all equal here */
lcode.luaK_goiftrue(ls.fs, v);
- return v;
+ return v.f;
};
const gotostat = function(ls, pc) {
@@ -1341,15 +1341,17 @@ const test_then_block = function(ls, escapelist) {
if (ls.t.token === R.TK_ELSE || ls.t.token === R.TK_ELSEIF) /* followed by 'else'/'elseif'? */
escapelist = lcode.luaK_concat(fs, escapelist, lcode.luaK_jump(fs)); /* must jump over it */
lcode.luaK_patchtohere(fs, jf);
+
+ return escapelist
};
const ifstat = function(ls, line) {
/* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
let fs = ls.fs;
let escapelist = lcode.NO_JUMP; /* exit list for finished parts */
- test_then_block(ls, escapelist); /* IF cond THEN block */
+ escapelist = test_then_block(ls, escapelist); /* IF cond THEN block */
while (ls.t.token === R.TK_ELSEIF)
- test_then_block(ls, escapelist); /* ELSEIF cond THEN block */
+ escapelist = test_then_block(ls, escapelist); /* ELSEIF cond THEN block */
if (testnext(ls, R.TK_ELSE))
block(ls); /* 'else' part */
check_match(ls, R.TK_END, R.TK_IF, line);