lvm.js

changeset 24
5c9d8a65c87d
parent 23
70fc1cb387e1
child 25
9e62bc13b30d
equal deleted inserted replaced
23:70fc1cb387e1 24:5c9d8a65c87d
310 break; 310 break;
311 case OP_CLOSURE: 311 case OP_CLOSURE:
312 var prototype_id = INS_Bx(instruction); 312 var prototype_id = INS_Bx(instruction);
313 var chunk = this.frame.f.chunk.prototypes[prototype_id]; 313 var chunk = this.frame.f.chunk.prototypes[prototype_id];
314 var f = new LFunction(chunk, this.frame.f.environment); 314 var f = new LFunction(chunk, this.frame.f.environment);
315 this.frame.reg[INS_A(instruction)] = new LValue("function", f);
315 for(var i=0;i<chunk.numUpvalues;i++) 316 for(var i=0;i<chunk.numUpvalues;i++)
316 { 317 {
317 var upval_instruction = this.frame.f.instructions[this.frame.pc++]; 318 var upval_instruction = this.frame.f.instructions[this.frame.pc++];
318 switch(INS_OPCODE(upval_instruction)) 319 switch(INS_OPCODE(upval_instruction))
319 { 320 {
325 break; 326 break;
326 default: 327 default:
327 throw "Invalid upvalue opcode following OP_CLOSURE"; 328 throw "Invalid upvalue opcode following OP_CLOSURE";
328 } 329 }
329 } 330 }
330 this.frame.reg[INS_A(instruction)] = new LValue("function", f);
331 break; 331 break;
332 case OP_RETURN: 332 case OP_RETURN:
333 var oldFrame = this.callstack.pop(); 333 var oldFrame = this.callstack.pop();
334 this.frame = this.callstack[this.callstack.length-1]; 334 this.frame = this.callstack[this.callstack.length-1];
335 if(this.frame) 335 if(this.frame)

mercurial