-#ifndef __abc_code_h__
-#define __abc_code_h__
+#ifndef __code_h__
+#define __code_h__
#include "../q.h"
-DECLARE(abc_code);
+DECLARE(code);
+DECLARE_LIST(code);
DECLARE(codestats);
+DECLARE(codelookup);
+DECLARE(lookupswitch);
#include "abc.h"
int flags;
} opcode_t;
-struct _abc_code {
+struct _code {
void*data[2];
- abc_code_t*next;
- abc_code_t*prev;
+ code_t*next;
+ code_t*prev;
- abc_code_t*branch;
+ code_t*branch;
int pos; //used during code path evaluation
U8 opcode;
+ char badbranch;
};
+struct _lookupswitch {
+ code_t*def;
+ code_list_t*targets;
+};
+
+#define FLAGS_ACTIVATION 0x02
+#define FLAGS_SET_DXNS 0x40
struct _codestats {
int max_stack;
int local_count;
- int init_scope_depth;
int max_scope_depth;
+ int flags;
};
-abc_code_t*add_opcode(abc_code_t*atag, U8 op);
+struct _codelookup {
+ code_t**bytepos;
+ int len;
+};
+
+code_t*add_opcode(code_t*atag, U8 op);
+
+code_t*code_parse(TAG*tag, int len, abc_file_t*file, pool_t*pool, codelookup_t**codelookup);
+int code_dump(code_t*c, exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo);
+void code_write(TAG*tag, code_t*code, pool_t*pool, abc_file_t*file);
+void code_free(code_t*c);
+code_t* code_atposition(codelookup_t*l, int pos);
+void codelookup_free(codelookup_t*codelookup);
-abc_code_t*code_parse(TAG*tag, int len, abc_file_t*file, pool_t*pool);
-int code_dump(abc_code_t*c, abc_file_t*file, char*prefix, FILE*fo);
-void code_write(TAG*tag, abc_code_t*code, pool_t*pool, abc_file_t*file);
-void code_free(abc_code_t*c);
+codestats_t* code_get_statistics(code_t*code, exception_list_t*exceptions);
-codestats_t code_get_statistics(abc_code_t*code);
+void codestats_print(codestats_t*s);
+void codestats_free(codestats_t*s);
#endif