X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fcode.c;h=49f794e3a1bf07ccc06f28c2cd1e43e6053b7a87;hb=4987e1acaaadbee119088bcdda9f560a44777261;hp=62dd2a18b43196a009d138f8d57f89b54c410f1d;hpb=309cfb29215471ef323da96e21d1e2c7c0508be0;p=swftools.git diff --git a/lib/as3/code.c b/lib/as3/code.c index 62dd2a1..49f794e 100644 --- a/lib/as3/code.c +++ b/lib/as3/code.c @@ -1045,8 +1045,19 @@ code_t* code_append(code_t*code, code_t*toappend) return code_end(toappend); } +lookupswitch_t*lookupswitch_dup(lookupswitch_t*l) +{ + lookupswitch_t*n = malloc(sizeof(lookupswitch_t)); + fprintf(stderr, "lookupswitch dupping not supported yet\n"); + n->targets = list_clone(l->targets); + return 0; +} + code_t*code_dup(code_t*c) { + /* misses branch relocation */ + fprintf(stderr, "dupping not supported yet\n"); + return 0; if(!c) return 0; while(c->prev) c = c->prev; @@ -1055,6 +1066,25 @@ code_t*code_dup(code_t*c) while(c) { NEW(code_t, n); memcpy(n, c, sizeof(code_t)); + + opcode_t*op = opcode_get(c->opcode); + char*p = op?op->params:""; + int pos=0; + while(*p) { + if(*p == '2') { //multiname + c->data[pos] = multiname_clone(c->data[pos]); + } else if(*p == 's' || *p == 'D') { + c->data[pos] = strdup(c->data[pos]); + } else if(*p == 'f') { + double old = *(double*)c->data[pos]; + c->data[pos] = malloc(sizeof(double)); + *(double*)c->data[pos] = old; + } else if(strchr("S", *p)) { + c->data[pos] = lookupswitch_dup(c->data[pos]); + } + p++;pos++; + } + n->prev = last; if(last) { last->next = n;