The apple targets are not done yet.
Showing the changes to parse.c (1 of 12 files). Show all
Unified · Split
| @@ -45,6 +45,7 @@ enum { · 44 unmodified lines | ||
| 45 | 45 | Tjnz, |
| 46 | 46 | Tret, |
| 47 | 47 | Texport, |
| 48 | + Tthread, | |
| 48 | 49 | Tfunc, |
| 49 | 50 | Ttype, |
| 50 | 51 | Tdata, |
| @@ -99,6 +100,7 @@ static char *kwmap[Ntok] = { · 48 unmodified lines | ||
| 99 | 100 | [Tjnz] = "jnz", |
| 100 | 101 | [Tret] = "ret", |
| 101 | 102 | [Texport] = "export", |
| 103 | + [Tthread] = "thread", | |
| 102 | 104 | [Tfunc] = "function", |
| 103 | 105 | [Ttype] = "type", |
| 104 | 106 | [Tdata] = "data", |
| @@ -399,30 +401,34 @@ parseref() · 294 unmodified lines | ||
| 399 | 401 | |
| 400 | 402 | memset(&c, 0, sizeof c); |
| 401 | 403 | switch (next()) { |
| 404 | + default: | |
| 405 | + return R; | |
| 402 | 406 | case Ttmp: |
| 403 | 407 | return tmpref(tokval.str); |
| 404 | 408 | case Tint: |
| 405 | 409 | c.type = CBits; |
| 406 | 410 | c.bits.i = tokval.num; |
| 407 | − goto Look; | |
| 411 | + break; | |
| 408 | 412 | case Tflts: |
| 409 | 413 | c.type = CBits; |
| 410 | 414 | c.bits.s = tokval.flts; |
| 411 | 415 | c.flt = 1; |
| 412 | − goto Look; | |
| 416 | + break; | |
| 413 | 417 | case Tfltd: |
| 414 | 418 | c.type = CBits; |
| 415 | 419 | c.bits.d = tokval.fltd; |
| 416 | 420 | c.flt = 2; |
| 417 | − goto Look; | |
| 421 | + break; | |
| 422 | + case Tthread: | |
| 423 | + c.rel = RelThr; | |
| 424 | + expect(Tglo); | |
| 425 | + /* fall through */ | |
| 418 | 426 | case Tglo: |
| 419 | 427 | c.type = CAddr; |
| 420 | 428 | c.label = intern(tokval.str); |
| 421 | − Look: | |
| 422 | − return newcon(&c, curf); | |
| 423 | − default: | |
| 424 | − return R; | |
| 429 | + break; | |
| 425 | 430 | } |
| 431 | + return newcon(&c, curf); | |
| 426 | 432 | } |
| 427 | 433 | |
| 428 | 434 | static int |
| @@ -1101,6 +1107,9 @@ parselnk(Lnk *lnk) · 672 unmodified lines | ||
| 1101 | 1107 | case Texport: |
| 1102 | 1108 | lnk->export = 1; |
| 1103 | 1109 | break; |
| 1110 | + case Tthread: | |
| 1111 | + lnk->thread = 1; | |
| 1112 | + break; | |
| 1104 | 1113 | case Tsection: |
| 1105 | 1114 | if (lnk->sec) |
| 1106 | 1115 | err("only one section allowed"); |
| @@ -1113,9 +1122,9 @@ parselnk(Lnk *lnk) · 6 unmodified lines | ||
| 1113 | 1122 | } |
| 1114 | 1123 | break; |
| 1115 | 1124 | default: |
| 1116 | − if (haslnk) | |
| 1117 | − if (t != Tdata) | |
| 1118 | − if (t != Tfunc) | |
| 1125 | + if (t == Tfunc && lnk->thread) | |
| 1126 | + err("only data may have thread linkage"); | |
| 1127 | + if (haslnk && t != Tdata && t != Tfunc) | |
| 1119 | 1128 | err("only data and function have linkage"); |
| 1120 | 1129 | return t; |
| 1121 | 1130 | } |
| @@ -1244,8 +1253,6 @@ printfn(Fn *fn, FILE *f) · 122 unmodified lines | ||
| 1244 | 1253 | Ins *i; |
| 1245 | 1254 | uint n; |
| 1246 | 1255 | |
| 1247 | − if (fn->lnk.export) | |
| 1248 | − fprintf(f, "export "); | |
| 1249 | 1256 | fprintf(f, "function $%s() {\n", fn->name); |
| 1250 | 1257 | for (b=fn->start; b; b=b->link) { |
| 1251 | 1258 | fprintf(f, "@%s\n", b->name); |