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