# HG changeset patch # User Matthew Wild # Date 1290454692 0 # Node ID 29c56996fa030c2139f4f68e9012eef2934b9f78 # Parent 9a4c549c78281e9836ac2bbcc68dab9d7fafb626 Change LVM.call() to take an LValue rather than the raw native/LFunction object. Also add LVM.loadstring(chunk, env) and use that for loading luac.out. diff -r 9a4c549c7828 -r 29c56996fa03 lvm.js --- a/lvm.js Mon Nov 22 05:06:37 2010 +0000 +++ b/lvm.js Mon Nov 22 19:38:12 2010 +0000 @@ -50,8 +50,7 @@ LValue.prototype = { call: function (args) { - var f = this.precall(); - var ret = this.vm.call(f, args); + var ret = this.vm.call(this, args); if(typeof(ret) == "undefined") ret = []; return ret; @@ -204,7 +203,7 @@ if(debugMode) { var pi = this.instructions[this.instructions.length-1]; - sys.puts("Pos: "+(this.pos-4)+" Ins: "+ins+" OP: "+INS_OPCODE(pi)+" A: "+INS_A(pi)+" B: "+INS_B(pi)+" C: "+INS_C(pi)+" Bx: "+INS_Bx(pi)+" sBx: "+(INS_Bx(pi)-0x1FFFE)); + //sys.puts("Pos: "+(this.pos-4)+" Ins: "+ins+" OP: "+INS_OPCODE(pi)+" A: "+INS_A(pi)+" B: "+INS_B(pi)+" C: "+INS_C(pi)+" Bx: "+INS_Bx(pi)+" sBx: "+(INS_Bx(pi)-0x1FFFE)); } } @@ -397,21 +396,22 @@ typeof(value)+" from Javascript to Lua"; } }, - call: function (lfFunction, args) + call: function (func, args) { - if(typeof(lfFunction) == "function") + var f = func.precall(); + if(typeof(f) == "function") { - return lfFunction.apply(this, args); + return f.apply(this, args); } else { - var frame = {f:lfFunction,pc:0,entry:true}; + var frame = {f:f,pc:0,entry:true}; if(args) frame.reg = args.slice(0); else frame.reg = []; this.callstack.push(frame); - for(var i=frame.reg.length;i