Mercurial > hg > index.cgi
comparison lwasm/insn_rel.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 | d0e9dbe9afbe |
children | 35d4213e6657 |
comparison
equal
deleted
inserted
replaced
369:682524a1f32f | 370:8764142b3192 |
---|---|
78 | 78 |
79 t = lwasm_parse_expr(as, p); | 79 t = lwasm_parse_expr(as, p); |
80 | 80 |
81 if (!t) | 81 if (!t) |
82 { | 82 { |
83 lwasm_register_error(as, l, "Bad operand"); | 83 lwasm_register_error(as, l, E_OPERAND_BAD); |
84 return; | 84 return; |
85 } | 85 } |
86 | 86 |
87 // if we know the length of the instruction, set it now | 87 // if we know the length of the instruction, set it now |
88 if (l -> lint == 8) | 88 if (l -> lint == 8) |
220 e = lwasm_fetch_expr(l, 0); | 220 e = lwasm_fetch_expr(l, 0); |
221 if (l -> lint == 8) | 221 if (l -> lint == 8) |
222 { | 222 { |
223 if (!lw_expr_istype(e, lw_expr_type_int)) | 223 if (!lw_expr_istype(e, lw_expr_type_int)) |
224 { | 224 { |
225 lwasm_register_error(as, l, "Illegal non-constant expression"); | 225 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST); |
226 return; | 226 return; |
227 } | 227 } |
228 | 228 |
229 offs = lw_expr_intval(e); | 229 offs = lw_expr_intval(e); |
230 if (l -> lint == 8 && (offs < -128 || offs > 127)) | 230 if (l -> lint == 8 && (offs < -128 || offs > 127)) |
231 { | 231 { |
232 lwasm_register_error(as, l, "Byte overflow"); | 232 lwasm_register_error(as, l, E_BYTE_OVERFLOW); |
233 return; | 233 return; |
234 } | 234 } |
235 | 235 |
236 | 236 |
237 lwasm_emitop(l, instab[l -> insn].ops[2]); | 237 lwasm_emitop(l, instab[l -> insn].ops[2]); |