From 719f26744e38f9abbcadfc132b214dfd950a79fd Mon Sep 17 00:00:00 2001
From: kramm <kramm>
Date: Fri, 2 Jan 2009 19:46:19 +0000
Subject: [PATCH] warn about internal opcodes during writing

---
 lib/as3/code.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/as3/code.c b/lib/as3/code.c
index aef16ed..8a729d4 100644
--- a/lib/as3/code.c
+++ b/lib/as3/code.c
@@ -37,6 +37,7 @@
 #define OP_LOOKUPSWITCH 512
 #define OP_NEED_ACTIVATION 1024
 #define OP_STACK_ARGS2 2048
+#define OP_INTERNAL 32768
 
 /* 2 = u30 index into multiname
    m = u30 index into method
@@ -200,8 +201,8 @@ opcode_t opcodes[]={
 {0x53, "applytype", "n",       -1, 1, 0, OP_STACK_ARGS},
 
 /* dummy instruction. Warning: this one is not actually supported by flash */
-{0xfe, "__continue__", "s",           0, 0, 0, OP_RETURN},
-{0xff, "__break__", "s",            0, 0, 0, OP_RETURN},
+{0xfe, "__continue__", "s",           0, 0, 0, OP_RETURN|OP_INTERNAL},
+{0xff, "__break__", "s",            0, 0, 0, OP_RETURN|OP_INTERNAL},
 };
 
 static U8 op2index[256] = {254};
@@ -459,6 +460,15 @@ static int opcode_write(TAG*tag, code_t*c, pool_t*pool, abc_file_t*file, int len
         swf_SetU8(tag, c->opcode);
     len++;
 
+    if(op->flags & OP_INTERNAL) {
+        if(c->opcode == OPCODE___BREAK__ ||
+           c->opcode == OPCODE___CONTINUE__) {
+            fprintf(stderr, "Unresolved %s\n", op->name);
+        } else {
+            fprintf(stderr, "Error: writing undefined internal opcode %s", op->name);
+        }
+    }
+
     while(*p) {
         void*data = c->data[pos++];
         assert(pos<=2);
-- 
1.7.10.4