311 this.frame.f.environment.setIndex(name, this.frame.reg[instruction[1]]); |
314 this.frame.f.environment.setIndex(name, this.frame.reg[instruction[1]]); |
312 break; |
315 break; |
313 case OP_LOADK: |
316 case OP_LOADK: |
314 var value = this.frame.f.constants[INS_Bx(instruction)]; |
317 var value = this.frame.f.constants[INS_Bx(instruction)]; |
315 this.frame.reg[INS_A(instruction)] = value; |
318 this.frame.reg[INS_A(instruction)] = value; |
|
319 break; |
|
320 case OP_NEWTABLE: |
|
321 this.frame.reg[INS_A(instruction)] = new LValue("table", {}); |
|
322 break; |
|
323 case OP_GETTABLE: |
|
324 var C = INS_C(instruction); |
|
325 var keysource = (C&256)?this.frame.f.constants:this.frame.reg; |
|
326 var key = keysource[C&0xff]; |
|
327 var value = this.frame.reg[INS_B(instruction)].index(key).value; |
|
328 this.frame.reg[INS_A(instruction)] = new LValueFromValue(value); |
|
329 break; |
|
330 case OP_SETTABLE: |
|
331 var C = INS_C(instruction); |
|
332 var valuesource = (C&256)?this.frame.f.constants:this.frame.reg; |
|
333 var value = valuesource[C&0xff]; |
|
334 |
|
335 var B = INS_B(instruction); |
|
336 var keysource = (B&256)?this.frame.f.constants:this.frame.reg; |
|
337 var key = keysource[B&0xff]; |
|
338 this.frame.reg[INS_A(instruction)].setIndex(key, value); |
316 break; |
339 break; |
317 case OP_CALL: |
340 case OP_CALL: |
318 var f = this.frame.reg[INS_A(instruction)].call(); // return JS or LValue |
341 var f = this.frame.reg[INS_A(instruction)].call(); // return JS or LValue |
319 var A = INS_A(instruction), B = INS_B(instruction), undefined; |
342 var A = INS_A(instruction), B = INS_B(instruction), undefined; |
320 var args = this.frame.reg.slice(A+1, B==0?undefined:(A+B)); |
343 var args = this.frame.reg.slice(A+1, B==0?undefined:(A+B)); |