LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "go.h" | 5 #include "go.h" |
6 #include "md5.h" | 6 #include "md5.h" |
7 #include "y.tab.h" | 7 #include "y.tab.h" |
8 #include "opnames.h" | 8 #include "opnames.h" |
9 #include "yerr.h" | 9 #include "yerr.h" |
10 | 10 |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 fmtprint(fp, " g(%d)", n->vargen); | 1087 fmtprint(fp, " g(%d)", n->vargen); |
1088 | 1088 |
1089 if(n->lineno != 0) | 1089 if(n->lineno != 0) |
1090 fmtprint(fp, " l(%d)", n->lineno); | 1090 fmtprint(fp, " l(%d)", n->lineno); |
1091 | 1091 |
1092 if(!c && n->xoffset != BADWIDTH) | 1092 if(!c && n->xoffset != BADWIDTH) |
1093 fmtprint(fp, " x(%lld%+d)", n->xoffset, n->stkdelta); | 1093 fmtprint(fp, " x(%lld%+d)", n->xoffset, n->stkdelta); |
1094 | 1094 |
1095 if(n->class != 0) { | 1095 if(n->class != 0) { |
1096 s = ""; | 1096 s = ""; |
1097 » » if (n->class & PHEAP) s = ",heap"; | 1097 » » if(n->class & PHEAP) s = ",heap"; |
1098 » » if ((n->class & ~PHEAP) < nelem(classnames)) | 1098 » » if((n->class & ~PHEAP) < nelem(classnames)) |
1099 fmtprint(fp, " class(%s%s)", classnames[n->class&~PHEAP]
, s); | 1099 fmtprint(fp, " class(%s%s)", classnames[n->class&~PHEAP]
, s); |
1100 else | 1100 else |
1101 fmtprint(fp, " class(%d?%s)", n->class&~PHEAP, s); | 1101 fmtprint(fp, " class(%d?%s)", n->class&~PHEAP, s); |
1102 } | 1102 } |
1103 · | 1103 · |
1104 if(n->colas != 0) | 1104 if(n->colas != 0) |
1105 fmtprint(fp, " colas(%d)", n->colas); | 1105 fmtprint(fp, " colas(%d)", n->colas); |
1106 | 1106 |
1107 if(n->funcdepth != 0) | 1107 if(n->funcdepth != 0) |
1108 fmtprint(fp, " f(%d)", n->funcdepth); | 1108 fmtprint(fp, " f(%d)", n->funcdepth); |
1109 | 1109 |
1110 » if(n->noescape != 0) | 1110 » switch(n->esc) { |
1111 » » fmtprint(fp, " ne(%d)", n->noescape); | 1111 » case EscUnknown: |
| 1112 » » break; |
| 1113 » case EscHeap: |
| 1114 » » fmtprint(fp, " esc(h)"); |
| 1115 » » break; |
| 1116 » case EscScope: |
| 1117 » » fmtprint(fp, " esc(s)"); |
| 1118 » » break; |
| 1119 » case EscNone: |
| 1120 » » fmtprint(fp, " esc(no)"); |
| 1121 » » break; |
| 1122 » case EscNever: |
| 1123 » » if(!c) |
| 1124 » » » fmtprint(fp, " esc(N)"); |
| 1125 » » break; |
| 1126 » default: |
| 1127 » » fmtprint(fp, " esc(%d)", n->esc); |
| 1128 » » break; |
| 1129 » } |
| 1130 |
| 1131 » if(n->escloopdepth) |
| 1132 » » fmtprint(fp, " ld(%d)", n->escloopdepth); |
1112 | 1133 |
1113 if(!c && n->typecheck != 0) | 1134 if(!c && n->typecheck != 0) |
1114 fmtprint(fp, " tc(%d)", n->typecheck); | 1135 fmtprint(fp, " tc(%d)", n->typecheck); |
1115 | 1136 |
1116 if(!c && n->dodata != 0) | 1137 if(!c && n->dodata != 0) |
1117 fmtprint(fp, " dd(%d)", n->dodata); | 1138 fmtprint(fp, " dd(%d)", n->dodata); |
1118 | 1139 |
1119 if(n->isddd != 0) | 1140 if(n->isddd != 0) |
1120 fmtprint(fp, " isddd(%d)", n->isddd); | 1141 fmtprint(fp, " isddd(%d)", n->isddd); |
1121 | 1142 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 | 1537 |
1517 if(fp->flags & FmtSharp) { | 1538 if(fp->flags & FmtSharp) { |
1518 if(n->orig != N) | 1539 if(n->orig != N) |
1519 n = n->orig; | 1540 n = n->orig; |
1520 exprfmt(fp, n, 0); | 1541 exprfmt(fp, n, 0); |
1521 goto out; | 1542 goto out; |
1522 } | 1543 } |
1523 | 1544 |
1524 switch(n->op) { | 1545 switch(n->op) { |
1525 default: | 1546 default: |
1526 » » if (fp->flags & FmtShort) | 1547 » » if(fp->flags & FmtShort) |
1527 fmtprint(fp, "%O%hJ", n->op, n); | 1548 fmtprint(fp, "%O%hJ", n->op, n); |
1528 else | 1549 else |
1529 fmtprint(fp, "%O%J", n->op, n); | 1550 fmtprint(fp, "%O%J", n->op, n); |
1530 break; | 1551 break; |
1531 | 1552 |
1532 case ONAME: | 1553 case ONAME: |
1533 case ONONAME: | 1554 case ONONAME: |
1534 if(n->sym == S) { | 1555 if(n->sym == S) { |
1535 » » » if (fp->flags & FmtShort) | 1556 » » » if(fp->flags & FmtShort) |
1536 fmtprint(fp, "%O%hJ", n->op, n); | 1557 fmtprint(fp, "%O%hJ", n->op, n); |
1537 else | 1558 else |
1538 fmtprint(fp, "%O%J", n->op, n); | 1559 fmtprint(fp, "%O%J", n->op, n); |
1539 break; | 1560 break; |
1540 } | 1561 } |
1541 » » if (fp->flags & FmtShort) | 1562 » » if(fp->flags & FmtShort) |
1542 fmtprint(fp, "%O-%S%hJ", n->op, n->sym, n); | 1563 fmtprint(fp, "%O-%S%hJ", n->op, n->sym, n); |
1543 else | 1564 else |
1544 fmtprint(fp, "%O-%S%J", n->op, n->sym, n); | 1565 fmtprint(fp, "%O-%S%J", n->op, n->sym, n); |
1545 goto ptyp; | 1566 goto ptyp; |
1546 | 1567 |
1547 case OREGISTER: | 1568 case OREGISTER: |
1548 fmtprint(fp, "%O-%R%J", n->op, n->val.u.reg, n); | 1569 fmtprint(fp, "%O-%R%J", n->op, n->val.u.reg, n); |
1549 break; | 1570 break; |
1550 | 1571 |
1551 case OLITERAL: | 1572 case OLITERAL: |
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3169 */ | 3190 */ |
3170 void | 3191 void |
3171 genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface) | 3192 genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface) |
3172 { | 3193 { |
3173 Node *this, *fn, *call, *n, *t, *pad; | 3194 Node *this, *fn, *call, *n, *t, *pad; |
3174 NodeList *l, *args, *in, *out; | 3195 NodeList *l, *args, *in, *out; |
3175 Type *tpad; | 3196 Type *tpad; |
3176 int isddd; | 3197 int isddd; |
3177 Val v; | 3198 Val v; |
3178 | 3199 |
3179 » if(debug['r']) | 3200 » if(0 && debug['r']) |
3180 print("genwrapper rcvrtype=%T method=%T newnam=%S\n", | 3201 print("genwrapper rcvrtype=%T method=%T newnam=%S\n", |
3181 rcvr, method, newnam); | 3202 rcvr, method, newnam); |
3182 | 3203 |
3183 lineno = 1; // less confusing than end of input | 3204 lineno = 1; // less confusing than end of input |
3184 | 3205 |
3185 dclcontext = PEXTERN; | 3206 dclcontext = PEXTERN; |
3186 markdcl(); | 3207 markdcl(); |
3187 | 3208 |
3188 this = nod(ODCLFIELD, newname(lookup(".this")), typenod(rcvr)); | 3209 this = nod(ODCLFIELD, newname(lookup(".this")), typenod(rcvr)); |
3189 this->left->ntype = this->right; | 3210 this->left->ntype = this->right; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3446 | 3467 |
3447 l2 = l1->next; | 3468 l2 = l1->next; |
3448 l1->next = nil; | 3469 l1->next = nil; |
3449 l2->end = (*l)->end; | 3470 l2->end = (*l)->end; |
3450 (*l)->end = l1; | 3471 (*l)->end = l1; |
3451 | 3472 |
3452 l1 = *l; | 3473 l1 = *l; |
3453 listsort(&l1, f); | 3474 listsort(&l1, f); |
3454 listsort(&l2, f); | 3475 listsort(&l2, f); |
3455 | 3476 |
3456 » if ((*f)(l1->n, l2->n) < 0) { | 3477 » if((*f)(l1->n, l2->n) < 0) { |
3457 *l = l1; | 3478 *l = l1; |
3458 } else { | 3479 } else { |
3459 *l = l2; | 3480 *l = l2; |
3460 l2 = l1; | 3481 l2 = l1; |
3461 l1 = *l; | 3482 l1 = *l; |
3462 } | 3483 } |
3463 | 3484 |
3464 // now l1 == *l; and l1 < l2 | 3485 // now l1 == *l; and l1 < l2 |
3465 | 3486 |
3466 while ((l1 != nil) && (l2 != nil)) { | 3487 while ((l1 != nil) && (l2 != nil)) { |
3467 while ((l1->next != nil) && (*f)(l1->next->n, l2->n) < 0) | 3488 while ((l1->next != nil) && (*f)(l1->next->n, l2->n) < 0) |
3468 l1 = l1->next; | 3489 l1 = l1->next; |
3469 ················ | 3490 ················ |
3470 // l1 is last one from l1 that is < l2 | 3491 // l1 is last one from l1 that is < l2 |
3471 le = l1->next; // le is the rest of l1, first one that
is >= l2 | 3492 le = l1->next; // le is the rest of l1, first one that
is >= l2 |
3472 » » if (le != nil) | 3493 » » if(le != nil) |
3473 le->end = (*l)->end; | 3494 le->end = (*l)->end; |
3474 | 3495 |
3475 (*l)->end = l1; // cut *l at l1 | 3496 (*l)->end = l1; // cut *l at l1 |
3476 *l = concat(*l, l2); // glue l2 to *l's tail | 3497 *l = concat(*l, l2); // glue l2 to *l's tail |
3477 | 3498 |
3478 l1 = l2; // l1 is the first element of *l that is
< the new l2 | 3499 l1 = l2; // l1 is the first element of *l that is
< the new l2 |
3479 l2 = le; // ... because l2 now is the old tail of
l1 | 3500 l2 = le; // ... because l2 now is the old tail of
l1 |
3480 } | 3501 } |
3481 | 3502 |
3482 *l = concat(*l, l2); // any remainder· | 3503 *l = concat(*l, l2); // any remainder· |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3876 Strlit* | 3897 Strlit* |
3877 strlit(char *s) | 3898 strlit(char *s) |
3878 { | 3899 { |
3879 Strlit *t; | 3900 Strlit *t; |
3880 ········ | 3901 ········ |
3881 t = mal(sizeof *t + strlen(s)); | 3902 t = mal(sizeof *t + strlen(s)); |
3882 strcpy(t->s, s); | 3903 strcpy(t->s, s); |
3883 t->len = strlen(s); | 3904 t->len = strlen(s); |
3884 return t; | 3905 return t; |
3885 } | 3906 } |
LEFT | RIGHT |