lvm.js

changeset 134
2e2d08e3669c
parent 133
afce5a550d18
child 135
77022489338a
equal deleted inserted replaced
133:afce5a550d18 134:2e2d08e3669c
501 frame.reg[A+i] = new LValue(this, "nil", null); 501 frame.reg[A+i] = new LValue(this, "nil", null);
502 } 502 }
503 break; 503 break;
504 case OP_TAILCALL: 504 case OP_TAILCALL:
505 var f = frame.reg[INS_A(instruction)].precall(); 505 var f = frame.reg[INS_A(instruction)].precall();
506 var A = INS_A(instruction), B = INS_B(instruction); 506 if(typeof(f) != "function") // Can't tail-call native functions
507 var undefined, args; 507 {
508 if(B != 1) 508 var A = INS_A(instruction), B = INS_B(instruction);
509 args = frame.reg.slice(A+1, B==0?undefined:(A+B)); 509 var undefined, args;
510 else 510 if(B != 1)
511 args = []; 511 args = frame.reg.slice(A+1, B==0?undefined:(A+B));
512 if(args.length > f.numParameters) 512 else
513 args.length = f.numParameters; 513 args = [];
514 for(var i=args.length;i<f.maxStackSize;i++) 514 if(args.length > f.numParameters)
515 args[i] = new LValue(this, "nil", null); 515 args.length = f.numParameters;
516 // Patch frame for new function 516 for(var i=args.length;i<f.maxStackSize;i++)
517 frame.f = f; frame.pc = 0; frame.reg = args; 517 args[i] = new LValue(this, "nil", null); // Patch frame for new function
518 break; 518 frame.f = f; frame.pc = 0; frame.reg = args;
519 break;
520 }
521 // Fall through...
519 case OP_CALL: 522 case OP_CALL:
520 var f = frame.reg[INS_A(instruction)].precall(); // return JS or LFunction 523 var f = frame.reg[INS_A(instruction)].precall(); // return JS or LFunction
521 var A = INS_A(instruction), B = INS_B(instruction), C = INS_C(instruction); 524 var A = INS_A(instruction), B = INS_B(instruction), C = INS_C(instruction);
522 var undefined; 525 var undefined;
523 var args; 526 var args;

mercurial