Rune - Further Object abstraction 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 /*
9  * Headers needed to build this library
10  */
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <sys/file.h>
14 #include <sys/mman.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <stdarg.h>
18 #include <stddef.h>
19 #include <string.h>
20 #include <unistd.h>
21 #include <dirent.h>
22 #include <assert.h>
23 #include <setjmp.h>
24 #include <signal.h>
25
26 #include "export.h"
27
28 /*
29  * librune has no link dependencies on libgen or libruntime
30  */
31 #define LIBGEN_NOPROTOS
32 #define LIBRUNTIME_NOPROTOS
33
34 #include <libruntime/export.h>
35 #include <libgen/export.h>
36
37 /*
38  * decl.c
39  */
40 void    InitDecls(void);
41 Declaration *AllocDeclaration(SemGroup *sg, int dop, Scope *scope);
42 Declaration *AllocImportDecl(Stmt *st, Scope *scope);
43 Declaration *AllocClassDecl(Stmt *st, runeid_t id, Type *super, Scope *scope);
44 void    FreeDeclaration(Parse *p, Declaration *d);
45 void    AllocImportSemGroup(Parse *p, Stmt *st);
46 SemGroup *AllocSemGroup(sg_type_t type, Parse *p, SemGroup *par, Stmt *st);
47 void    FreeSemGroup(SemGroup *sg);
48 SemGroup *DupSemGroup(SemGroup *sg, Stmt *st, SemGroup *ssg, int dupDecls);
49 int     HashDecl(Declaration *d, runeid_t id);
50 runeid_t UnHashDecl(Declaration *d);
51 void    HashOper(Declaration *d, runeid_t id);
52 runeid_t UnHashOper(Declaration *d);
53 void    RenameDecl(Declaration *d, SemGroup *nsg);
54 int     MatchDeclTypes(Declaration *sd, Declaration *rd);
55 int     MatchOperatorTypes(Declaration *d, Type *ltype, Type *rtype);
56 int     MatchCastTypes(Declaration *d, Type *ltype, Type *rtype);
57 Declaration *FindOperId(SemGroup *sg, runeid_t id, int args);
58 void    RefineDeclaration(SemGroup *sg, Declaration *sd, Declaration *rd);
59 Declaration *DupDeclaration(SemGroup *sg, Declaration *sd);
60 void    AdjustProcArgsNestingLevel(Declaration *d, SemGroup *fromSg);
61 void    AdjustNestSize(SemGroup *sg, int size);
62
63 /*
64  * exp.c
65  */
66 Exp     *_AllocExpDebug(token_t *tok, const char *file, int line);
67 Exp     *_AllocExp(token_t *tok);
68 void    FreeExp(Exp *exp);
69 Exp     *WrapExp(token_t *tok, Exp *oexp, int t);
70 Exp     *ExpToNotExp(Exp *oexp);
71 Exp     *ExpToCastExp(Exp *oexp, Type *type);
72 Exp     *ExpToCompoundExp(Exp *oexp, int t);
73 Exp     *ExpToBracketedExp(Exp *oexp, int t);
74 Exp     *ExpToAssExp(Exp *oexp, Declaration *d);
75 Exp     *SetDupExp(SemGroup *sg, Exp *exp);
76 Exp     *DupExp(SemGroup *sg, Exp *exp);
77
78 /*
79  * lex.c
80  */
81 void    lexUpdateCache(Lex *lex, int boff);
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, runeid_t **pary, int *pcount, int *ltp);
98 runeid_t *DupDotIdAry(runeid_t *ary);
99 void    FreeDotIdAry(runeid_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(urunesize_t bytes);
119 Type    *AllocUnresolvedType(SemGroup *isg, SemGroup *sg,
120                         runeid_t *ary, int eatAry);
121 Type    *AllocClassType(typelist_t *list, Type *super, SemGroup *sg,
122                         int sqflags, int visibility);
123 Type    *AllocImportType(typelist_t *list, SemGroup *sg, int visibility);
124 Type    *TypeToVisibilityType(Type *otype, int visibility);
125 Type    *TypeToProcType(Type *otype, Type *atype, int adjret);
126 Type    *TypeToRawPtrType(Type *otype);
127 Type    *TypeToRefType(Type *otype);
128 /*Type* TypeToQualType(Type *otype, Type *ntype, Exp *exp, int sf, int vis);*/
129 Type    *TypeAdjustQList(Type *type, Type *adjtype);
130 Type    *TypeFixupInheritedFlags(Type *type, int rqflags);
131 Type    *TypeToAryType(Type *otype, Exp *exp, SemGroup *sg);
132 Type    *TypeToVarType(Type *otype, SemGroup *sg);
133 Type    *ChangeType(Type *otype, int op);
134 Type    *DupType(SemGroup *sg, Type *stype);