Sun, 23 May 2010 17:31:15 +0100
Initialise all stack slots to nil when calling a chunk
lvm.js | file | annotate | diff | comparison | revisions |
--- a/lvm.js Sun May 23 17:30:43 2010 +0100 +++ b/lvm.js Sun May 23 17:31:15 2010 +0100 @@ -280,6 +280,8 @@ { this.frame = {f:lfFunction,pc:0,reg:[]}; this.callstack.push(this.frame); + for(var i=0;i<lfFunction.maxStackSize;i++) + this.frame.reg[i] = new LValue("nil", null); var instruction; while(this.callstack.length>0) { @@ -343,6 +345,8 @@ var f = this.frame.reg[INS_A(instruction)].call(); // return JS or LValue var A = INS_A(instruction), B = INS_B(instruction), undefined; var args = this.frame.reg.slice(A+1, B==0?undefined:(A+B)); + for(var i=args.length+1;i<f.maxStackSize;i++) + args[i] = new LValue("nil", null); if(typeof(f) == "function") { // JS native function