Mercurial > hg > index.cgi
comparison lwasm/lwasm.c @ 249:1f1a28b797e1
Add trap for divide by zero in expression library
Added a trap for division by zero in the expression library and adjusted
lwasm to use it and report division by zero errors instead of crashing with
a cryptic "arithmetic exception" or even more mysterious "floating point
exception".
author | William Astle <lost@l-w.ca> |
---|---|
date | Fri, 25 Jan 2013 21:48:01 -0700 |
parents | d0e9dbe9afbe |
children | bc25269d96bc |
comparison
equal
deleted
inserted
replaced
248:891bab942b5a | 249:1f1a28b797e1 |
---|---|
40 } | 40 } |
41 | 41 |
42 int lwasm_expr_exportval(asmstate_t *as, lw_expr_t expr) | 42 int lwasm_expr_exportval(asmstate_t *as, lw_expr_t expr) |
43 { | 43 { |
44 return 0; | 44 return 0; |
45 } | |
46 | |
47 void lwasm_dividezero(void *priv) | |
48 { | |
49 asmstate_t *as = (asmstate_t *)priv; | |
50 lwasm_register_error(as, as -> cl, "Division by zero"); | |
45 } | 51 } |
46 | 52 |
47 lw_expr_t lwasm_evaluate_var(char *var, void *priv) | 53 lw_expr_t lwasm_evaluate_var(char *var, void *priv) |
48 { | 54 { |
49 asmstate_t *as = (asmstate_t *)priv; | 55 asmstate_t *as = (asmstate_t *)priv; |