OLD | NEW |
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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 [OXFALL] = -1, | 1075 [OXFALL] = -1, |
1076 | 1076 |
1077 [OEND] = 0 | 1077 [OEND] = 0 |
1078 }; | 1078 }; |
1079 | 1079 |
1080 static int | 1080 static int |
1081 exprfmt(Fmt *f, Node *n, int prec) | 1081 exprfmt(Fmt *f, Node *n, int prec) |
1082 { | 1082 { |
1083 int nprec; | 1083 int nprec; |
1084 NodeList *l; | 1084 NodeList *l; |
1085 Type *t; | |
1086 | 1085 |
1087 while(n && n->implicit && (n->op == OIND || n->op == OADDR)) | 1086 while(n && n->implicit && (n->op == OIND || n->op == OADDR)) |
1088 n = n->left; | 1087 n = n->left; |
1089 | 1088 |
1090 if(n == N) | 1089 if(n == N) |
1091 return fmtstrcpy(f, "<N>"); | 1090 return fmtstrcpy(f, "<N>"); |
1092 | 1091 |
1093 nprec = opprec[n->op]; | 1092 nprec = opprec[n->op]; |
1094 if(n->op == OTYPE && n->sym != S) | 1093 if(n->op == OTYPE && n->sym != S) |
1095 nprec = 8; | 1094 nprec = 8; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 return fmtprint(f, "%N", n->left); | 1200 return fmtprint(f, "%N", n->left); |
1202 return fmtprint(f, "&%N", n->left); | 1201 return fmtprint(f, "&%N", n->left); |
1203 | 1202 |
1204 case OSTRUCTLIT: | 1203 case OSTRUCTLIT: |
1205 if(fmtmode == FExp) { // requires special handling of field na
mes | 1204 if(fmtmode == FExp) { // requires special handling of field na
mes |
1206 if(n->implicit) | 1205 if(n->implicit) |
1207 fmtstrcpy(f, "{"); | 1206 fmtstrcpy(f, "{"); |
1208 else | 1207 else |
1209 fmtprint(f, "(%T{", n->type); | 1208 fmtprint(f, "(%T{", n->type); |
1210 for(l=n->list; l; l=l->next) { | 1209 for(l=n->list; l; l=l->next) { |
1211 » » » » // 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); |
1212 » » » » // it needs to be non-qualified. Can't figure t
hat out in %S, so do it here | |
1213 » » » » if(l->n->left->type->embedded) { | |
1214 » » » » » t = l->n->left->type->type; | |
1215 » » » » » if(t->sym == S) | |
1216 » » » » » » t = t->type; | |
1217 » » » » » fmtprint(f, " %hhS:%N", t->sym, l->n->ri
ght); | |
1218 » » » » } else | |
1219 » » » » » fmtprint(f, " %hhS:%N", l->n->left->sym,
l->n->right); | |
1220 | 1211 |
1221 if(l->next) | 1212 if(l->next) |
1222 fmtstrcpy(f, ","); | 1213 fmtstrcpy(f, ","); |
1223 else | 1214 else |
1224 fmtstrcpy(f, " "); | 1215 fmtstrcpy(f, " "); |
1225 } | 1216 } |
1226 if(!n->implicit) | 1217 if(!n->implicit) |
1227 return fmtstrcpy(f, "})"); | 1218 return fmtstrcpy(f, "})"); |
1228 return fmtstrcpy(f, "}"); | 1219 return fmtstrcpy(f, "}"); |
1229 } | 1220 } |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 dumplist(char *s, NodeList *l) | 1665 dumplist(char *s, NodeList *l) |
1675 { | 1666 { |
1676 print("%s\n%+H\n", s, l); | 1667 print("%s\n%+H\n", s, l); |
1677 } | 1668 } |
1678 | 1669 |
1679 void | 1670 void |
1680 dump(char *s, Node *n) | 1671 dump(char *s, Node *n) |
1681 { | 1672 { |
1682 print("%s [%p]\n%+N\n", s, n, n); | 1673 print("%s [%p]\n%+N\n", s, n, n); |
1683 } | 1674 } |
OLD | NEW |