comparison lwlib/lw_expr.h @ 366:433dbc18fb41

Make byte overflow detection for 8 bit immediate not fail with COM operator This is a horrible hack. Add a quick and dirty context to expression parsing so that it knows whether an 8 bit or 16 bit complement is required. The 8 bit complement will just discard anything above bit 7. When returning an operator back with lwasm_whichop(), the result will still be "COM" which should allow other things to keep working as they already do. This does prevent byte overflows when the complement operator is used, however, and since those were introduced, there were problems building Nitros9 among other things. This fix allows Nitros9 to build again.
author William Astle <lost@l-w.ca>
date Tue, 02 Jun 2015 20:58:14 -0600
parents 4130ffdeb5c8
children 8e25147c2aa8
comparison
equal deleted inserted replaced
365:3f8abaac214c 366:433dbc18fb41
49 lw_expr_oper_bwxor, // bitwise xor 49 lw_expr_oper_bwxor, // bitwise xor
50 lw_expr_oper_and, // boolean and 50 lw_expr_oper_and, // boolean and
51 lw_expr_oper_or, // boolean or 51 lw_expr_oper_or, // boolean or
52 lw_expr_oper_neg, // unary negation, 2's complement 52 lw_expr_oper_neg, // unary negation, 2's complement
53 lw_expr_oper_com, // unary 1's complement 53 lw_expr_oper_com, // unary 1's complement
54 lw_expr_oper_com8, // 8 bit complement
54 lw_expr_oper_none = 0 55 lw_expr_oper_none = 0
55 }; 56 };
56 57
57 #ifdef ___lw_expr_c_seen___ 58 #ifdef ___lw_expr_c_seen___
58 59
109 110
110 typedef int lw_expr_testfn_t(lw_expr_t e, void *priv); 111 typedef int lw_expr_testfn_t(lw_expr_t e, void *priv);
111 112
112 extern int lw_expr_operandcount(lw_expr_t e); 113 extern int lw_expr_operandcount(lw_expr_t e);
113 114
115 extern void lw_expr_setwidth(int w);
116
114 // run a function on all terms in an expression; if the function 117 // run a function on all terms in an expression; if the function
115 // returns non-zero for any term, return non-zero, else return 118 // returns non-zero for any term, return non-zero, else return
116 // zero 119 // zero
117 extern int lw_expr_testterms(lw_expr_t e, lw_expr_testfn_t *fn, void *priv); 120 extern int lw_expr_testterms(lw_expr_t e, lw_expr_testfn_t *fn, void *priv);
118 121