comparison lwasm/insn_indexed.c @ 370:8764142b3192

Convert internal error/warning handling framework to a new unified system Replace the ad hoc error and warning handling with a new system that codifies the errors with specific codes. This makes it possible in the future for error numbers to be used for testing and other purposes. It also makes sure the error strings themselves are consistent. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 22 Jun 2015 18:49:38 -0600
parents c6d2a1f54e0c
children 35d4213e6657
comparison
equal deleted inserted replaced
369:682524a1f32f 370:8764142b3192
167 // extended indir 167 // extended indir
168 l -> pb = 0x9f; 168 l -> pb = 0x9f;
169 e = lwasm_parse_expr(as, p); 169 e = lwasm_parse_expr(as, p);
170 if (!e || **p != ']') 170 if (!e || **p != ']')
171 { 171 {
172 lwasm_register_error(as, l, "Bad operand"); 172 lwasm_register_error(as, l, E_OPERAND_BAD);
173 return; 173 return;
174 } 174 }
175 lwasm_save_expr(l, 0, e); 175 lwasm_save_expr(l, 0, e);
176 176
177 (*p)++; 177 (*p)++;
197 197
198 // now we have to evaluate the expression 198 // now we have to evaluate the expression
199 e = lwasm_parse_expr(as, p); 199 e = lwasm_parse_expr(as, p);
200 if (!e) 200 if (!e)
201 { 201 {
202 lwasm_register_error(as, l, "Bad operand"); 202 lwasm_register_error(as, l, E_OPERAND_BAD);
203 return; 203 return;
204 } 204 }
205 lwasm_save_expr(l, 0, e); 205 lwasm_save_expr(l, 0, e);
206 206
207 // now look for a comma; if not present, explode 207 // now look for a comma; if not present, explode
208 if (*(*p)++ != ',') 208 if (*(*p)++ != ',')
209 { 209 {
210 lwasm_register_error(as, l, "Bad operand"); 210 lwasm_register_error(as, l, E_OPERAND_BAD);
211 return; 211 return;
212 } 212 }
213 213
214 // now get the register 214 // now get the register
215 rn = lwasm_lookupreg3(reglist, p); 215 rn = lwasm_lookupreg3(reglist, p);
216 if (rn < 0) 216 if (rn < 0)
217 { 217 {
218 lwasm_register_error(as, l, "Bad register"); 218 lwasm_register_error(as, l, E_REGISTER_BAD);
219 return; 219 return;
220 } 220 }
221 221
222 if (indir) 222 if (indir)
223 { 223 {
224 if (**p != ']') 224 if (**p != ']')
225 { 225 {
226 lwasm_register_error(as, l, "Bad operand"); 226 lwasm_register_error(as, l, E_OPERAND_BAD);
227 return; 227 return;
228 } 228 }
229 else 229 else
230 (*p)++; 230 (*p)++;
231 } 231 }
248 // nnnn,W is only 16 bit (or 0 bit) 248 // nnnn,W is only 16 bit (or 0 bit)
249 if (rn == 4) 249 if (rn == 4)
250 { 250 {
251 if (l -> lint == 1) 251 if (l -> lint == 1)
252 { 252 {
253 lwasm_register_error(as, l, "n,W cannot be 8 bit"); 253 lwasm_register_error(as, l, E_NW_8);
254 return; 254 return;
255 } 255 }
256 256
257 if (l -> lint == 2) 257 if (l -> lint == 2)
258 { 258 {
586 int i; 586 int i;
587 e = lwasm_fetch_expr(l, 0); 587 e = lwasm_fetch_expr(l, 0);
588 i = lw_expr_intval(e); 588 i = lw_expr_intval(e);
589 if (i < -128 || i > 127) 589 if (i < -128 || i > 127)
590 { 590 {
591 lwasm_register_error(as, l, "Byte overflow"); 591 lwasm_register_error(as, l, E_BYTE_OVERFLOW);
592 } 592 }
593 } 593 }
594 594
595 lwasm_emitop(l, instab[l -> insn].ops[0]); 595 lwasm_emitop(l, instab[l -> insn].ops[0]);
596 lwasm_emitop(l, l -> pb); 596 lwasm_emitop(l, l -> pb);