LEFT | RIGHT |
(no file at all) | |
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 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 case OCLOSURE: | 1154 case OCLOSURE: |
1155 if(fmtmode == FErr) | 1155 if(fmtmode == FErr) |
1156 return fmtstrcpy(f, "func literal"); | 1156 return fmtstrcpy(f, "func literal"); |
1157 if(n->nbody) | 1157 if(n->nbody) |
1158 return fmtprint(f, "%T { %H }", n->type, n->nbody); | 1158 return fmtprint(f, "%T { %H }", n->type, n->nbody); |
1159 return fmtprint(f, "%T { %H }", n->type, n->closure->nbody); | 1159 return fmtprint(f, "%T { %H }", n->type, n->closure->nbody); |
1160 | 1160 |
1161 case OCOMPLIT: | 1161 case OCOMPLIT: |
1162 if(fmtmode == FErr) | 1162 if(fmtmode == FErr) |
1163 return fmtstrcpy(f, "composite literal"); | 1163 return fmtstrcpy(f, "composite literal"); |
1164 » » return fmtprint(f, "%N{ %,H }", n->right, n->list); | 1164 » » return fmtprint(f, "(%N{ %,H })", n->right, n->list); |
1165 | 1165 |
1166 case OPTRLIT: | 1166 case OPTRLIT: |
1167 if(fmtmode == FExp && n->left->implicit) | 1167 if(fmtmode == FExp && n->left->implicit) |
1168 return fmtprint(f, "%N", n->left); | 1168 return fmtprint(f, "%N", n->left); |
1169 return fmtprint(f, "&%N", n->left); | 1169 return fmtprint(f, "&%N", n->left); |
1170 | 1170 |
1171 case OSTRUCTLIT: | 1171 case OSTRUCTLIT: |
1172 if(fmtmode == FExp) { // requires special handling of field na
mes | 1172 if(fmtmode == FExp) { // requires special handling of field na
mes |
1173 if(n->implicit) | 1173 if(n->implicit) |
1174 fmtstrcpy(f, "{"); | 1174 fmtstrcpy(f, "{"); |
1175 » » » else | 1175 » » » else |
1176 » » » » fmtprint(f, "%T{", n->type); | 1176 » » » » fmtprint(f, "(%T{", n->type); |
1177 for(l=n->list; l; l=l->next) { | 1177 for(l=n->list; l; l=l->next) { |
1178 // another special case: if n->left is an embedd
ed field of builtin type, | 1178 // another special case: if n->left is an embedd
ed field of builtin type, |
1179 // it needs to be non-qualified. Can't figure t
hat out in %S, so do it here | 1179 // it needs to be non-qualified. Can't figure t
hat out in %S, so do it here |
1180 if(l->n->left->type->embedded) { | 1180 if(l->n->left->type->embedded) { |
1181 t = l->n->left->type->type; | 1181 t = l->n->left->type->type; |
1182 if(t->sym == S) | 1182 if(t->sym == S) |
1183 t = t->type; | 1183 t = t->type; |
1184 fmtprint(f, " %hhS:%N", t->sym, l->n->ri
ght); | 1184 fmtprint(f, " %hhS:%N", t->sym, l->n->ri
ght); |
1185 } else | 1185 } else |
1186 fmtprint(f, " %hhS:%N", l->n->left->sym,
l->n->right); | 1186 fmtprint(f, " %hhS:%N", l->n->left->sym,
l->n->right); |
1187 | 1187 |
1188 if(l->next) | 1188 if(l->next) |
1189 fmtstrcpy(f, ","); | 1189 fmtstrcpy(f, ","); |
1190 else | 1190 else |
1191 fmtstrcpy(f, " "); | 1191 fmtstrcpy(f, " "); |
1192 } | 1192 } |
| 1193 if(!n->implicit) |
| 1194 return fmtstrcpy(f, "})"); |
1193 return fmtstrcpy(f, "}"); | 1195 return fmtstrcpy(f, "}"); |
1194 } | 1196 } |
1195 // fallthrough | 1197 // fallthrough |
1196 | 1198 |
1197 case OARRAYLIT: | 1199 case OARRAYLIT: |
1198 case OMAPLIT: | 1200 case OMAPLIT: |
1199 if(fmtmode == FErr) | 1201 if(fmtmode == FErr) |
1200 return fmtprint(f, "%T literal", n->type); | 1202 return fmtprint(f, "%T literal", n->type); |
1201 if(fmtmode == FExp && n->implicit) | 1203 if(fmtmode == FExp && n->implicit) |
1202 return fmtprint(f, "{ %,H }", n->list); | 1204 return fmtprint(f, "{ %,H }", n->list); |
1203 » » return fmtprint(f, "%T{ %,H }", n->type, n->list); | 1205 » » return fmtprint(f, "(%T{ %,H })", n->type, n->list); |
1204 | 1206 |
1205 case OKEY: | 1207 case OKEY: |
1206 if(n->left && n->right) | 1208 if(n->left && n->right) |
1207 return fmtprint(f, "%N:%N", n->left, n->right); | 1209 return fmtprint(f, "%N:%N", n->left, n->right); |
1208 if(!n->left && n->right) | 1210 if(!n->left && n->right) |
1209 return fmtprint(f, ":%N", n->right); | 1211 return fmtprint(f, ":%N", n->right); |
1210 if(n->left && !n->right) | 1212 if(n->left && !n->right) |
1211 return fmtprint(f, "%N:", n->left); | 1213 return fmtprint(f, "%N:", n->left); |
1212 return fmtstrcpy(f, ":"); | 1214 return fmtstrcpy(f, ":"); |
1213 | 1215 |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 dumplist(char *s, NodeList *l) | 1636 dumplist(char *s, NodeList *l) |
1635 { | 1637 { |
1636 print("%s\n%+H\n", s, l); | 1638 print("%s\n%+H\n", s, l); |
1637 } | 1639 } |
1638 | 1640 |
1639 void | 1641 void |
1640 dump(char *s, Node *n) | 1642 dump(char *s, Node *n) |
1641 { | 1643 { |
1642 print("%s [%p]\n%+N\n", s, n, n); | 1644 print("%s [%p]\n%+N\n", s, n, n); |
1643 } | 1645 } |
LEFT | RIGHT |