IntNode() value set in tree transformations must be string, not plain int
authorStefan Behnel <scoder@users.berlios.de>
Thu, 11 Jun 2009 15:32:32 +0000 (17:32 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 11 Jun 2009 15:32:32 +0000 (17:32 +0200)
Cython/Compiler/Optimize.py

index 2f5936c5c9d22290cd6760359f8986e8e103c942..315d857256298857bac8431313ee54bd50850089 100644 (file)
@@ -148,13 +148,16 @@ class IterationTransform(Visitor.VisitorTransform):
             # nothing we can do here, I guess
             return node
 
-        temp = UtilNodes.LetRefNode(ExprNodes.IntNode(enumerate_function.pos, value='0',
-                                                      type=counter_type))
+        temp = UtilNodes.LetRefNode(ExprNodes.IntNode(enumerate_function.pos,
+                                                      value='0',
+                                                      type=counter_type,
+                                                      constant_result=0))
         inc_expression = ExprNodes.AddNode(
             enumerate_function.pos,
             operand1 = temp,
             operand2 = ExprNodes.IntNode(node.pos, value='1',
-                                         type=counter_type),
+                                         type=counter_type,
+                                         constant_result=1),
             operator = '+',
             type = counter_type,
             is_temp = counter_type.is_pyobject
@@ -190,7 +193,8 @@ class IterationTransform(Visitor.VisitorTransform):
         if len(args) < 3:
             step_pos = range_function.pos
             step_value = 1
-            step = ExprNodes.IntNode(step_pos, value=1)
+            step = ExprNodes.IntNode(step_pos, value='1',
+                                     constant_result=1)
         else:
             step = args[2]
             step_pos = step.pos
@@ -202,7 +206,8 @@ class IterationTransform(Visitor.VisitorTransform):
                 # will lead to an error elsewhere
                 return node
             if not isinstance(step, ExprNodes.IntNode):
-                step = ExprNodes.IntNode(step_pos, value=step_value)
+                step = ExprNodes.IntNode(step_pos, value=str(step_value),
+                                         constant_result=step_value)
 
         if step_value < 0:
             step.value = -step_value
@@ -213,7 +218,8 @@ class IterationTransform(Visitor.VisitorTransform):
             relation2 = '<'
 
         if len(args) == 1:
-            bound1 = ExprNodes.IntNode(range_function.pos, value=0)
+            bound1 = ExprNodes.IntNode(range_function.pos, value='0',
+                                       constant_result=0)
             bound2 = args[0].coerce_to_integer(self.current_scope)
         else:
             bound1 = args[0].coerce_to_integer(self.current_scope)
@@ -350,7 +356,8 @@ class IterationTransform(Visitor.VisitorTransform):
             Nodes.SingleAssignmentNode(
                 pos = node.pos,
                 lhs = pos_temp,
-                rhs = ExprNodes.IntNode(node.pos, value=0)),
+                rhs = ExprNodes.IntNode(node.pos, value='0',
+                                        constant_result=0)),
             Nodes.WhileStatNode(
                 pos = node.pos,
                 condition = ExprNodes.SimpleCallNode(