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