# HG changeset patch # User Matthew Wild # Date 1270605952 -3600 # Node ID 5240eaff785fffbc6cf53d09d1778a1a1951aac3 # Parent 21a2fce50931b3ae93f7cc172b076d97dceb882a Implement basic OP_CLOSURE (no support for upvalues yet) diff -r 21a2fce50931 -r 5240eaff785f lvm.js --- a/lvm.js Wed Apr 07 03:05:24 2010 +0100 +++ b/lvm.js Wed Apr 07 03:05:52 2010 +0100 @@ -6,6 +6,7 @@ var OP_SETGLOBAL = 7; var OP_CALL = 28; var OP_RETURN = 30; +var OP_CLOSURE = 36; var debugMode = false; @@ -294,6 +295,14 @@ // Lua function } break; + case OP_CLOSURE: + var prototype_id = INS_Bx(instruction); + var chunk = this.frame.f.chunk.prototypes[prototype_id]; + if(chunk.numUpvalues>0) + throw "Upvalues not yet implemented, sorry :)"; + var f = new LFunction(chunk, this.frame.f.environment); + this.frame.reg[INS_A(instruction)] = new LValue("function", f); + break; case OP_RETURN: this.callstack.pop(); break;