u = u30
r = register
*/
-
+
opcode_t opcodes[]={
{0xa0, "add", "", -2, 1, 0, 0},
{0xc5, "add_i", "", -2, 1, 0, 0},
{0x57, "newactivation", "", 0, 1, 0, OP_NEED_ACTIVATION},
{0x56, "newarray", "n", 0, 1, 0, OP_STACK_ARGS},
{0x5a, "newcatch", "u", 0, 1, 0, 0}, //u = index into exception_info
+#define OP_NEWCLASS 0x58
{0x58, "newclass", "c", -1, 1, 0, 0}, //c = index into class_info
+#define OP_NEWFUNCTION 0x40
{0x40, "newfunction", "m", 0, 1, 0, 0}, //i = index into method_info
{0x55, "newobject", "n", 0, 1, 0, OP_STACK_ARGS2},
{0x1e, "nextname", "", -2, 1, 0, 0},
{0x24, "pushbyte", "b", 0, 1, 0, 0},
{0x2f, "pushdouble", "f", 0, 1, 0, 0}, //index into floats
{0x27, "pushfalse", "", 0, 1, 0, 0},
-{0x2d, "pushint", "i", 0, 1, 0, 0}, //index into ints
-{0x31, "pushnamespace", "u", 0, 1, 0, 0}, //index into namespace
+{0x2d, "pushint", "I", 0, 1, 0, 0}, //index into ints
+{0x31, "pushnamespace", "u", 0, 1, 0, 0}, //index into namespace TODO
{0x28, "pushnan", "", 0, 1, 0, 0},
{0x20, "pushnull", "", 0, 1, 0, 0},
{0x30, "pushscope", "", -1, 0, 1, 0},
code_t*code_find_start(code_t*c)
{
- while(c->prev)
+ while(c && c->prev)
c=c->prev;
return c;
}
printf(" 00000000\n");
}
if(op->params[0]=='2') {
- printf(" %s", multiname_to_string(c->data[0]));
+ printf(" %s", multiname_tostring(c->data[0]));
}
printf("\n");
}
stats->flags |= FLAGS_SET_DXNS;
if(op->flags & OP_NEED_ACTIVATION)
stats->flags |= FLAGS_ACTIVATION;
+
+ if(c->opcode == OP_NEWCLASS) {
+ abc_class_t*cls = (abc_class_t*)(c->data[0]);
+ if(scope > cls->init_scope_depth)
+ cls->init_scope_depth = scope;
+ }
+ if(c->opcode == OP_NEWFUNCTION) {
+ abc_method_t*m = (abc_method_t*)(c->data[0]);
+ if(m->body && scope > m->body->init_scope_depth)
+ m->body->init_scope_depth = scope;
+ }
if(op->flags & OP_REGISTER) {
char*p = op->params;
if(op->flags & (OP_JUMP|OP_BRANCH)) {
printf("%5d) %s %08x\n", t, op->name, c->branch);
} else if(op->params[0]=='2') {
- printf("%5d) %s %s\n", t, op->name, multiname_to_string(c->data[0]));
+ printf("%5d) %s %s\n", t, op->name, multiname_tostring(c->data[0]));
} else {
printf("%5d) %s\n", t, op->name);
}
if(c==e->exception->from)
fprintf(fo, "%s TRY {\n", prefix);
if(c==e->exception->target) {
- char*s1 = multiname_to_string(e->exception->exc_type);
- char*s2 = multiname_to_string(e->exception->var_name);
+ char*s1 = multiname_tostring(e->exception->exc_type);
+ char*s2 = multiname_tostring(e->exception->var_name);
fprintf(fo, "%s CATCH(%s %s)\n", prefix, s1, s2);
free(s1);
free(s2);
fprintf(fo, "%d params", n);
} else if(*p == '2') {
multiname_t*n = (multiname_t*)data;
- char* m = multiname_to_string(n);
+ char* m = multiname_tostring(n);
fprintf(fo, "%s", m);
free(m);
} else if(*p == 'm') {
fprintf(fo, "[method %s]", m->name);
} else if(*p == 'c') {
abc_class_t*cls = (abc_class_t*)data;
- char*classname = multiname_to_string(cls->classname);
+ char*classname = multiname_tostring(cls->classname);
fprintf(fo, "[classinfo %s]", classname);
free(classname);
} else if(*p == 'i') {
tmp->next = 0;
if(atag) {
tmp->prev = atag;
+ tmp->next = atag->next;
atag->next = tmp;
} else {
tmp->prev = 0;
printf("scope_depth: %d\n", stats->max_scope_depth);
}
+code_t* code_append(code_t*code, code_t*toappend)
+{
+ if(!code)
+ return toappend;
+ if(!toappend)
+ return code;
+ //find end of first list
+ while(code->next) {
+ code = code->next;
+ }
+ code_t*start=toappend;
+ //and start of second list
+ while(start->prev) {
+ start = start->prev;
+ }
+ code->next = start;
+ start->prev = code;
+ return toappend;
+}
+