Mon, 24 May 2010 14:12:14 +0100
Merge backout
lvm.js | file | annotate | diff | comparison | revisions |
--- a/lvm.js Mon May 24 14:08:50 2010 +0100 +++ b/lvm.js Mon May 24 14:12:14 2010 +0100 @@ -260,11 +260,12 @@ return (INS_Bx(ins)-0x1FFFF); } -function LFunction(chunk, env) +function LFunction(vm, chunk, env) { function F() {}; F.prototype = chunk; var o = new F(); + o.vm = vm; o.environment = env; o.chunk = chunk; o.upvalues = []; @@ -375,7 +376,7 @@ case OP_CLOSURE: var prototype_id = INS_Bx(instruction); var chunk = frame.f.chunk.prototypes[prototype_id]; - var f = new LFunction(chunk, frame.f.environment); + var f = new LFunction(this, chunk, frame.f.environment); frame.reg[INS_A(instruction)] = new LValue("function", f); for(var i=0;i<chunk.numUpvalues;i++) { @@ -466,7 +467,7 @@ default_environment.setIndex(LValueFromString("print"), LValueFromFunction(print)); -var f = new LFunction(c, default_environment); +var f = new LFunction(this, c, default_environment); try{ testvm.call(f); @@ -476,4 +477,5 @@ print("Error: " + e); if(typeof(e) == "object" && "stack" in e) print(e.stack); + process.exit(1); }