Rune - Cleanup PointerInfo use in interpreter
[rune.git] / librune / export.h
1 /*
2  * EXPORT.H
3  *
4  * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved.  See the  
5  *    COPYRIGHT file at the base of the distribution.
6  */
7
8 /*
9  * Headers needed by others using this library
10  */
11 #include <sys/types.h>
12 #include <stdint.h>
13 #include <limits.h>
14
15 #include "lex.h"
16 #include "sym.h"
17 #include "type.h"
18 #include "decl.h"
19 #include "exp.h"
20 #include "stmt.h"
21 #include "parse.h"
22 #include "insn.h"
23 #include "context.h"
24
25 /*
26  * debug_lex.c
27  */
28 void LexDebugLine(token_t *tok);
29
30 /*
31  * decl.c
32  */
33 Declaration *FindDeclId(SemGroup *db, string_t id, int *eno);
34 Declaration *FindDeclIdLevel(SemGroup *db, string_t id, int level, int *eno);
35 Declaration *FindDeclByIndex(SemGroup *sg, int index);
36 void DeclPrintError(Declaration *d, int type);
37 Declaration *FindDeclPath(LexRef *lexRef, SemGroup *osg, SemGroup *sg,
38                         Type *nomatch, string_t *ary, int mask,
39                         int *visibility, int level, int *eno);
40 Declaration *FindDeclPathAltContext(LexRef *lexRef, SemGroup *osg, SemGroup *sg,
41                         Type *nomatch, string_t *ary, int mask,
42                         int *visibility, int level, int *eno);
43 void *FindDLLSymbol(SemGroup *osg, SemGroup *sg, string_t id);
44
45 /*
46  * exp.c
47  */
48 void ExpPrintError(Exp *exp, int type);
49 int64_t resolveGetConstExpInt64(Exp *exp);
50 float128_t resolveGetConstExpFloat128(Exp *exp);
51
52 /*
53  * lex.c
54  */
55 Lex *LexOpen(const char *path, token_t *tok);
56 void LexClose(Lex **plex);
57 int LexRedactToken(token_t *tok, int bytes);
58 int LexPeekToken(token_t *tok);
59 int LexToken(token_t *tok);
60 int LexSkipToken(token_t *tok, int type);
61 int LexStripQuotes(token_t *tok, token_t *tmp);
62 int LexError(token_t *tok, int err);
63 void LexPrintError(token_t *tok);
64 void LexPrintRef(LexRef *lr, int type);
65 void LexInitRef(LexRef *lr, token_t *tok);
66 void LexDupRef(LexRef *s, LexRef *d);
67 void LexDoneRef(LexRef *lr);
68 const char *LexErrStr(token_t *tok);
69
70 /*
71  * misc.c
72  */
73 void LibRuneInit(void);
74
75 /*
76  * heap.c
77  */
78 void *heapAlloc(PointerStor *ps, Type *type);
79
80 /*
81  * parse.c
82  */
83 int ParseOpen(Stmt *st, Parse **pp, void **dll);
84 void ParseDone(Parse *p);
85 void ParseClose(Parse **pp);
86 void AddImportPath(const char *path, int flags);
87 void PrefixImportPaths(const char *basePath);
88
89 /*
90  * parse1.c
91  */
92 int ParseModule(Parse *p, Stmt *st, int t);
93 int ParseStmt(Parse *p, int t, Stmt **pst);
94 int ParseDeclarationStmt(Parse *p, int t, int idRequired, Stmt **pst,
95                         int dop, Scope *scope);
96
97 /*
98  * parse2.c
99  */
100 int ParseScopeQual(Parse *p, int t, Scope *scope);
101 int ParseStorageQual(Parse *p, int t, int *pmask);
102 int ParseDeclaration(Parse *p, int t, Declaration **pd, int idRequired,
103                         int dop, Scope *scope);
104 int ParseType(Parse *p, int t, Type **ptype, int sqflags);
105 int ParseDeclType(Parse *p, int t, Type **ptype, SemGroup **psg,
106                         int scopeFlags, int rqflags, string_t *id,
107                         int idRequired, int isLocked);
108
109 /*
110  * parse3.c
111  */
112 int ParseExp(Parse *p, int t, Exp **pexp);
113 int ParseParenthesizedExp(Parse *p, int t, Exp **pexp, int docomp);
114 int ParseNotExp(Parse *p, int t, Exp **pexp);
115
116 /*
117  * resolve.c
118  */
119 void ResolveProject(Parse *p, Stmt *st);
120 void CollapseProject(Stmt *st);
121
122 /*
123  * stmt.c
124  */
125 Stmt *BuildRootImportStmt(const char *path);
126 void StmtPrintError(Stmt *st, int type);
127
128 /*
129  * strtable.c
130  */
131 string_t StrTableEscapeQuotedString(const char *str, int len, int term);
132 string_t StrTableAlloc(const char *str, int len, int special);
133 string_t StrTableToken(token_t *tok);
134 string_t StrTableInt(int v);
135 string_t StrTableDup(string_t str);
136 int     StrTableSpecial(string_t id);
137 int     StrTableLen(string_t id);
138 int     StrCmpToken(string_t id, token_t *tok);
139 void ReplaceStrTable(string_t *pstr, string_t id);
140 void RelStrTable(string_t *pstr);
141 const char *StripPathId(const char *path, int *len);
142 int SimpleIntToken(token_t *tok, int *rv);
143 int SimpleRunesizeToken(token_t *tok, runesize_t *rv);
144 int StrTableEnumerate(string_t id);
145
146 /*
147  * sym.c
148  */
149 int SymKeywordFind(const char *ptr, int len, int t);
150
151 /*
152  * type.c
153  */
154 char *TypeToStr(Type *type, char **pstr);
155 int SameType(Type *t1, Type *t2, int sqFlags2);
156 int SimilarType(Type *t1, Type *t2);
157 int SimilarSemGroup(SemGroup *s1, SemGroup *s2);
158 int MatchType(Type *super, Type *type);
159 void InternalRegisterType(const char *str, const char *linkname, Type *type);
160 Type *InternalRegisteredTypeLookup(string_t id);
161 void initType(Type *type, typelist_t *list, int op);
162 void initQualType(Type *type, typelist_t *list, int op, int sqflags);
163 void initPtrType(Type *type, Type *ptrto, int sqflags);
164 void initCPtrType(Type *type, Type *ptrto, int sqflags);
165 SemGroup *BaseType(Type **ptype);
166
167 /*
168  * High-level Interpreter and Generator
169  */
170 runctx_p RunUnresolvedStmt(runctx_p ct, Stmt *st);
171 genctx_p GenUnresolvedStmt(genctx_p ct, Stmt *st);
172
173 void RunUnresolvedExp(runctx_p ct, rundata_t *data, Exp *exp);
174 int64_t Run64DefaultExp(runctx_p ct, Exp *exp);
175 gendata_t *GenUnresolvedExp(genctx_p ct, Exp *exp);
176
177 extern typelist_t DynamicTypeList;
178 extern typelist_t CompoundTypeList;
179 extern typelist_t ArgsTypeList;
180 extern typelist_t StorageTypeList;
181
182 extern void **DefaultDynamicVector;
183
184 extern Type DynamicRValueType;
185 extern Type DynamicLValueType;
186 extern Type NumericType;
187 extern Type IntegralType;
188 extern Type SIntegerType;
189 extern Type UIntegerType;
190 extern Type VoidType;
191 extern Type BoolType;
192 extern Type Int8Type;
193 extern Type UInt8Type;
194 extern Type Int16Type;
195 extern Type UInt16Type;
196 extern Type Int32Type;
197 extern Type UInt32Type;
198 extern Type Int64Type;
199 extern Type UInt64Type;
200 extern Type Int128Type;
201 extern Type UInt128Type;
202
203 extern Type FloatType;
204 extern Type Float32Type;
205 extern Type Float64Type;
206 extern Type Float128Type;
207
208 extern Type CCharType;
209 extern Type StrType;            /* NOTE: const char *, chars are unsigned */
210 extern Type CharPtrType;
211 extern Type CharPtrPtrType;
212 extern Type VoidPtrType;
213 extern Type VoidRefType;
214 extern Type CVoidPtrType;
215 extern Type LVoidPtrType;
216 extern Type PointerType;        /* generic pointer placeholder */
217 extern Type PointerInfoType;
218
219 extern Type LexRefType;         /* run-time access class tie-ins */
220 extern Type ScopeType;
221 extern Type DeclarationType;
222 extern Type SemGroupType;
223 extern Type TypeType;
224 extern Type FILLERTypeType;
225 extern Type FILLERDeclType;
226
227 extern Type IntPtrType;
228 extern Type UIntPtrType;
229 extern Type OffType;
230 extern Type SizeType;
231
232 extern Type *BaseTypeAry[];
233 extern typereglist_t TypeRegList;
234