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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 if(fmtmode == FExp && n->right == N) | 803 if(fmtmode == FExp && n->right == N) |
804 break; | 804 break; |
805 | 805 |
806 if(n->colas && !complexinit) | 806 if(n->colas && !complexinit) |
807 fmtprint(f, "%N := %N", n->left, n->right); | 807 fmtprint(f, "%N := %N", n->left, n->right); |
808 else | 808 else |
809 fmtprint(f, "%N = %N", n->left, n->right); | 809 fmtprint(f, "%N = %N", n->left, n->right); |
810 break; | 810 break; |
811 | 811 |
812 case OASOP: | 812 case OASOP: |
| 813 if(n->implicit) { |
| 814 if(n->etype == OADD) |
| 815 fmtprint(f, "%N++", n->left); |
| 816 else |
| 817 fmtprint(f, "%N--", n->left); |
| 818 break; |
| 819 } |
813 fmtprint(f, "%N %#O= %N", n->left, n->etype, n->right); | 820 fmtprint(f, "%N %#O= %N", n->left, n->etype, n->right); |
814 break; | 821 break; |
815 | 822 |
816 case OAS2: | 823 case OAS2: |
817 if(n->colas && !complexinit) { | 824 if(n->colas && !complexinit) { |
818 fmtprint(f, "%,H := %,H", n->list, n->rlist); | 825 fmtprint(f, "%,H := %,H", n->list, n->rlist); |
819 break; | 826 break; |
820 } | 827 } |
821 // fallthrough | 828 // fallthrough |
822 case OAS2DOTTYPE: | 829 case OAS2DOTTYPE: |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 // be misinterpreted as a unary operator: * or <-. | 1108 // be misinterpreted as a unary operator: * or <-. |
1102 if(isptr[n->type->etype] || (n->type->etype == TCHAN &&
n->type->chan == Crecv)) | 1109 if(isptr[n->type->etype] || (n->type->etype == TCHAN &&
n->type->chan == Crecv)) |
1103 return fmtprint(f, "(%T)(%V)", n->type, &n->val)
; | 1110 return fmtprint(f, "(%T)(%V)", n->type, &n->val)
; |
1104 else· | 1111 else· |
1105 return fmtprint(f, "%T(%V)", n->type, &n->val); | 1112 return fmtprint(f, "%T(%V)", n->type, &n->val); |
1106 } | 1113 } |
1107 return fmtprint(f, "%V", &n->val); | 1114 return fmtprint(f, "%V", &n->val); |
1108 | 1115 |
1109 case ONAME: | 1116 case ONAME: |
1110 // Special case: name used as local variable in export. | 1117 // Special case: name used as local variable in export. |
1111 » » switch(n->class&~PHEAP){ | 1118 » » // _ becomes ~b%d internally; print as _ for export |
1112 » » case PAUTO: | 1119 » » if(fmtmode == FExp && n->sym && n->sym->name[0] == '~' && n->sym
->name[1] == 'b') |
1113 » » case PPARAM: | 1120 » » » return fmtprint(f, "_"); |
1114 » » case PPARAMOUT: | 1121 » » if(fmtmode == FExp && n->sym && !isblank(n) && n->vargen > 0) |
1115 » » » // _ becomes ~b%d internally; print as _ for export | 1122 » » » return fmtprint(f, "%S·%d", n->sym, n->vargen); |
1116 » » » if(fmtmode == FExp && n->sym && n->sym->name[0] == '~' &
& n->sym->name[1] == 'b') | |
1117 » » » » return fmtprint(f, "_"); | |
1118 » » » if(fmtmode == FExp && n->sym && !isblank(n) && n->vargen
> 0) | |
1119 » » » » return fmtprint(f, "%S·%d", n->sym, n->vargen); | |
1120 » » } | |
1121 | 1123 |
1122 // Special case: explicit name of func (*T) method(...) is turne
d into pkg.(*T).method, | 1124 // Special case: explicit name of func (*T) method(...) is turne
d into pkg.(*T).method, |
1123 // but for export, this should be rendered as (*pkg.T).meth. | 1125 // but for export, this should be rendered as (*pkg.T).meth. |
1124 // These nodes have the special property that they are names wit
h a left OTYPE and a right ONAME. | 1126 // These nodes have the special property that they are names wit
h a left OTYPE and a right ONAME. |
1125 if(fmtmode == FExp && n->left && n->left->op == OTYPE && n->righ
t && n->right->op == ONAME) { | 1127 if(fmtmode == FExp && n->left && n->left->op == OTYPE && n->righ
t && n->right->op == ONAME) { |
1126 if(isptr[n->left->type->etype]) | 1128 if(isptr[n->left->type->etype]) |
1127 return fmtprint(f, "(%T).%hhS", n->left->type, n
->right->sym); | 1129 return fmtprint(f, "(%T).%hhS", n->left->type, n
->right->sym); |
1128 else | 1130 else |
1129 return fmtprint(f, "%T.%hhS", n->left->type, n->
right->sym); | 1131 return fmtprint(f, "%T.%hhS", n->left->type, n->
right->sym); |
1130 } | 1132 } |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 dumplist(char *s, NodeList *l) | 1682 dumplist(char *s, NodeList *l) |
1681 { | 1683 { |
1682 print("%s%+H\n", s, l); | 1684 print("%s%+H\n", s, l); |
1683 } | 1685 } |
1684 | 1686 |
1685 void | 1687 void |
1686 dump(char *s, Node *n) | 1688 dump(char *s, Node *n) |
1687 { | 1689 { |
1688 print("%s [%p]%+N\n", s, n, n); | 1690 print("%s [%p]%+N\n", s, n, n); |
1689 } | 1691 } |
OLD | NEW |