RPA Toolkit
2831ebc97f00cf931598168bc775ff05d3f572da
[rpatk.git] / rpa2 / rpacompiler.h
1 #ifndef _RPACOMPILER_H_
2 #define _RPACOMPILER_H_
3
4 #include "rvmcodegen.h"
5 #include "rvmscope.h"
6 #include "rpavm.h"
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 typedef struct rpa_ruledef_s {
13         rulong branch;
14         rulong start;
15         rlong labelidx;
16         rlong emitidx;
17         rlong endidx;
18 } rpa_ruledef_t;
19
20
21 #define RPA_COMPILER_CURRENTEXP(__co__) ((rpa_ruledef_t*)r_array_lastslot((__co__)->expressions))
22
23 typedef struct rpa_compiler_s {
24         rvm_codegen_t *cg;
25         rarray_t *expressions;
26         rboolean optimized;
27         rvm_scope_t *scope;
28         rulong fpoff;
29 } rpa_compiler_t;
30
31
32 rpa_compiler_t *rpa_compiler_create();
33 void rpa_compiler_destroy(rpa_compiler_t *co);
34 rint rpa_compiler_rule_begin(rpa_compiler_t *co, const rchar *name, ruint namesize);
35 rint rpa_compiler_rule_begin_s(rpa_compiler_t *co, const rchar *name);
36 rint rpa_compiler_rule_end(rpa_compiler_t *co);
37
38 rint rpa_compiler_exp_begin(rpa_compiler_t *co);
39 rint rpa_compiler_exp_end(rpa_compiler_t *co, ruint qflag);
40
41
42 #ifdef __cplusplus
43 }
44 #endif
45
46 #endif