added flags generation
[swftools.git] / lib / as3 / code.h
1 #ifndef __code_h__
2 #define __code_h__
3
4 #include "../q.h"
5
6 DECLARE(code);
7 DECLARE_LIST(code);
8 DECLARE(codestats);
9 DECLARE(codelookup);
10 DECLARE(lookupswitch);
11
12 #include "abc.h"
13
14 typedef struct _opcode
15 {
16     unsigned char opcode;
17     char*name;
18     char*params;
19
20     int stack_minus;
21     int stack_plus;
22     int scope_stack_plus;
23     int flags;
24 } opcode_t;
25
26 struct _code {
27     void*data[2];
28     code_t*next;
29     code_t*prev;
30
31     code_t*branch;
32     int pos; //used during code path evaluation
33     
34     U8 opcode;
35     char badbranch;
36 };
37
38 struct _lookupswitch {
39     code_t*def;
40     code_list_t*targets;
41 };
42
43 #define FLAGS_ACTIVATION 0x02
44 #define FLAGS_SET_DXNS 0x40
45 struct _codestats {
46     int max_stack;
47     int local_count;
48     int init_scope_depth;
49     int max_scope_depth;
50     int flags;
51 };
52
53 struct _codelookup {
54     code_t**bytepos;
55     int len;
56 };
57
58 code_t*add_opcode(code_t*atag, U8 op);
59
60 code_t*code_parse(TAG*tag, int len, abc_file_t*file, pool_t*pool, codelookup_t**codelookup);
61 int        code_dump(code_t*c, exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo);
62 void       code_write(TAG*tag, code_t*code, pool_t*pool, abc_file_t*file);
63 void       code_free(code_t*c);
64 code_t* code_atposition(codelookup_t*l, int pos);
65 void codelookup_free(codelookup_t*codelookup);
66
67 codestats_t* code_get_statistics(code_t*code, exception_list_t*exceptions);
68
69 void codestats_print(codestats_t*s);
70 void codestats_free(codestats_t*s);
71
72
73 #endif