LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 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 <u.h> | 5 #include <u.h> |
6 #include <libc.h> | 6 #include <libc.h> |
7 #include "go.h" | 7 #include "go.h" |
8 #include "opnames.h" | 8 #include "opnames.h" |
9 | 9 |
10 // | 10 // |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 527 |
528 if(fp->flags&FmtByte) { // FmtByte (hh) implies FmtShort (h) | 528 if(fp->flags&FmtByte) { // FmtByte (hh) implies FmtShort (h) |
529 // skip leading "type." in method name | 529 // skip leading "type." in method name |
530 p = utfrrune(s->name, '.'); | 530 p = utfrrune(s->name, '.'); |
531 if(p) | 531 if(p) |
532 p++; | 532 p++; |
533 else | 533 else |
534 p = s->name; | 534 p = s->name; |
535 | 535 |
536 // exportname needs to see the name without the prefix too. | 536 // exportname needs to see the name without the prefix too. |
537 » » if((fmtmode == FExp && !exportname(p)) || fmtmode == FDbg) { | 537 » » if((fmtmode == FExp && !exportname(p)) || fmtmode == FDbg) |
538 » » » if(s->pkg != builtinpkg) | 538 » » » return fmtprint(fp, "@\"%Z\".%s", s->pkg->path, p); |
539 » » » » return fmtprint(fp, "@\"%Z\".%s", s->pkg->path,
p); | |
540 » » » else | |
541 » » » » return fmtprint(fp, "@\"\".%s", p); | |
542 » » } | |
543 | 539 |
544 return fmtstrcpy(fp, p); | 540 return fmtstrcpy(fp, p); |
545 } | 541 } |
546 | 542 |
547 return fmtstrcpy(fp, s->name); | 543 return fmtstrcpy(fp, s->name); |
548 } | 544 } |
549 | 545 |
550 static char* | 546 static char* |
551 basicnames[] = | 547 basicnames[] = |
552 { | 548 { |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 [OXFALL] = -1, | 1075 [OXFALL] = -1, |
1080 | 1076 |
1081 [OEND] = 0 | 1077 [OEND] = 0 |
1082 }; | 1078 }; |
1083 | 1079 |
1084 static int | 1080 static int |
1085 exprfmt(Fmt *f, Node *n, int prec) | 1081 exprfmt(Fmt *f, Node *n, int prec) |
1086 { | 1082 { |
1087 int nprec; | 1083 int nprec; |
1088 NodeList *l; | 1084 NodeList *l; |
1089 Type *t; | |
1090 | 1085 |
1091 while(n && n->implicit && (n->op == OIND || n->op == OADDR)) | 1086 while(n && n->implicit && (n->op == OIND || n->op == OADDR)) |
1092 n = n->left; | 1087 n = n->left; |
1093 | 1088 |
1094 if(n == N) | 1089 if(n == N) |
1095 return fmtstrcpy(f, "<N>"); | 1090 return fmtstrcpy(f, "<N>"); |
1096 | 1091 |
1097 nprec = opprec[n->op]; | 1092 nprec = opprec[n->op]; |
1098 if(n->op == OTYPE && n->sym != S) | 1093 if(n->op == OTYPE && n->sym != S) |
1099 nprec = 8; | 1094 nprec = 8; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 return fmtprint(f, "%N", n->left); | 1200 return fmtprint(f, "%N", n->left); |
1206 return fmtprint(f, "&%N", n->left); | 1201 return fmtprint(f, "&%N", n->left); |
1207 | 1202 |
1208 case OSTRUCTLIT: | 1203 case OSTRUCTLIT: |
1209 if(fmtmode == FExp) { // requires special handling of field na
mes | 1204 if(fmtmode == FExp) { // requires special handling of field na
mes |
1210 if(n->implicit) | 1205 if(n->implicit) |
1211 fmtstrcpy(f, "{"); | 1206 fmtstrcpy(f, "{"); |
1212 else | 1207 else |
1213 fmtprint(f, "(%T{", n->type); | 1208 fmtprint(f, "(%T{", n->type); |
1214 for(l=n->list; l; l=l->next) { | 1209 for(l=n->list; l; l=l->next) { |
1215 » » » » // another special case: if n->left is an embedd
ed field of builtin type, | 1210 » » » » fmtprint(f, " %hhS:%N", l->n->left->sym, l->n->r
ight); |
1216 » » » » // it needs to be non-qualified. Can't figure t
hat out in %S, so do it here | |
1217 » » » » if(l->n->left->type->embedded) { | |
1218 » » » » » t = l->n->left->type->type; | |
1219 » » » » » if(t->sym == S) | |
1220 » » » » » » t = t->type; | |
1221 » » » » » fmtprint(f, " %hhS:%N", t->sym, l->n->ri
ght); | |
1222 » » » » } else | |
1223 » » » » » fmtprint(f, " %hhS:%N", l->n->left->sym,
l->n->right); | |
1224 | 1211 |
1225 if(l->next) | 1212 if(l->next) |
1226 fmtstrcpy(f, ","); | 1213 fmtstrcpy(f, ","); |
1227 else | 1214 else |
1228 fmtstrcpy(f, " "); | 1215 fmtstrcpy(f, " "); |
1229 } | 1216 } |
1230 if(!n->implicit) | 1217 if(!n->implicit) |
1231 return fmtstrcpy(f, "})"); | 1218 return fmtstrcpy(f, "})"); |
1232 return fmtstrcpy(f, "}"); | 1219 return fmtstrcpy(f, "}"); |
1233 } | 1220 } |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 dumplist(char *s, NodeList *l) | 1665 dumplist(char *s, NodeList *l) |
1679 { | 1666 { |
1680 print("%s\n%+H\n", s, l); | 1667 print("%s\n%+H\n", s, l); |
1681 } | 1668 } |
1682 | 1669 |
1683 void | 1670 void |
1684 dump(char *s, Node *n) | 1671 dump(char *s, Node *n) |
1685 { | 1672 { |
1686 print("%s [%p]\n%+N\n", s, n, n); | 1673 print("%s [%p]\n%+N\n", s, n, n); |
1687 } | 1674 } |
LEFT | RIGHT |