rsc | 564ca70 | 2004-04-19 19:32:07 +0000 | [diff] [blame] | 1 | /* acid.h */ |
| 2 | enum |
| 3 | { |
| 4 | Eof = -1, |
| 5 | Strsize = 4096, |
| 6 | Hashsize = 128, |
| 7 | Maxarg = 512, |
| 8 | NFD = 100, |
| 9 | Maxproc = 50, |
| 10 | Maxval = 10, |
| 11 | Mempergc = 1024*1024, |
| 12 | }; |
| 13 | |
| 14 | /* #pragma varargck type "L" void */ |
| 15 | |
| 16 | typedef struct Node Node; |
| 17 | typedef struct String String; |
| 18 | typedef struct Lsym Lsym; |
| 19 | typedef struct List List; |
| 20 | typedef struct Store Store; |
| 21 | typedef struct Gc Gc; |
| 22 | typedef struct Strc Strc; |
| 23 | typedef struct Rplace Rplace; |
| 24 | typedef struct Ptab Ptab; |
| 25 | typedef struct Value Value; |
| 26 | typedef struct Type Type; |
| 27 | typedef struct Frtype Frtype; |
| 28 | |
| 29 | Extern int kernel; |
| 30 | Extern int nlcount; |
| 31 | Extern int remote; |
| 32 | Extern int text; |
| 33 | Extern int cor; |
| 34 | Extern int silent; |
| 35 | Extern Fhdr *fhdr; |
| 36 | Extern Fhdr *chdr; |
| 37 | Extern int line; |
| 38 | Extern Biobuf* bout; |
| 39 | Extern Biobuf* io[32]; |
| 40 | Extern int iop; |
| 41 | Extern int pid; |
| 42 | Extern char symbol[Strsize]; |
| 43 | Extern int interactive; |
| 44 | Extern Node* code; |
| 45 | Extern int na; |
| 46 | Extern int wtflag; |
| 47 | Extern Regs* correg; |
| 48 | Extern Map* cormap; |
| 49 | Extern Map* symmap; |
| 50 | Extern Lsym* hash[Hashsize]; |
| 51 | Extern long dogc; |
| 52 | Extern Rplace* ret; |
| 53 | Extern char* symfil; |
| 54 | Extern char* corfil; |
| 55 | Extern int gotint; |
| 56 | Extern long flen; |
| 57 | Extern Gc* gcl; |
| 58 | Extern int stacked; |
rsc | 13e6607 | 2004-04-20 00:20:36 +0000 | [diff] [blame] | 59 | #define err aciderrjmp |
rsc | 564ca70 | 2004-04-19 19:32:07 +0000 | [diff] [blame] | 60 | Extern jmp_buf err; |
| 61 | Extern Node* prnt; |
| 62 | Extern Node* fomt; |
| 63 | Extern List* tracelist; |
| 64 | Extern int initialising; |
| 65 | Extern int quiet; |
| 66 | Extern Fhdr* corhdr; |
| 67 | Extern Fhdr* symhdr; |
| 68 | |
| 69 | extern void (*expop[])(Node*, Node*); |
| 70 | #define expr(n, r) (r)->store.comt=0; (*expop[(unsigned char)((n)->op)])(n, r); |
| 71 | |
| 72 | enum |
| 73 | { |
| 74 | TINT, |
| 75 | TFLOAT, |
| 76 | TSTRING, |
| 77 | TLIST, |
| 78 | TCODE, |
rsc | e637c94 | 2004-04-20 01:42:20 +0000 | [diff] [blame] | 79 | NUMT, |
rsc | 564ca70 | 2004-04-19 19:32:07 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | struct Type |
| 83 | { |
| 84 | Type* next; |
| 85 | int offset; |
| 86 | char fmt; |
| 87 | char depth; |
| 88 | Lsym* type; |
| 89 | Lsym* tag; |
| 90 | Lsym* base; |
| 91 | }; |
| 92 | |
| 93 | struct Frtype |
| 94 | { |
| 95 | Lsym* var; |
| 96 | Type* type; |
| 97 | Frtype* next; |
| 98 | }; |
| 99 | |
| 100 | struct Ptab |
| 101 | { |
| 102 | int pid; |
| 103 | /* int ctl; */ |
| 104 | }; |
| 105 | Extern Ptab ptab[Maxproc]; |
| 106 | |
| 107 | struct Rplace |
| 108 | { |
| 109 | jmp_buf rlab; |
| 110 | Node* stak; |
| 111 | Node* val; |
| 112 | Lsym* local; |
| 113 | Lsym** tail; |
| 114 | }; |
| 115 | |
| 116 | struct Gc |
| 117 | { |
| 118 | char gcmark; |
| 119 | Gc* gclink; |
| 120 | }; |
| 121 | |
| 122 | struct Store |
| 123 | { |
| 124 | char fmt; |
| 125 | Type* comt; |
| 126 | union { |
| 127 | vlong ival; |
| 128 | double fval; |
| 129 | String* string; |
| 130 | List* l; |
| 131 | Node* cc; |
| 132 | } u; |
| 133 | }; |
| 134 | |
| 135 | struct List |
| 136 | { |
| 137 | Gc gc; |
| 138 | List* next; |
| 139 | char type; |
| 140 | Store store; |
| 141 | }; |
| 142 | |
| 143 | struct Value |
| 144 | { |
| 145 | char set; |
| 146 | char type; |
| 147 | Store store; |
| 148 | Value* pop; |
| 149 | Lsym* scope; |
| 150 | Rplace* ret; |
| 151 | }; |
| 152 | |
| 153 | struct Lsym |
| 154 | { |
| 155 | char* name; |
| 156 | int lexval; |
| 157 | Lsym* hash; |
| 158 | Value* v; |
| 159 | Type* lt; |
| 160 | Node* proc; |
| 161 | Frtype* local; |
| 162 | void (*builtin)(Node*, Node*); |
| 163 | }; |
| 164 | |
| 165 | struct Node |
| 166 | { |
| 167 | Gc gc; |
| 168 | char op; |
| 169 | char type; |
| 170 | Node* left; |
| 171 | Node* right; |
| 172 | Lsym* sym; |
| 173 | int builtin; |
| 174 | Store store; |
| 175 | }; |
| 176 | #define ZN (Node*)0 |
| 177 | |
| 178 | struct String |
| 179 | { |
| 180 | Gc gc; |
| 181 | char *string; |
| 182 | int len; |
| 183 | }; |
| 184 | |
| 185 | List* addlist(List*, List*); |
| 186 | void addvarsym(Fhdr*); |
| 187 | List* al(int); |
| 188 | Node* an(int, Node*, Node*); |
| 189 | void append(Node*, Node*, Node*); |
| 190 | int bool(Node*); |
| 191 | void build(Node*); |
| 192 | void call(char*, Node*, Node*, Node*, Node*); |
| 193 | void catcher(void*, char*); |
| 194 | void checkqid(int, int); |
| 195 | void cmd(void); |
| 196 | Node* con(int); |
| 197 | List* construct(Node*); |
| 198 | void ctrace(int); |
| 199 | void decl(Node*); |
| 200 | void defcomplex(Node*, Node*); |
| 201 | void deinstall(int); |
| 202 | void delete(List*, int n, Node*); |
| 203 | void delvarsym(char*); |
| 204 | void dostop(int); |
| 205 | Lsym* enter(char*, int); |
| 206 | void error(char*, ...); |
| 207 | void execute(Node*); |
| 208 | void fatal(char*, ...); |
| 209 | ulong findframe(ulong); |
| 210 | void flatten(Node**, Node*); |
| 211 | void gc(void); |
| 212 | char* getstatus(int); |
| 213 | void* gmalloc(long); |
| 214 | void indir(Map*, ulong, char, Node*); |
rsc | e637c94 | 2004-04-20 01:42:20 +0000 | [diff] [blame] | 215 | void initexpr(void); |
| 216 | void initprint(void); |
rsc | 564ca70 | 2004-04-19 19:32:07 +0000 | [diff] [blame] | 217 | void installbuiltin(void); |
| 218 | void kinit(void); |
| 219 | int Zfmt(Fmt*); |
| 220 | int listcmp(List*, List*); |
| 221 | int listlen(List*); |
| 222 | List* listvar(char*, long); |
| 223 | void loadmodule(char*); |
| 224 | void loadvars(void); |
| 225 | Lsym* look(char*); |
| 226 | void ltag(char*); |
| 227 | void marklist(List*); |
| 228 | Lsym* mkvar(char*); |
| 229 | void msg(int, char*); |
| 230 | void notes(int); |
| 231 | int nproc(char**); |
| 232 | void nthelem(List*, int, Node*); |
| 233 | int numsym(char); |
| 234 | void odot(Node*, Node*); |
| 235 | void pcode(Node*, int); |
| 236 | void pexpr(Node*); |
| 237 | int popio(void); |
| 238 | void pstr(String*); |
| 239 | void pushfd(int); |
| 240 | void pushfile(char*); |
| 241 | void pushstr(Node*); |
| 242 | ulong raddr(char*); |
| 243 | void readtext(char*); |
| 244 | void readcore(void); |
| 245 | void restartio(void); |
| 246 | String *runenode(Rune*); |
| 247 | int scmp(String*, String*); |
| 248 | void sproc(int); |
| 249 | String* stradd(String*, String*); |
| 250 | String* strnode(char*); |
| 251 | String* strnodlen(char*, int); |
| 252 | #define system acidsystem |
| 253 | char* system(void); |
| 254 | int trlist(Map*, Regs*, ulong, ulong, Symbol*, int); |
| 255 | void unwind(void); |
| 256 | void userinit(void); |
| 257 | void varreg(void); |
| 258 | void varsym(void); |
| 259 | Waitmsg* waitfor(int); |
| 260 | void whatis(Lsym*); |
| 261 | void windir(Map*, Node*, Node*, Node*); |
| 262 | void yyerror(char*, ...); |
| 263 | int yylex(void); |
| 264 | int yyparse(void); |
| 265 | |
| 266 | enum |
| 267 | { |
| 268 | ONAME, |
| 269 | OCONST, |
| 270 | OMUL, |
| 271 | ODIV, |
| 272 | OMOD, |
| 273 | OADD, |
| 274 | OSUB, |
| 275 | ORSH, |
| 276 | OLSH, |
| 277 | OLT, |
| 278 | OGT, |
| 279 | OLEQ, |
| 280 | OGEQ, |
| 281 | OEQ, |
| 282 | ONEQ, |
| 283 | OLAND, |
| 284 | OXOR, |
| 285 | OLOR, |
| 286 | OCAND, |
| 287 | OCOR, |
| 288 | OASGN, |
| 289 | OINDM, |
| 290 | OEDEC, |
| 291 | OEINC, |
| 292 | OPINC, |
| 293 | OPDEC, |
| 294 | ONOT, |
| 295 | OIF, |
| 296 | ODO, |
| 297 | OLIST, |
| 298 | OCALL, |
| 299 | OCTRUCT, |
| 300 | OWHILE, |
| 301 | OELSE, |
| 302 | OHEAD, |
| 303 | OTAIL, |
| 304 | OAPPEND, |
| 305 | ORET, |
| 306 | OINDEX, |
| 307 | OINDC, |
| 308 | ODOT, |
| 309 | OLOCAL, |
| 310 | OFRAME, |
| 311 | OCOMPLEX, |
| 312 | ODELETE, |
| 313 | OCAST, |
| 314 | OFMT, |
| 315 | OEVAL, |
| 316 | OWHAT, |
rsc | e637c94 | 2004-04-20 01:42:20 +0000 | [diff] [blame] | 317 | NUMO, |
rsc | 564ca70 | 2004-04-19 19:32:07 +0000 | [diff] [blame] | 318 | }; |