comparison dmd/AsmStatement.d @ 176:fa9a71a9f5a8

Moved all the mutable globals to Global
author korDen
date Sun, 10 Oct 2010 05:22:45 +0400
parents af724d3510d7
children e3afd1303184
comparison
equal deleted inserted replaced
175:94b6033c07f3 176:fa9a71a9f5a8
88 fd.inlineAsm = 1; 88 fd.inlineAsm = 1;
89 89
90 if (!tokens) 90 if (!tokens)
91 return null; 91 return null;
92 92
93 memset(&asmstate, 0, asmstate.sizeof); 93 auto asmstate = &global.asmstate;
94
95 memset(asmstate, 0, (*asmstate).sizeof);
94 96
95 asmstate.statement = this; 97 asmstate.statement = this;
96 asmstate.sc = sc; 98 asmstate.sc = sc;
97 99
98 static if (false) { 100 static if (false) {
120 cod3_set386(); 122 cod3_set386();
121 } 123 }
122 124
123 asmstate.loc = loc; 125 asmstate.loc = loc;
124 126
125 asmtok = tokens; 127 global.asmtok = tokens;
126 asm_token_trans(asmtok); 128 asm_token_trans(global.asmtok);
127 if (setjmp(asmstate.env)) 129 if (setjmp(asmstate.env))
128 { 130 {
129 asmtok = null; // skip rest of line 131 global.asmtok = null; // skip rest of line
130 tok_value = TOK.TOKeof; 132 global.tok_value = TOK.TOKeof;
131 exit(EXIT_FAILURE); 133 exit(EXIT_FAILURE);
132 goto AFTER_EMIT; 134 goto AFTER_EMIT;
133 } 135 }
134 136
135 switch (cast(int)tok_value) 137 switch (cast(int)global.tok_value)
136 { 138 {
137 case ASMTK.ASMTKnaked: 139 case ASMTK.ASMTKnaked:
138 naked = true; 140 naked = true;
139 sc.func.naked = true; 141 sc.func.naked = true;
140 asm_token(); 142 asm_token();
169 case TOK.TOKout: 171 case TOK.TOKout:
170 o = asm_op_lookup(Id.___out.toChars()); 172 o = asm_op_lookup(Id.___out.toChars());
171 goto Lopcode; 173 goto Lopcode;
172 174
173 case TOK.TOKidentifier: 175 case TOK.TOKidentifier:
174 o = asm_op_lookup(asmtok.ident.toChars()); 176 o = asm_op_lookup(global.asmtok.ident.toChars());
175 if (!o) 177 if (!o)
176 goto OPCODE_EXPECTED; 178 goto OPCODE_EXPECTED;
177 179
178 Lopcode: 180 Lopcode:
179 asmstate.ucItype = o.usNumops & IT.ITMASK; 181 asmstate.ucItype = o.usNumops & IT.ITMASK;
194 break; 196 break;
195 } 197 }
196 } 198 }
197 // get the first part of an expr 199 // get the first part of an expr
198 o1 = asm_cond_exp(); 200 o1 = asm_cond_exp();
199 if (tok_value == TOK.TOKcomma) 201 if (global.tok_value == TOK.TOKcomma)
200 { 202 {
201 asm_token(); 203 asm_token();
202 o2 = asm_cond_exp(); 204 o2 = asm_cond_exp();
203 } 205 }
204 if (tok_value == TOK.TOKcomma) 206 if (global.tok_value == TOK.TOKcomma)
205 { 207 {
206 asm_token(); 208 asm_token();
207 o3 = asm_cond_exp(); 209 o3 = asm_cond_exp();
208 } 210 }
209 // match opcode and operands in ptrntab to verify legal inst and 211 // match opcode and operands in ptrntab to verify legal inst and
247 asmcode = asm_emit(loc, usNumops, ptb, o, o1, o2, o3); 249 asmcode = asm_emit(loc, usNumops, ptb, o, o1, o2, o3);
248 break; 250 break;
249 251
250 default: 252 default:
251 OPCODE_EXPECTED: 253 OPCODE_EXPECTED:
252 asmerr(ASMERRMSGS.EM_opcode_exp, asmtok.toChars()); // assembler opcode expected 254 asmerr(ASMERRMSGS.EM_opcode_exp, global.asmtok.toChars()); // assembler opcode expected
253 break; 255 break;
254 } 256 }
255 257
256 AFTER_EMIT: 258 AFTER_EMIT:
257 opnd_free(o1); 259 opnd_free(o1);
258 opnd_free(o2); 260 opnd_free(o2);
259 opnd_free(o3); 261 opnd_free(o3);
260 o1 = o2 = o3 = null; 262 o1 = o2 = o3 = null;
261 263
262 if (tok_value != TOK.TOKeof) 264 if (global.tok_value != TOK.TOKeof)
263 asmerr(ASMERRMSGS.EM_eol); // end of line expected 265 asmerr(ASMERRMSGS.EM_eol); // end of line expected
264 266
265 //return asmstate.bReturnax; 267 //return asmstate.bReturnax;
266 return this; 268 return this;
267 } 269 }