00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef SYMBOLDEF_H
00037 #define SYMBOLDEF_H
00038
00039 #include "ptree.h"
00040 #include "symbol.h"
00041 #include "util.h"
00042
00043
00044 #define GLOBALSYM 1 // defines global scope
00045 #define CLASSSYM 2 // defines class scope
00046 #define PARAMETER 3 // defines parameter scope
00047 #define LOCALSYM 4 // defines local scope
00048 #define INVISIBLESYM 12 // defines scope in imported specclass
00049
00050
00051 #define TBASIC 5
00052 #define TARRAY 6
00053 #define TPOINTER 7
00054 #define TENUM 8
00055 #define TSTRUCT 9
00056 #define TTYPE 10
00057 #define TCLASS 11
00058
00059
00060
00061
00062 typedef struct specx {
00063 symboltable *use_files;
00064 symboltable *types;
00065 symboltable *variables;
00066 symboltable *functions;
00067 symboltable *classes;
00068 } specx;
00069
00070
00071 typedef struct typex {
00072 char *name;
00073 char *basetype;
00074 char *realtype;
00075 int type;
00076 symboltable *fields;
00077 parsex *range;
00078 int scope;
00079 int flags;
00080 char *typesize;
00081 linex *lf;
00082 } typex;
00083
00084
00085
00086 typedef struct varx {
00087 char *name;
00088 char *type;
00089 char *realtype;
00090 parsex *init;
00091 int scope;
00092 int flags;
00093 char *offset;
00094 linex *lf;
00095 } varx;
00096
00097
00098 typedef struct mfpx {
00099 char *name;
00100 char *replytype;
00101 char *realreply;
00102 char *returntype;
00103 char *realreturn;
00104 symboltable *parameters;
00105 symboltable *locals;
00106 parsex *code;
00107 int scope;
00108 int flags;
00109 int is_double;
00110 char *paramsize;
00111 char *localsize;
00112 int method_label;
00113 linex *lf;
00114 int istriv;
00115 } mfpx;
00116
00117
00118 typedef struct classx {
00119 char *name;
00120 symboltable *types;
00121 symboltable *variables;
00122 int verydirty;
00123 symboltable *func_meths;
00124 symboltable *subtypeof;
00125 int scope;
00126 int state_statistics;
00127 parsex *code;
00128 linex *lf;
00129 symboltable *localvar;
00130 char *varsize;
00131 char *cvarsize;
00132 } classx;
00133
00134
00135 typedef struct modulex {
00136 char *name;
00137 specx *specs;
00138 symboltable *types;
00139 symboltable *variables;
00140 symboltable *functions;
00141 symboltable *classes;
00142 bool label_init;
00143 } modulex;
00144
00145
00146 typedef struct namex {
00147 char *name;
00148 bool to_compile;
00149 } namex;
00150
00151
00152 typedef struct filex {
00153 char *name;
00154 parsex *spec, *impl;
00155 } filex;
00156
00157
00158 typedef struct subtype_rel {
00159 char *type;
00160 char *subtype;
00161 bool init;
00162 } subtype_rel;
00163
00164 void initmodule(void);
00165 void init_moduletable(void);
00166 void addsubtype(symboltable *t, char *name);
00167 void addtype(symboltable *t, char *name, int type, char *basetype,
00168 symboltable *fields, int scope, linex *lf);
00169 void addvariable(symboltable *t, char *name, char *type, int scope,
00170 parsex *init, linex *lf);
00171 void addfunction(symboltable *t, char *name, char *rettype, char *reptype,
00172 symboltable *params, symboltable *locals, parsex *code,
00173 bool ismethod, int scope, linex *lf);
00174 void addclass(symboltable *t, char *name, parsex *code, symboltable *types,
00175 symboltable *variables, symboltable *func_meths,
00176 symboltable *subtypeof, int scope, linex *lf,
00177 symboltable *localvars);
00178 void addmodule(symboltable *t, char *name, specx *specs, symboltable *types,
00179 symboltable *variables, symboltable *functions,
00180 symboltable *classes);
00181
00182 #endif // SYMBOLDEF_H