lvm.js

changeset 103
5a0db53fc898
parent 102
7bf985fd9e03
child 104
c481f6bfb19b
equal deleted inserted replaced
102:7bf985fd9e03 103:5a0db53fc898
24 var OP_CALL = 28; 24 var OP_CALL = 28;
25 var OP_RETURN = 30; 25 var OP_RETURN = 30;
26 var OP_FORLOOP = 31; 26 var OP_FORLOOP = 31;
27 var OP_FORPREP = 32; 27 var OP_FORPREP = 32;
28 var OP_TFORLOOP = 33; 28 var OP_TFORLOOP = 33;
29 var OP_SETLIST = 34;
29 var OP_CLOSURE = 36; 30 var OP_CLOSURE = 36;
30 31
31 var debugMode = false; 32 var debugMode = false;
32 33
33 function LValue(vm, type, value) 34 function LValue(vm, type, value)
628 var RB = RK(frame, INS_B(instruction)); 629 var RB = RK(frame, INS_B(instruction));
629 var RC = RK(frame, INS_C(instruction)); 630 var RC = RK(frame, INS_C(instruction));
630 if(RB.value <= RC.value != (A!=0)) 631 if(RB.value <= RC.value != (A!=0))
631 frame.pc++; 632 frame.pc++;
632 break; 633 break;
634 case OP_SETLIST:
635 var A = INS_A(instruction);
636 var RA = frame.reg[A];
637 var B = INS_B(instruction);
638 var C = INS_C(instruction);
639 if(C == 0)
640 throw "Dynamic table construction not yet implemented";
641 // #define LFIELDS_PER_FLUSH 50 // Lua 5.1
642 var baseindex = (C-1)*50;
643 var index = new LValue(this, "number", 1);
644 for(var i = 1; i<=B; index.value=(baseindex+(++i)))
645 RA.setIndex(index, frame.reg[A+i]);
646 break;
633 default: 647 default:
634 throw "Unhandled opcode: "+INS_OPCODE(instruction); 648 throw "Unhandled opcode: "+INS_OPCODE(instruction);
635 } 649 }
636 } 650 }
637 }, 651 },

mercurial