Commit cde600a1 authored by Stefan Behnel's avatar Stefan Behnel

fix FlattenInListTransform for the trivial case

parent d304d225
...@@ -114,7 +114,7 @@ class Context: ...@@ -114,7 +114,7 @@ class Context:
_specific_post_parse, _specific_post_parse,
InterpretCompilerDirectives(self, self.pragma_overrides), InterpretCompilerDirectives(self, self.pragma_overrides),
_align_function_definitions, _align_function_definitions,
# FlattenInListTransform(), FlattenInListTransform(),
WithTransform(self), WithTransform(self),
DecoratorTransform(self), DecoratorTransform(self),
AnalyseDeclarationsTransform(self), AnalyseDeclarationsTransform(self),
......
...@@ -311,27 +311,33 @@ class FlattenInListTransform(Visitor.VisitorTransform): ...@@ -311,27 +311,33 @@ class FlattenInListTransform(Visitor.VisitorTransform):
args = node.operand2.args args = node.operand2.args
if len(args) == 0: if len(args) == 0:
return ExprNodes.BoolNode(pos = node.pos, value = node.operator == 'not_in') return ExprNodes.BoolNode(pos = node.pos, value = node.operator == 'not_in')
if node.operand1.is_temp or node.operand1.is_simple():
lhs = node.operand1
else: else:
lhs = ExprNodes.PersistentNode(node.operand1, len(args)) # FIXME: allocate temp for evaluated node.operand1
conds = [] return node
for arg in args:
cond = ExprNodes.PrimaryCmpNode( conds = []
pos = node.pos, for arg in args:
operand1 = lhs, cond = ExprNodes.PrimaryCmpNode(
operator = eq_or_neq, pos = node.pos,
operand2 = arg, operand1 = lhs,
cascade = None) operator = eq_or_neq,
conds.append(ExprNodes.TypecastNode( operand2 = arg,
pos = node.pos, cascade = None)
operand = cond, conds.append(ExprNodes.TypecastNode(
type = PyrexTypes.c_bint_type)) pos = node.pos,
def concat(left, right): operand = cond,
return ExprNodes.BoolBinopNode( type = PyrexTypes.c_bint_type))
pos = node.pos, def concat(left, right):
operator = conjunction, return ExprNodes.BoolBinopNode(
operand1 = left, pos = node.pos,
operand2 = right) operator = conjunction,
return reduce(concat, conds) operand1 = left,
operand2 = right)
return reduce(concat, conds)
else: else:
return node return node
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment