Rune - Change ABI
[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 int DeclarationCacheable(Declaration *d);
45
46 /*
47  * exp.c
48  */
49 void ExpPrintError(Exp *exp, int type);
50 int64_t resolveGetConstExpInt64(Exp *exp);
51 float128_t resolveGetConstExpFloat128(Exp *exp);
52
53 /*
54  * lex.c
55  */
56 Lex *LexOpen(const char *path, token_t *tok);
57 void LexClose(Lex **plex);
58 int LexRedactToken(token_t *tok, int bytes);
59 int LexPeekToken(token_t *tok);
60 int LexToken(token_t *tok);
61 int LexSkipToken(token_t *tok, int type);
62 int LexStripQuotes(token_t *tok, token_t *tmp);
63 int LexError(token_t *tok, int err);
64 void LexPrintError(token_t *tok);
65 void LexPrintRef(LexRef *lr, int type);
66 void LexInitRef(LexRef *lr, token_t *tok);
67 void LexDupRef(LexRef *s, LexRef *d);
68 void LexDoneRef(LexRef *lr);
69 const char *LexErrStr(token_t *tok);
70
71 /*
72  * misc.c
73  */
74 void LibRuneInit(void);
75
76 /*
77  * heap.c
78  */
79 void *heapAlloc(PointerStor *ps, Type *type);
80
81 /*
82  * parse.c
83  */
84 int ParseOpen(Stmt *st, Parse **pp, void **dll);
85 void ParseDone(Parse *p);
86 void ParseClose(Parse **pp);
87 void AddImportPath(const char *path, int flags);
88 void PrefixImportPaths(const char *basePath);
89
90 /*
91  * parse1.c
92  */
93 int ParseModule(Parse *p, Stmt *st, int t);
94 int ParseStmt(Parse *p, int t, Stmt **pst);
95 int ParseDeclarationStmt(Parse *p, int t, int idRequired, Stmt **pst,
96                         int dop, Scope *scope);
97
98 /*
99  * parse2.c
100  */
101 int ParseScopeQual(Parse *p, int t, Scope *scope);
102 int ParseStorageQual(Parse *p, int t, int *pmask);
103 int ParseDeclaration(Parse *p, int t, Declaration **pd, int idRequired,
104                         int dop, Scope *scope);
105 int ParseType(Parse *p, int t, Type **ptype, int sqflags);
106 int ParseDeclType(Parse *p, int t, Type **ptype, SemGroup **psg,
107                         int scopeFlags, int rqflags, string_t *id,
108                         int idRequired, int isLocked);
109
110 /*
111  * parse3.c
112  */
113 int ParseExp(Parse *p, int t, Exp **pexp);
114 int ParseParenthesizedExp(Parse *p, int t, Exp **pexp, int docomp);
115 int ParseNotExp(Parse *p, int t, Exp **pexp);
116
117 /*
118  * resolve.c
119  */
120 void ResolveProject(Parse *p, Stmt *st);
121 void CollapseProject(Stmt *st);
122
123 /*
124  * stmt.c
125  */
126 Stmt *BuildRootImportStmt(const char *path);
127 void StmtPrintError(Stmt *st, int type);
128
129 /*
130  * strtable.c
131  */
132 string_t StrTableEscapeQuotedString(const char *str, int len, int term);
133 string_t StrTableAlloc(const char *str, int len, int special);
134 string_t StrTableToken(token_t *tok);
135 string_t StrTableInt(int v);
136 string_t StrTableDup(string_t str);
137 int     StrTableSpecial(string_t id);
138 int     StrTableLen(string_t id);
139 int     StrCmpToken(string_t id, token_t *tok);
140 void ReplaceStrTable(string_t *pstr, string_t id);
141 void RelStrTable(string_t *pstr);
142 const char *StripPathId(const char *path, int *len);
143 int SimpleIntToken(token_t *tok, int *rv);
144 int SimpleRunesizeToken(token_t *tok, runesize_t *rv);
145 int StrTableEnumerate(string_t id);
146
147 /*
148  * sym.c
149  */
150 int SymKeywordFind(const char *ptr, int len, int t);
151
152 /*
153  * type.c
154  */
155 char *TypeToStr(Type *type, char **pstr);
156 int SameType(Type *t1, Type *t2, int sqFlags2);
157 int SimilarType(Type *t1, Type *t2);
158 int SimilarSemGroup(SemGroup *s1, SemGroup *s2);
159 int MatchType(Type *super, Type *type);
160 void InternalRegisterType(const char *str, const char *linkname, Type *type);
161 Type *InternalRegisteredTypeLookup(string_t id);
162 void initType(Type *type, typelist_t *list, int op);
163 void initQualType(Type *type, typelist_t *list, int op, int sqflags);
164 void initPtrType(Type *type, Type *ptrto, int sqflags);
165 void initCPtrType(Type *type, Type *ptrto, int sqflags);
166 SemGroup *BaseType(Type **ptype);
167
168 GlobInfo *GetGlobInfo(const char *label,
169                         runesize_t beg_off, runesize_t end_off,
170                         SemGroup *rssg, Type *type);
171
172 /*
173  * High-level Interpreter and Generator
174  */
175 runctx_p RunUnresolvedStmt(runctx_p ct, Stmt *st);
176 genctx_p GenUnresolvedStmt(genctx_p ct, Stmt *st);
177
178 void RunUnresolvedExp(runctx_p ct, rundata_t *data, Exp *exp);
179 int64_t Run64DefaultExp(runctx_p ct, Exp *exp);
180 gendata_t *GenUnresolvedExp(genctx_p ct, Exp *exp);
181
182 extern int RuneInlineComplexity;
183
184 extern typelist_t DynamicTypeList;
185 extern typelist_t CompoundTypeList;
186 extern typelist_t ArgsTypeList;
187 extern typelist_t StorageTypeList;
188
189 extern void **DefaultDynamicVector;
190
191 extern Type DynamicRValueType;
192 extern Type DynamicLValueType;
193 extern Type NumericType;
194 extern Type IntegralType;
195 extern Type SIntegerType;
196 extern Type UIntegerType;
197 extern Type VoidType;
198 extern Type BoolType;
199 extern Type Int8Type;
200 extern Type UInt8Type;
201 extern Type Int16Type;
202 extern Type UInt16Type;
203 extern Type Int32Type;
204 extern Type UInt32Type;
205 extern Type Int64Type;
206 extern Type UInt64Type;
207 extern Type Int128Type;
208 extern Type UInt128Type;
209
210 extern Type FloatType;
211 extern Type Float32Type;
212 extern Type Float64Type;
213 extern Type Float128Type;
214
215 extern Type CCharType;
216 extern Type StrType;            /* NOTE: const char *, chars are unsigned */
217 extern Type CharPtrType;
218 extern Type CharPtrPtrType;
219 extern Type VoidPtrType;
220 extern Type VoidRefType;
221 extern Type CVoidPtrType;
222 extern Type LVoidPtrType;
223 extern Type PointerType;        /* generic pointer placeholder */
224 extern Type PointerInfoType;
225
226 extern Type LexRefType;         /* run-time access class tie-ins */
227 extern Type ScopeType;
228 extern Type DeclarationType;
229 extern Type SemGroupType;
230 extern Type TypeType;
231 extern Type FILLERTypeType;
232 extern Type FILLERDeclType;
233
234 extern Type IntPtrType;
235 extern Type UIntPtrType;
236 extern Type OffType;
237 extern Type SizeType;
238
239 extern Type *BaseTypeAry[];
240 extern typereglist_t TypeRegList;
241