RPA Toolkit
Build system cleanup...
[rpatk.git] / rvm / rvmscope.h
1 /*
2  *  Regular Pattern Analyzer (RPA)
3  *  Copyright (c) 2009-2010 Martin Stoilov
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  *  Martin Stoilov <martin@rpasearch.com>
19  */
20
21 #ifndef _RVMSCOPE_H_
22 #define _RVMSCOPE_H_
23
24 #include "rtypes.h"
25 #include "rlib/rarray.h"
26 #include "rlib/rhash.h"
27
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #define VARMAP_DATATYPE_OFFSET 0
34 #define VARMAP_DATATYPE_PTR 1
35
36
37 typedef struct rvm_varmap_s {
38         const char *name;
39         union {
40                 rpointer ptr;
41                 ruint32 offset;
42         } data;
43         unsigned char datatype;
44 } rvm_varmap_t;
45
46
47 typedef struct rvm_scope_s {
48         rarray_t *names;
49         rhash_t *nameshash;
50         rarray_t *varstack;
51         rarray_t *scopestack;
52 } rvm_scope_t;
53
54
55 rvm_scope_t *rvm_scope_create();
56 void rvm_scope_destroy(rvm_scope_t *scope);
57 char *rvm_scope_addname(rvm_scope_t *scope, const char *name, unsigned int namesize);
58 char *rvm_scope_addstrname(rvm_scope_t *scope, const char *name);
59 void rvm_scope_addoffset(rvm_scope_t *scope, const char *name, unsigned int namesize, ruint32 off);
60 void rvm_scope_addpointer(rvm_scope_t *scope, const char *name, unsigned int namesize, rpointer ptr);
61 void rvm_scope_addoffset_s(rvm_scope_t *scope, const char *name, ruint32 off);
62 void rvm_scope_addpointer_s(rvm_scope_t *scope, const char *name, rpointer ptr);
63 void rvm_scope_push(rvm_scope_t* scope);
64 void rvm_scope_pop(rvm_scope_t* scope);
65 unsigned int rvm_scope_count(rvm_scope_t* scope);
66 unsigned int rvm_scope_numentries(rvm_scope_t *scope);
67 rvm_varmap_t *rvm_scope_lookup(rvm_scope_t *scope, const char *name, unsigned int namesize);
68 rvm_varmap_t *rvm_scope_lookup_s(rvm_scope_t *scope, const char *name);
69 rvm_varmap_t *rvm_scope_tiplookup(rvm_scope_t *scope, const char *name, unsigned int namesize);
70 rvm_varmap_t *rvm_scope_tiplookup_s(rvm_scope_t *scope, const char *name);
71
72
73 #ifdef __cplusplus
74 }
75 #endif
76
77 #endif