ref: 67de4965c6190526606344edc59af8b621835e50
parent: 1122d1f6479f0eba69bc72b6e9f7a772c9619592
author: Tor Andersson <[email protected]>
date: Sun Jan 12 07:54:08 EST 2014
Use special TCALL opcode for foo.bar() calls that set 'this' for the call.
--- a/jscompile.c
+++ b/jscompile.c
@@ -189,10 +189,19 @@
break;
case EXP_CALL:
- cexp(J, F, exp->a);
- n = cargs(J, F, exp->b);
- emit(J, F, OP_CALL);
- emit(J, F, n);
+ if (exp->a->type == EXP_MEMBER) {
+ cexp(J, F, exp->a->a);
+ emit(J, F, OP_DUP);
+ emitstring(J, F, OP_LOADMEMBER, exp->a->b->string);
+ n = cargs(J, F, exp->b);
+ emit(J, F, OP_TCALL);
+ emit(J, F, n);
+ } else {
+ cexp(J, F, exp->a);
+ n = cargs(J, F, exp->b);
+ emit(J, F, OP_CALL);
+ emit(J, F, n);
+ }
break;
case EXP_NEW:
@@ -200,6 +209,11 @@
n = cargs(J, F, exp->b);
emit(J, F, OP_NEW);
emit(J, F, n);
+ break;
+
+ case EXP_DELETE:
+ clval(J, F, exp->a);
+ emit(J, F, OP_DELETE);
break;
case EXP_VOID: