comparison lwasm/lwasm.c @ 210:5d969517db74

Added condundefzero pragma Added pragma condundefzero to allow the assembler to treat symbols that are undefined in a conditional expression as if their value had been set to zero.
author William Astle <lost@l-w.ca>
date Sat, 09 Jun 2012 16:25:19 -0600
parents 52d9dd71f555
children 6f2e18f1fe67
comparison
equal deleted inserted replaced
209:52d9dd71f555 210:5d969517db74
53 53
54 s = lookup_symbol(as, as -> cl, var); 54 s = lookup_symbol(as, as -> cl, var);
55 if (s) 55 if (s)
56 { 56 {
57 e = lw_expr_build(lw_expr_type_special, lwasm_expr_syment, s); 57 e = lw_expr_build(lw_expr_type_special, lwasm_expr_syment, s);
58 return e;
59 }
60
61 if (as -> undefzero)
62 {
63 e = lw_expr_build(lw_expr_type_int, 0);
58 return e; 64 return e;
59 } 65 }
60 66
61 // undefined here is undefied unless output is object 67 // undefined here is undefied unless output is object
62 if (as -> output_format != OUTPUT_OBJ) 68 if (as -> output_format != OUTPUT_OBJ)
894 { 900 {
895 lwasm_register_error(as, as -> cl, "Bad expression"); 901 lwasm_register_error(as, as -> cl, "Bad expression");
896 return NULL; 902 return NULL;
897 } 903 }
898 904
905 /* handle condundefzero */
906 if (CURPRAGMA(as -> cl, PRAGMA_CONDUNDEFZERO))
907 {
908 as -> undefzero = 1;
909 lwasm_reduce_expr(as, e);
910 as -> undefzero = 0;
911 }
912
899 /* we need to simplify the expression here */ 913 /* we need to simplify the expression here */
900 debug_message(as, 250, "Doing interim reductions"); 914 debug_message(as, 250, "Doing interim reductions");
901 lwasm_interim_reduce(as); 915 lwasm_interim_reduce(as);
902 debug_message(as, 250, "COND EXPR: %s", lw_expr_print(e)); 916 debug_message(as, 250, "COND EXPR: %s", lw_expr_print(e));
903 debug_message(as, 250, "Reducing expression"); 917 debug_message(as, 250, "Reducing expression");