Rune - Localize interpreter code
[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 typedef struct Context *runctx_p;
9 typedef struct SaveObjCtx *saveobj_p;
10
11 #include "lex.h"
12 #include "sym.h"
13 #include "strtable.h"
14 #include "type.h"
15 #include "context.h"
16 #include "decl.h"
17 #include "exp.h"
18 #include "stmt.h"
19 #include "parse.h"
20
21 /*
22  * debug_lex.c
23  */
24 void LexDebugLine(token_t *tok);
25
26 /*
27  * decl.c
28  */
29 Declaration *FindDeclId(SemGroup *db, string_t id, int *eno);
30 Declaration *FindDeclIdLevel(SemGroup *db, string_t id, int level, int *eno);
31 Declaration *FindDeclByIndex(SemGroup *sg, int index);
32 void DeclPrintError(Declaration *d, int type);
33 Declaration *FindDeclPath(LexRef *lexRef, SemGroup *osg, SemGroup *sg,
34                         Type *nomatch, string_t *ary, int mask,
35                         int *visibility, int level, int *eno);
36 void *FindDLLSymbol(SemGroup *osg, SemGroup *sg, string_t id);
37
38 /*
39  * exp.c
40  */
41 void ExpPrintError(Exp *exp, int type);
42
43 /*
44  * lex.c
45  */
46 Lex *LexOpen(const char *path, token_t *tok);
47 void LexClose(Lex **plex);
48 int LexRedactToken(token_t *tok, int bytes);
49 int LexPeekToken(token_t *tok);
50 int LexToken(token_t *tok);
51 int LexSkipToken(token_t *tok, int type);
52 int LexStripQuotes(token_t *tok, token_t *tmp);
53 int LexError(token_t *tok, int err);
54 void LexPrintError(token_t *tok);
55 void LexPrintRef(LexRef *lr, int type);
56 void LexInitRef(LexRef *lr, token_t *tok);
57 void LexDupRef(LexRef *s, LexRef *d);
58 void LexDoneRef(LexRef *lr);
59 const char *LexErrStr(token_t *tok);
60
61 /*
62  * misc.c
63  */
64 void LibRuneInit(void);
65
66 /*
67  * parse.c
68  */
69 int ParseOpen(Stmt *st, Parse **pp, void **dll);
70 void ParseDone(Parse *p);
71 void ParseClose(Parse **pp);
72 void AddImportPath(const char *path, int flags);
73 void PrefixImportPaths(const char *basePath);
74
75 /*
76  * parse1.c
77  */
78 int ParseModule(Parse *p, Stmt *st, int t);
79 int ParseStmt(Parse *p, int t, Stmt **pst);
80 int ParseDeclarationStmt(Parse *p, int t, int idRequired, Stmt **pst,
81                         int dop, Scope *scope);
82
83 /*
84  * parse2.c
85  */
86 int ParseScopeQual(Parse *p, int t, Scope *scope);
87 int ParseStorageQual(Parse *p, int t, int *pmask);
88 int ParseDeclaration(Parse *p, int t, Declaration **pd, int idRequired,
89                         int dop, Scope *scope);
90 int ParseDeclarationList(Parse *p, int t, int scopeFlags,
91                         int idRequired, int dop);
92 int ParseType(Parse *p, int t, Type **ptype, int sqflags);
93 int ParseDeclType(Parse *p, int t, Type **ptype, SemGroup **psg,
94                         int scopeFlags, int rqflags, string_t *id,
95                         int idRequired);
96
97 /*
98  * parse3.c
99  */
100 int ParseExp(Parse *p, int t, Exp **pexp);
101 int ParseParenthesizedExp(Parse *p, int t, Exp **pexp, int docomp);
102 int ParseNotExp(Parse *p, int t, Exp **pexp);
103
104 /*
105  * resolve.c
106  */
107 void ResolveProject(Parse *p, Stmt *st);
108 Type *resolveType(Type *type);
109
110 /*
111  * stmt.c
112  */
113 Stmt *BuildRootImportStmt(const char *path);
114 void StmtPrintError(Stmt *st, int type);
115
116 /*
117  * strtable.c
118  */
119 string_t StrTableEscapeQuotedString(const char *str, int len, int term);
120 string_t StrTableAlloc(const char *str, int len, int special);
121 string_t StrTableToken(token_t *tok);
122 string_t StrTableInt(int v);
123 string_t StrTableDup(string_t str);
124 int     StrTableSpecial(string_t id);
125 int     StrTableLen(string_t id);
126 int     StrCmpToken(string_t id, token_t *tok);
127 void ReplaceStrTable(string_t *pstr, string_t id);
128 void RelStrTable(string_t *pstr);
129 const char *StripPathId(const char *path, int *len);
130 int SimpleIntToken(token_t *tok, int *rv);
131 int SimpleRunesizeToken(token_t *tok, runesize_t *rv);
132
133 /*
134  * sym.c
135  */
136 int SymKeywordFind(const char *ptr, int len, int t);
137
138 /*
139  * type.c
140  */
141 char *TypeToStr(Type *type, char **pstr);
142 int SameType(Type *t1, Type *t2, int sqFlags2);
143 int SimilarType(Type *t1, Type *t2);
144 int SimilarSemGroup(SemGroup *s1, SemGroup *s2);
145 int MatchType(Type *super, Type *type);
146 void InternalRegisterType(const char *str, Type *type);
147 Type *InternalRegisteredTypeLookup(string_t id);
148 void initType(Type *type, List *list, int op);
149 void initQualType(Type *type, List *list, int op, int sqflags);
150 void initPtrType(Type *type, Type *ptrto, int sqflags);
151
152 extern st_func_t StmtFuncVector;
153 extern ex_func_t ExpFuncVector;
154
155 extern Type DynamicRValueType;
156 extern Type DynamicLValueType;
157 extern Type NumericType;
158 extern Type IntegerType;
159 extern Type VoidType;
160 extern Type BoolType;
161 extern Type Int8Type;
162 extern Type UInt8Type;
163 extern Type Int16Type;
164 extern Type UInt16Type;
165 extern Type Int32Type;
166 extern Type UInt32Type;
167 extern Type Int64Type;
168 extern Type UInt64Type;
169 extern Type Float32Type;
170 extern Type Float64Type;
171 extern Type Float128Type;
172 extern Type CCharType;
173 extern Type StrType;
174 extern Type CharPtrType;
175 extern Type CharPtrPtrType;
176 extern Type VoidPtrType;
177 extern Type VoidRefType;
178 extern Type CVoidPtrType;
179 extern Type LVoidPtrType;
180 extern Type PointerType;        /* generic pointer placeholder */
181 extern Type IntPtrType;         /* not int * ... intptr_t */
182 extern Type UIntPtrType;        /* not int * ... intptr_t */