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