lvm.js

changeset 130
88fa4df26e9d
parent 129
6784d462999f
child 131
cd1ba419c808
equal deleted inserted replaced
129:6784d462999f 130:88fa4df26e9d
401 var f = func.precall(); 401 var f = func.precall();
402 if(typeof(f) == "function") 402 if(typeof(f) == "function")
403 { 403 {
404 return f.apply(this, args); 404 return f.apply(this, args);
405 } 405 }
406 else 406 else if(f.instructions)
407 { 407 {
408 var frame = {f:f,pc:0,entry:true}; 408 var frame = {f:f,pc:0,entry:true};
409 if(args) 409 if(args)
410 frame.reg = args.slice(0); 410 frame.reg = args.slice(0);
411 else 411 else
413 this.callstack.push(frame); 413 this.callstack.push(frame);
414 for(var i=frame.reg.length;i<f.maxStackSize;i++) 414 for(var i=frame.reg.length;i<f.maxStackSize;i++)
415 frame.reg[i] = this.LValue(null); 415 frame.reg[i] = this.LValue(null);
416 return this.run(frame); 416 return this.run(frame);
417 } 417 }
418 else
419 throw "Attempt to call invalid function object: "+f.toString();
418 }, 420 },
419 run: function(frame) 421 run: function(frame)
420 { 422 {
421 var instruction; 423 var instruction;
422 while(this.callstack.length>0) 424 while(this.callstack.length>0)

mercurial