Rune - Generation work
[rune.git] / librune / defs.h
1 /*
2  * DEFS.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 <sys/types.h>
9 #include <sys/stat.h>
10 #include <sys/file.h>
11 #include <sys/mman.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <stdarg.h>
15 #include <stddef.h>
16 #include <string.h>
17 #include <unistd.h>
18 #include <dirent.h>
19 #include <assert.h>
20 #include <setjmp.h>
21
22 #include <libsupport/export.h>
23 #include <libdthread/export.h>
24 #include "export.h"
25
26 /*
27  * decl.c
28  */
29 void InitDecls(void);
30 Declaration *AllocDeclaration(SemGroup *sg, int dop, Scope *scope);
31 Declaration *AllocImportDecl(Stmt *st, Scope *scope);
32 Declaration *AllocClassDecl(Stmt *st, string_t id, Type *super, Scope *scope);
33 void FreeDeclaration(Parse *p, Declaration *d);
34 void AllocImportSemGroup(Parse *p, Stmt *st);
35 SemGroup *AllocSemGroup(sg_type_t type, Parse *p, SemGroup *par, Stmt *st);
36 void FreeSemGroup(SemGroup *sg);
37 SemGroup *DupSemGroup(SemGroup *sg, Stmt *st, SemGroup *ssg, int dupDecls);
38 int HashDecl(Declaration *d, string_t id);
39 string_t UnHashDecl(Declaration *d);
40 void HashOper(Declaration *d, string_t id);
41 string_t UnHashOper(Declaration *d);
42 void RenameDecl(Declaration *d, SemGroup *nsg);
43 int MatchDeclTypes(Declaration *sd, Declaration *rd);
44 int MatchOperatorTypes(Declaration *d, Type *ltype, Type *rtype);
45 int MatchCastTypes(Declaration *d, Type *ltype, Type *rtype);
46 Declaration *FindOperId(SemGroup *sg, string_t id, int args);
47 void RefineDeclaration(SemGroup *sg, Declaration *sd, Declaration *rd);
48 Declaration *DupDeclaration(SemGroup *sg, Declaration *sd);
49 void AdjustProcArgsNestingLevel(Declaration *d, SemGroup *fromSg);
50 void AdjustNestSize(SemGroup *sg, int size);
51
52 /*
53  * exp.c
54  */
55 Exp *_AllocExpDebug(token_t *tok, const char *file, int line);
56 Exp *_AllocExp(token_t *tok);
57 void FreeExp(Exp *exp);
58 Exp *WrapExp(token_t *tok, Exp *oexp, int t);
59 Exp *ExpToNotExp(Exp *oexp);
60 Exp *ExpToCastExp(Exp *oexp, Type *type);
61 Exp *ExpToCompoundExp(Exp *oexp, int t);        /* XXX */
62 Exp *ExpToAssExp(Exp *oexp, Declaration *d);
63 Exp *SetDupExp(SemGroup *sg, Exp *exp);
64 Exp *DupExp(SemGroup *sg, Exp *exp);
65
66 /*
67  * lex.c
68  */
69 void lexUpdateCache(Lex *lex, int boff);
70
71 /*
72  * misc.c
73  */
74 extern string_t String_Self;
75 extern string_t String_This;
76 extern string_t String_Super;
77 extern string_t String_Pointer;
78 extern string_t String_SelfContained;
79 extern string_t String_Preempt;
80 extern string_t String_NoPreempt;
81 extern string_t String_Immediate;
82
83 /*
84  * parse.c
85  */
86 void SetSharedImport(struct stat *st, SemGroup *sg);
87 SemGroup *GetSharedImport(struct stat *st);
88
89 /*
90  * parse1.c
91  */
92 int ParseTypedefStmt(Parse *p, int t, Scope *scope);
93
94 /*
95  * parse2.c
96  */
97 int ParseDotIdAry(Parse *p, int t, string_t **pary, int *pcount, int *ltp);
98 string_t *DupDotIdAry(string_t *ary);
99 void FreeDotIdAry(string_t *ary);
100
101 /*
102  * stmt.c
103  */
104 Stmt *PushStmt(Parse *p, Stmt **pst, int type, int flags);
105 void *PopStmt(Parse *p, Stmt *st);
106 Stmt *DupStmt(SemGroup *sg, Stmt *par, Stmt *sst);
107 void FreeStmt(Stmt *st);
108
109 /*
110  * type.c
111  */
112 void TypeInit(void);
113 int InternalTypeAttach(Parse *p, int t, Declaration *d);
114 int InternalClassAttach(Parse *p, int t, Declaration *d);
115 Type *AllocType(typelist_t *list, int op);
116 Type *AllocCompoundType(SemGroup *sg);
117 Type *AllocArgsType(SemGroup *sg);
118 Type *AllocStorageType(runesize_t bytes);
119 Type *AllocUnresolvedType(SemGroup *isg, SemGroup *sg,
120                         string_t *ary, int eatAry);
121 Type *AllocClassType(typelist_t *list, Type *super, SemGroup *sg,
122                         int visibility);
123 Type *AllocImportType(typelist_t *list, SemGroup *sg, int visibility);
124 Type *TypeToProcType(Type *otype, Type *atype);
125 Type *TypeToPtrType(Type *otype);
126 Type *TypeToCPtrType(Type *otype);
127 Type *TypeToRefType(Type *otype);
128 /*Type *TypeToQualType(Type *otype, Type *ntype, int sqFlags, Exp *exp);*/
129 Type *TypeToAryType(Type *otype, Exp *exp, SemGroup *sg);
130 Type *TypeToVarType(Type *otype, SemGroup *sg);
131 Type *ChangeType(Type *otype, int op);
132 Type *DupType(SemGroup *sg, Type *stype);