Fix OP_CALL to handle the case of B==1 (no parameters) and fix an off-by-one error that wouldn't fill the stack with nils properly

Mon, 22 Nov 2010 02:31:16 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 22 Nov 2010 02:31:16 +0000
changeset 113
1e49dfb8ccdc
parent 112
5318bb31b0ac
child 114
82d7b057d330

Fix OP_CALL to handle the case of B==1 (no parameters) and fix an off-by-one error that wouldn't fill the stack with nils properly

lvm.js file | annotate | diff | comparison | revisions
--- a/lvm.js	Sun Nov 21 21:37:07 2010 +0000
+++ b/lvm.js	Mon Nov 22 02:31:16 2010 +0000
@@ -475,8 +475,12 @@
 				var f = frame.reg[INS_A(instruction)].precall(); // return JS or LValue
 				var A = INS_A(instruction), B = INS_B(instruction), C = INS_C(instruction);
 				var undefined;
-				var args = frame.reg.slice(A+1, B==0?undefined:(A+B));
-				for(var i=args.length+1;i<f.maxStackSize;i++)
+				var args;
+				if(B != 1)
+					args = frame.reg.slice(A+1, B==0?undefined:(A+B));
+				else
+					args = [];
+				for(var i=args.length;i<f.maxStackSize;i++)
 					args[i] = new LValue(this, "nil", null);
 				if(typeof(f) == "function")
 				{

mercurial