Blob
- Date:
- Message:
- Working on better handling of multithreading in general and core dumps in particular. See notes: new types: register is something that when dereferenced gives you the registers. the Ureg is no longer mapped at 0. refconst is something that gives a constant when dereferenced. new builtin register("AX") creates register values new builtin refconst(0x123) creates refconst values new builtin var("foo") is equivalent to the variable foo (it returns foo but can also be used as the lhs of an assignment). new acid function getregs() returns a list of the current values of registers. new acid function setregs() sets the current registers to those values. note that getregs and setregs operate on register locations, not the register values themselves. new acid function resetregs() sets registers to register("AX"), etc. new acid function clearregs() sets all registers to constant -1. the default register settings are as in resetregs(), not small numbers. new acid variables coretext, pids, systype, corefile, cmdline. new behavior: local variable lookup, stk, etc., use the acid values of registers (*PC, *SP, and so on), so the thread support code can change the context completely. unary + is applicable to more data types and prints more often.
- Actions:
- History | Blame | Raw File
1 %{2 #include <u.h>3 #include <libc.h>4 #include <bio.h>5 #include <mach.h>6 #define Extern extern7 #include "acid.h"8 %}10 %union11 {12 Node *node;13 Lsym *sym;14 ulong ival;15 float fval;16 String *string;17 }19 %type <node> expr monexpr term stmnt name args zexpr slist20 %type <node> member members mname castexpr idlist21 %type <sym> zname23 %left ';'24 %right '='25 %left Tfmt26 %left Toror27 %left Tandand28 %left '|'29 %left '^'30 %left '&'31 %left Teq Tneq32 %left '<' '>' Tleq Tgeq33 %left Tlsh Trsh34 %left '+' '-'35 %left '*' '/' '%'36 %right Tdec Tinc Tindir '.' '[' '('38 %token <sym> Tid39 %token <ival> Tconst Tfmt40 %token <fval> Tfconst41 %token <string> Tstring42 %token Tif Tdo Tthen Telse Twhile Tloop Thead Ttail Tappend Tfn Tret Tlocal43 %token Tcomplex Twhat Tdelete Teval Tbuiltin45 %%47 prog :48 | prog bigstmnt49 ;51 bigstmnt : stmnt52 {53 /* hold on to current command for gc */54 mkvar("_thiscmd")->proc = $1;55 execute($1);56 gc();57 if(interactive && nlcount){58 Bprint(bout, "acid; ");59 nlcount = 0;60 }61 }62 | Tfn Tid '(' args ')' zsemi '{' slist '}'63 {64 $2->proc = an(OLIST, $4, $8);65 }66 | Tfn Tid67 {68 $2->proc = nil;69 }70 | Tcomplex name '{' members '}' ';'71 {72 defcomplex($2, $4);73 }74 ;76 zsemi :77 | ';' zsemi79 members : member80 | members member81 {82 $$ = an(OLIST, $1, $2);83 }84 ;86 mname : Tid87 {88 $$ = an(ONAME, ZN, ZN);89 $$->sym = $1;90 }91 ;93 member : Tconst Tconst mname ';'94 {95 $3->store.u.ival = $2;96 $3->store.fmt = $1;97 $$ = $3;98 }99 | Tconst mname Tconst mname ';'100 {101 $4->store.u.ival = $3;102 $4->store.fmt = $1;103 $4->right = $2;104 $$ = $4;105 }106 | mname Tconst mname ';'107 {108 $3->store.u.ival = $2;109 $3->left = $1;110 $$ = $3;111 }112 | '{' members '}' ';'113 {114 $$ = an(OCTRUCT, $2, ZN);115 }116 ;118 zname :119 { $$ = 0; }120 | Tid121 ;123 slist : stmnt124 | slist stmnt125 {126 $$ = an(OLIST, $1, $2);127 }128 ;130 stmnt : zexpr ';'131 | '{' slist '}'132 {133 $$ = $2;134 }135 | Tif expr Tthen stmnt136 {137 $$ = an(OIF, $2, $4);138 }139 | Tif expr Tthen stmnt Telse stmnt140 {141 $$ = an(OIF, $2, an(OELSE, $4, $6));142 }143 | Tloop expr ',' expr Tdo stmnt144 {145 $$ = an(ODO, an(OLIST, $2, $4), $6);146 }147 | Twhile expr Tdo stmnt148 {149 $$ = an(OWHILE, $2, $4);150 }151 | Tret expr ';'152 {153 $$ = an(ORET, $2, ZN);154 }155 | Tlocal idlist156 {157 $$ = an(OLOCAL, $2, ZN);158 }159 | Tcomplex Tid name ';'160 {161 $$ = an(OCOMPLEX, $3, ZN);162 $$->sym = $2;163 }164 ;166 idlist : Tid167 {168 $$ = an(ONAME, ZN, ZN);169 $$->sym = $1;170 }171 | idlist ',' Tid172 {173 $$ = an(ONAME, $1, ZN);174 $$->sym = $3;175 }176 ;178 zexpr :179 { $$ = 0; }180 | expr181 ;183 expr : castexpr184 | expr '*' expr185 {186 $$ = an(OMUL, $1, $3);187 }188 | expr '/' expr189 {190 $$ = an(ODIV, $1, $3);191 }192 | expr '%' expr193 {194 $$ = an(OMOD, $1, $3);195 }196 | expr '+' expr197 {198 $$ = an(OADD, $1, $3);199 }200 | expr '-' expr201 {202 $$ = an(OSUB, $1, $3);203 }204 | expr Trsh expr205 {206 $$ = an(ORSH, $1, $3);207 }208 | expr Tlsh expr209 {210 $$ = an(OLSH, $1, $3);211 }212 | expr '<' expr213 {214 $$ = an(OLT, $1, $3);215 }216 | expr '>' expr217 {218 $$ = an(OGT, $1, $3);219 }220 | expr Tleq expr221 {222 $$ = an(OLEQ, $1, $3);223 }224 | expr Tgeq expr225 {226 $$ = an(OGEQ, $1, $3);227 }228 | expr Teq expr229 {230 $$ = an(OEQ, $1, $3);231 }232 | expr Tneq expr233 {234 $$ = an(ONEQ, $1, $3);235 }236 | expr '&' expr237 {238 $$ = an(OLAND, $1, $3);239 }240 | expr '^' expr241 {242 $$ = an(OXOR, $1, $3);243 }244 | expr '|' expr245 {246 $$ = an(OLOR, $1, $3);247 }248 | expr Tandand expr249 {250 $$ = an(OCAND, $1, $3);251 }252 | expr Toror expr253 {254 $$ = an(OCOR, $1, $3);255 }256 | expr '=' expr257 {258 $$ = an(OASGN, $1, $3);259 }260 | expr Tfmt261 {262 $$ = an(OFMT, $1, con($2));263 }264 ;266 castexpr : monexpr267 | '(' Tid ')' monexpr268 {269 $$ = an(OCAST, $4, ZN);270 $$->sym = $2;271 }272 ;274 monexpr : term275 | '*' monexpr276 {277 $$ = an(OINDM, $2, ZN);278 }279 | '@' monexpr280 {281 $$ = an(OINDC, $2, ZN);282 }283 | '+' monexpr284 {285 $$ = an(OUPLUS, $2, ZN);286 }287 | '-' monexpr288 {289 $$ = con(0);290 $$ = an(OSUB, $$, $2);291 }292 | Tdec monexpr293 {294 $$ = an(OEDEC, $2, ZN);295 }296 | Tinc monexpr297 {298 $$ = an(OEINC, $2, ZN);299 }300 | Thead monexpr301 {302 $$ = an(OHEAD, $2, ZN);303 }304 | Ttail monexpr305 {306 $$ = an(OTAIL, $2, ZN);307 }308 | Tappend monexpr ',' monexpr309 {310 $$ = an(OAPPEND, $2, $4);311 }312 | Tdelete monexpr ',' monexpr313 {314 $$ = an(ODELETE, $2, $4);315 }316 | '!' monexpr317 {318 $$ = an(ONOT, $2, ZN);319 }320 | '~' monexpr321 {322 $$ = an(OXOR, $2, con(-1));323 }324 | Teval monexpr325 {326 $$ = an(OEVAL, $2, ZN);327 }328 ;330 term : '(' expr ')'331 {332 $$ = $2;333 }334 | '{' args '}'335 {336 $$ = an(OCTRUCT, $2, ZN);337 }338 | term '[' expr ']'339 {340 $$ = an(OINDEX, $1, $3);341 }342 | term Tdec343 {344 $$ = an(OPDEC, $1, ZN);345 }346 | term '.' Tid347 {348 $$ = an(ODOT, $1, ZN);349 $$->sym = $3;350 }351 | term Tindir Tid352 {353 $$ = an(ODOT, an(OINDM, $1, ZN), ZN);354 $$->sym = $3;355 }356 | term Tinc357 {358 $$ = an(OPINC, $1, ZN);359 }360 | name '(' args ')'361 {362 $$ = an(OCALL, $1, $3);363 }364 | Tbuiltin name '(' args ')'365 {366 $$ = an(OCALL, $2, $4);367 $$->builtin = 1;368 }369 | name370 | Tconst371 {372 $$ = con($1);373 }374 | Tfconst375 {376 $$ = an(OCONST, ZN, ZN);377 $$->type = TFLOAT;378 $$->store.fmt = 'f';379 $$->store.u.fval = $1;380 }381 | Tstring382 {383 $$ = an(OCONST, ZN, ZN);384 $$->type = TSTRING;385 $$->store.u.string = $1;386 $$->store.fmt = 's';387 }388 | Twhat zname389 {390 $$ = an(OWHAT, ZN, ZN);391 $$->sym = $2;392 }393 ;395 name : Tid396 {397 $$ = an(ONAME, ZN, ZN);398 $$->sym = $1;399 }400 | Tid ':' name401 {402 $$ = an(OFRAME, $3, ZN);403 $$->sym = $1;404 }405 ;407 args : zexpr408 | args ',' zexpr409 {410 $$ = an(OLIST, $1, $3);411 }412 ;