RPA Toolkit
adding rvm_compiler_t to the rpagen test
[rpatk.git] / rvm / rvmscope.h
1 #ifndef _RVMSCOPE_H_
2 #define _RVMSCOPE_H_
3
4 #include "rtypes.h"
5 #include "rarray.h"
6 #include "rhash.h"
7
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13
14 #define VARMAP_DATATYPE_OFFSET 0
15 #define VARMAP_DATATYPE_PTR 1
16
17 typedef struct rvm_varmap_s {
18         const rchar *name;
19         union {
20                 rpointer ptr;
21                 ruint32 offset;
22         } data;
23         ruchar datatype;
24 } rvm_varmap_t;
25
26
27 typedef struct rvm_scope_s {
28         rarray_t *names;
29         rhash_t *nameshash;
30         rarray_t *varstack;
31         rarray_t *scopestack;
32 } rvm_scope_t;
33
34
35 rvm_scope_t *rvm_scope_create();
36 void rvm_scope_destroy(rvm_scope_t *scope);
37 rchar *rvm_scope_addname(rvm_scope_t *scope, const rchar *name, ruint namesize);
38 rchar *rvm_scope_addstrname(rvm_scope_t *scope, const rchar *name);
39 void rvm_scope_addoffset(rvm_scope_t *scope, const rchar *name, ruint namesize, ruint32 off);
40 void rvm_scope_addpointer(rvm_scope_t *scope, const rchar *name, ruint namesize, rpointer ptr);
41 void rvm_scope_push(rvm_scope_t* scope);
42 void rvm_scope_pop(rvm_scope_t* scope);
43 ruint rvm_scope_numentries(rvm_scope_t *scope);
44 rvm_varmap_t *rvm_scope_lookup(rvm_scope_t *scope, const rchar *name, ruint namesize);
45 rvm_varmap_t *rvm_scope_lookup_tip(rvm_scope_t *scope, const rchar *name, ruint namesize);
46 rvm_varmap_t *rvm_scope_lookup_s(rvm_scope_t *scope, const rchar *name);
47 rvm_varmap_t *rvm_scope_lookuptip_s(rvm_scope_t *scope, const rchar *name);
48
49
50 #ifdef __cplusplus
51 }
52 #endif
53
54 #endif