added statistics generation
[swftools.git] / lib / as3 / code.h
1 #ifndef __abc_code_h__
2 #define __abc_code_h__
3
4 #include "../q.h"
5
6 DECLARE(abc_code);
7 DECLARE(codestats);
8
9 #include "abc.h"
10
11 typedef struct _opcode
12 {
13     unsigned char opcode;
14     char*name;
15     char*params;
16
17     int stack_minus;
18     int stack_plus;
19     int scope_stack_plus;
20     int flags;
21 } opcode_t;
22
23 struct _abc_code {
24     U8 opcode;
25     U8 len;
26     void*data[2];
27     abc_code_t*next;
28     abc_code_t*prev;
29     abc_code_t*parent;
30
31     abc_code_t*branch;
32     int pos; //used during code path evaluation
33 };
34
35 struct _codestats {
36     int max_stack;
37     int local_count;
38     int init_scope_depth;
39     int max_scope_depth;
40 };
41
42 abc_code_t*add_opcode(abc_code_t*atag, U8 op);
43
44 abc_code_t*code_parse(TAG*tag, int len, abc_file_t*file, pool_t*pool);
45 int        code_dump(abc_code_t*c, abc_file_t*file, char*prefix, FILE*fo);
46 void       code_write(TAG*tag, abc_code_t*code, pool_t*pool, abc_file_t*file);
47 void       code_free(abc_code_t*c);
48
49
50 #endif