LEFT | RIGHT |
(no file at all) | |
1 // Derived from Inferno utils/6c/txt.c | 1 // Derived from Inferno utils/6c/txt.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/6c/txt.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/6c/txt.c |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 */ | 110 */ |
111 Prog* | 111 Prog* |
112 gbranch(int as, Type *t, int likely) | 112 gbranch(int as, Type *t, int likely) |
113 { | 113 { |
114 Prog *p; | 114 Prog *p; |
115 ········ | 115 ········ |
116 USED(t); | 116 USED(t); |
117 | 117 |
118 p = prog(as); | 118 p = prog(as); |
119 p->to.type = D_BRANCH; | 119 p->to.type = D_BRANCH; |
120 » p->to.branch = P; | 120 » p->to.u.branch = P; |
121 if(as != AJMP && likely != 0) { | 121 if(as != AJMP && likely != 0) { |
122 p->from.type = D_CONST; | 122 p->from.type = D_CONST; |
123 p->from.offset = likely > 0; | 123 p->from.offset = likely > 0; |
124 } | 124 } |
125 return p; | 125 return p; |
126 } | 126 } |
127 | 127 |
128 /* | 128 /* |
129 * patch previous branch to jump to to. | 129 * patch previous branch to jump to to. |
130 */ | 130 */ |
131 void | 131 void |
132 patch(Prog *p, Prog *to) | 132 patch(Prog *p, Prog *to) |
133 { | 133 { |
134 if(p->to.type != D_BRANCH) | 134 if(p->to.type != D_BRANCH) |
135 fatal("patch: not a branch"); | 135 fatal("patch: not a branch"); |
136 » p->to.branch = to; | 136 » p->to.u.branch = to; |
137 p->to.offset = to->loc; | 137 p->to.offset = to->loc; |
138 } | 138 } |
139 | 139 |
140 Prog* | 140 Prog* |
141 unpatch(Prog *p) | 141 unpatch(Prog *p) |
142 { | 142 { |
143 Prog *q; | 143 Prog *q; |
144 | 144 |
145 if(p->to.type != D_BRANCH) | 145 if(p->to.type != D_BRANCH) |
146 fatal("unpatch: not a branch"); | 146 fatal("unpatch: not a branch"); |
147 » q = p->to.branch; | 147 » q = p->to.u.branch; |
148 » p->to.branch = P; | 148 » p->to.u.branch = P; |
149 p->to.offset = 0; | 149 p->to.offset = 0; |
150 return q; | 150 return q; |
151 } | 151 } |
152 | 152 |
153 /* | 153 /* |
154 * start a new Prog list. | 154 * start a new Prog list. |
155 */ | 155 */ |
156 Plist* | 156 Plist* |
157 newplist(void) | 157 newplist(void) |
158 { | 158 { |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 } | 1195 } |
1196 break; | 1196 break; |
1197 | 1197 |
1198 case OLITERAL: | 1198 case OLITERAL: |
1199 switch(n->val.ctype) { | 1199 switch(n->val.ctype) { |
1200 default: | 1200 default: |
1201 fatal("naddr: const %lT", n->type); | 1201 fatal("naddr: const %lT", n->type); |
1202 break; | 1202 break; |
1203 case CTFLT: | 1203 case CTFLT: |
1204 a->type = D_FCONST; | 1204 a->type = D_FCONST; |
1205 » » » a->dval = mpgetflt(n->val.u.fval); | 1205 » » » a->u.dval = mpgetflt(n->val.u.fval); |
1206 break; | 1206 break; |
1207 case CTINT: | 1207 case CTINT: |
1208 case CTRUNE: | 1208 case CTRUNE: |
1209 a->sym = S; | 1209 a->sym = S; |
1210 a->type = D_CONST; | 1210 a->type = D_CONST; |
1211 a->offset = mpgetfix(n->val.u.xval); | 1211 a->offset = mpgetfix(n->val.u.xval); |
1212 break; | 1212 break; |
1213 case CTSTR: | 1213 case CTSTR: |
1214 datagostring(n->val.u.sval, a); | 1214 datagostring(n->val.u.sval, a); |
1215 break; | 1215 break; |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 naddr(&n2, a, 1); | 2249 naddr(&n2, a, 1); |
2250 goto yes; | 2250 goto yes; |
2251 | 2251 |
2252 yes: | 2252 yes: |
2253 return 1; | 2253 return 1; |
2254 | 2254 |
2255 no: | 2255 no: |
2256 sudoclean(); | 2256 sudoclean(); |
2257 return 0; | 2257 return 0; |
2258 } | 2258 } |
LEFT | RIGHT |