# HG changeset patch # User Matthew Wild # Date 1290356861 0 # Node ID 5a0db53fc898116678179cd2bf8df6fb92fc6b08 # Parent 7bf985fd9e037d28323a15bea61010fe47995416 Implement OP_SETLIST diff -r 7bf985fd9e03 -r 5a0db53fc898 lvm.js --- a/lvm.js Sun Nov 21 16:27:18 2010 +0000 +++ b/lvm.js Sun Nov 21 16:27:41 2010 +0000 @@ -26,6 +26,7 @@ var OP_FORLOOP = 31; var OP_FORPREP = 32; var OP_TFORLOOP = 33; +var OP_SETLIST = 34; var OP_CLOSURE = 36; var debugMode = false; @@ -630,6 +631,19 @@ if(RB.value <= RC.value != (A!=0)) frame.pc++; break; + case OP_SETLIST: + var A = INS_A(instruction); + var RA = frame.reg[A]; + var B = INS_B(instruction); + var C = INS_C(instruction); + if(C == 0) + throw "Dynamic table construction not yet implemented"; + // #define LFIELDS_PER_FLUSH 50 // Lua 5.1 + var baseindex = (C-1)*50; + var index = new LValue(this, "number", 1); + for(var i = 1; i<=B; index.value=(baseindex+(++i))) + RA.setIndex(index, frame.reg[A+i]); + break; default: throw "Unhandled opcode: "+INS_OPCODE(instruction); }