Problem with negated literals while compiling generated C file on 32bits systems fixed
authorlbessard
Tue, 08 Apr 2008 18:21:37 +0200
changeset 118 d4cf7ea933a4
parent 117 550c3bd2df16
child 119 4cbf71106b66
Problem with negated literals while compiling generated C file on 32bits systems fixed
absyntax/absyntax.def
stage1_2/iec.y
stage4/generate_c/generate_c_base.cc
stage4/generate_iec/generate_iec.cc
--- a/absyntax/absyntax.def	Thu Apr 03 18:29:14 2008 +0200
+++ b/absyntax/absyntax.def	Tue Apr 08 18:21:37 2008 +0200
@@ -81,6 +81,8 @@
 SYM_TOKEN(signed_real_c)
 */
 
+SYM_REF1(neg_literal_c, exp)
+
 SYM_REF2(numeric_literal_c, type, value)
 SYM_REF2(integer_literal_c, type, value)
 SYM_REF2(real_literal_c, type, value)
--- a/stage1_2/iec.y	Thu Apr 03 18:29:14 2008 +0200
+++ b/stage1_2/iec.y	Tue Apr 08 18:21:37 2008 +0200
@@ -1687,7 +1687,7 @@
 signed_integer:
   integer
 | '+' integer   {$$ = $2;}
-| '-' integer	{$$ = new neg_expression_c($2, locloc(@$));}
+| '-' integer	{$$ = new neg_literal_c($2, locloc(@$));}
 ;
 
 /* a helper symbol for non_negative_constant */
@@ -1716,7 +1716,7 @@
 signed_real:
   real
 | '+' real	{$$ = $2;}
-| '-' real	{$$ = new neg_expression_c($2, locloc(@2));}
+| '-' real	{$$ = new neg_literal_c($2, locloc(@2));}
 ;
 
 /* helper symbol for non_negative_real_literal */
--- a/stage4/generate_c/generate_c_base.cc	Thu Apr 03 18:29:14 2008 +0200
+++ b/stage4/generate_c/generate_c_base.cc	Tue Apr 08 18:21:37 2008 +0200
@@ -254,6 +254,12 @@
     void *visit(boolean_true_c *symbol) {s4o.print("TRUE"); return NULL;}
     void *visit(boolean_false_c *symbol) {s4o.print("FALSE"); return NULL;}
 
+    void *visit(neg_literal_c *symbol) {
+      s4o.print("-");
+      symbol->exp->accept(*this);
+      return NULL;
+    }
+
     void *visit(neg_expression_c *symbol) {
       s4o.print("-");
       symbol->exp->accept(*this);
--- a/stage4/generate_iec/generate_iec.cc	Thu Apr 03 18:29:14 2008 +0200
+++ b/stage4/generate_iec/generate_iec.cc	Tue Apr 08 18:21:37 2008 +0200
@@ -154,6 +154,8 @@
 void *visit(real_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
 void *visit(bit_string_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
 void *visit(boolean_literal_c *symbol) {return print_literal(symbol->type, symbol->value);}
+void *visit(neg_literal_c *symbol) {return print_unary_expression(symbol->exp, "-");}
+
 
 /* helper class for boolean_literal_c */
 void *visit(boolean_true_c *symbol) {s4o.print(/*"TRUE"*/"1"); return NULL;}