ref: 1122d1f6479f0eba69bc72b6e9f7a772c9619592
parent: 50d5cb95abc045d219fa80e9b1f41470e2d86a89
author: Tor Andersson <tor.andersson@artifex.com>
date: Sun Jan 12 07:52:26 EST 2014
Improve opcode naming.
--- a/jscompile.c
+++ b/jscompile.c
@@ -124,16 +124,16 @@
{
switch (exp->type) {
case AST_IDENTIFIER:
- emitstring(J, F, OP_VAR, exp->string);
+ emitstring(J, F, OP_AVAR, exp->string);
break;
case EXP_INDEX:
cexp(J, F, exp->a);
cexp(J, F, exp->b);
- emit(J, F, OP_INDEX);
+ emit(J, F, OP_AINDEX);
break;
case EXP_MEMBER:
cexp(J, F, exp->a);
- emitstring(J, F, OP_MEMBER, exp->b->string);
+ emitstring(J, F, OP_AMEMBER, exp->b->string);
break;
default:
jsC_error(J, exp, "invalid l-value in assignment");
@@ -144,7 +144,7 @@
static void assignop(JF, js_Ast *exp, int opcode)
{
clval(J, F, exp->a);
- emit(J, F, OP_DUPLOAD);
+ emit(J, F, OP_DUP_LOAD);
cexp(J, F, exp->b);
emit(J, F, opcode);
emit(J, F, OP_STORE);
@@ -156,8 +156,7 @@
switch (exp->type) {
case AST_IDENTIFIER:
- emitstring(J, F, OP_VAR, exp->string);
- emit(J, F, OP_LOAD);
+ emitstring(J, F, OP_LOADVAR, exp->string);
break;
case AST_NUMBER: emitnumber(J, F, OP_CONST, exp->number); break;
@@ -181,14 +180,12 @@
case EXP_INDEX:
cexp(J, F, exp->a);
cexp(J, F, exp->b);
- emit(J, F, OP_INDEX);
- emit(J, F, OP_LOAD);
+ emit(J, F, OP_LOADINDEX);
break;
case EXP_MEMBER:
cexp(J, F, exp->a);
- emitstring(J, F, OP_MEMBER, exp->b->string);
- emit(J, F, OP_LOAD);
+ emitstring(J, F, OP_LOADMEMBER, exp->b->string);
break;
case EXP_CALL:
@@ -281,7 +278,7 @@
cexp(J, F, vardec->b);
else
emit(J, F, OP_UNDEF);
- emitstring(J, F, OP_DEFVAR, vardec->a->string);
+ emitstring(J, F, OP_VARDEC, vardec->a->string);
}
static void cvardeclist(JF, js_Ast *list)
@@ -346,9 +343,9 @@
case STM_WITH:
cexp(J, F, stm->a);
- emit(J, F, OP_PUSHWITH);
+ emit(J, F, OP_WITH);
cstm(J, F, stm->b);
- emit(J, F, OP_POPWITH);
+ emit(J, F, OP_ENDWITH);
break;
// switch
--- a/jscompile.h
+++ b/jscompile.h
@@ -3,6 +3,9 @@
enum
{
+ OP_POP,
+ OP_DUP,
+
OP_CONST,
OP_UNDEF,
OP_NULL,
@@ -15,17 +18,24 @@
OP_OBJECT,
OP_OBJECTPUT,
- OP_DEFVAR,
- OP_VAR,
- OP_INDEX,
- OP_MEMBER,
+ OP_VARDEC,
+ OP_FUNDEC,
+ OP_FUNEXP,
+
+ OP_LOADVAR,
+ OP_LOADINDEX,
+ OP_LOADMEMBER,
+ OP_AVAR,
+ OP_AINDEX,
+ OP_AMEMBER,
+
OP_LOAD,
- OP_DUPLOAD,
+ OP_DUP_LOAD,
OP_STORE,
OP_CALL,
+ OP_TCALL,
OP_NEW,
- OP_CLOSURE,
OP_DELETE,
OP_VOID,
@@ -63,18 +73,17 @@
OP_DIV,
OP_MOD,
- OP_JUMP,
- OP_JTRUE,
- OP_JFALSE,
-
OP_TRY,
OP_THROW,
OP_RETURN,
- OP_PUSHWITH,
- OP_POPWITH,
OP_DEBUGGER,
- OP_POP,
+ OP_WITH,
+ OP_ENDWITH,
+
+ OP_JUMP,
+ OP_JTRUE,
+ OP_JFALSE,
};
struct js_Function
--- a/jsdump.c
+++ b/jsdump.c
@@ -620,13 +620,16 @@
switch (c) {
case OP_CONST:
case OP_OBJECTPUT:
- case OP_DEFVAR:
- case OP_VAR:
- case OP_MEMBER:
+ case OP_VARDEC:
+ case OP_LOADVAR:
+ case OP_LOADMEMBER:
+ case OP_AVAR:
+ case OP_AMEMBER:
pc(' ');
jsC_dumpvalue(J, fun->klist[*p++]);
break;
case OP_CALL:
+ case OP_TCALL:
case OP_NEW:
printf(" %d", *p++);
break;