# HG changeset patch # User Matthew Wild # Date 1270561866 -3600 # Node ID ce2f27fa25a45b3d4ef09f18f836e03e7b549ae8 # Parent 3f055c9ab80e36fe9b50d7e6e5da4a131abaabc7 Use new notation for accessing instruction fields diff -r 3f055c9ab80e -r ce2f27fa25a4 lvm.js --- a/lvm.js Tue Apr 06 14:49:52 2010 +0100 +++ b/lvm.js Tue Apr 06 14:51:06 2010 +0100 @@ -200,27 +200,27 @@ switch(INS_OPCODE(instruction)) { case OP_MOVE: - this.frame.reg[instruction[1]] = this.frame.reg[instruction[2]]; + this.frame.reg[INS_A(instruction)] = this.frame.reg[INS_B(instruction)]; break; case OP_LOADNIL: - for(var i = instruction[1];i<=instruction[2];i++) + for(var i = INS_A(instruction);i<=INS_B(instruction);i++) this.frame.reg[i] = new LValue("nil", null); break; case OP_GETGLOBAL: - var name = this.frame.f.constants[instruction[2]]; - this.frame.reg[instruction[1]] = this.frame.f.environment.index(name); + var name = this.frame.f.constants[INS_Bx(instruction)]; + this.frame.reg[INS_A(instruction)] = this.frame.f.environment.index(name); break; case OP_SETGLOBAL: - var name = this.frame.f.constants[instruction[2]]; + var name = this.frame.f.constants[INS_Bx(instruction)]; this.frame.f.environment.setIndex(name, this.frame.reg[instruction[1]]); break; case OP_LOADK: - var value = this.frame.f.constants[instruction[2]]; - this.frame.reg[instruction[1]] = value; + var value = this.frame.f.constants[INS_Bx(instruction)]; + this.frame.reg[INS_A(instruction)] = value; break; case OP_CALL: - var f = this.frame.reg[instruction[1]].call(); // return JS or LValue - var args = this.frame.reg.splice(instruction[1]+1, instruction[1]+(instruction[2]-1)); + var f = this.frame.reg[INS_A(instruction)].call(); // return JS or LValue + var args = this.frame.reg.slice(INS_A(instruction)+1, INS_A(instruction)+(INS_B(instruction))); if(typeof(f) == "function") { // JS native function