reactivated code_dup
authorkramm <kramm>
Tue, 30 Dec 2008 22:55:03 +0000 (22:55 +0000)
committerkramm <kramm>
Tue, 30 Dec 2008 22:55:03 +0000 (22:55 +0000)
lib/as3/code.c
lib/as3/code.h

index bb59ede..e92d6c9 100644 (file)
@@ -1048,16 +1048,13 @@ code_t* code_append(code_t*code, code_t*toappend)
 lookupswitch_t*lookupswitch_dup(lookupswitch_t*l)
 {
     lookupswitch_t*n = malloc(sizeof(lookupswitch_t));
-    fprintf(stderr, "lookupswitch dupping not supported yet\n");
+    fprintf(stderr, "Error: 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;
@@ -1068,6 +1065,10 @@ code_t*code_dup(code_t*c)
         memcpy(n, c, sizeof(code_t));
 
         opcode_t*op = opcode_get(c->opcode);
+        if(c->branch) {
+            fprintf(stderr, "Error: Can't duplicate branching code\n");
+            return 0;
+        }
         char*p = op?op->params:"";
         int pos=0;
         while(*p) {
index 885bfbe..6ae24b9 100644 (file)
@@ -77,7 +77,7 @@ struct _codelookup {
     int len;
 };
 
-code_t*code_dup(code_t*c); //shallow copy
+code_t*code_dup(code_t*c);
 
 code_t*add_opcode(code_t*atag, U8 op);