self.result(),
self.value,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
-class ImagNode(AtomicExprNode):
+class ImagNode(AtomicNewTempExprNode):
# Imaginary number literal
#
# value float imaginary part
self.module_name.py_result(),
name_list_code,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
-class IteratorNode(ExprNode):
+class IteratorNode(NewTempExprNode):
# Used as part of for statement implementation.
+ #
+ # allocate_counter_temp/release_counter_temp needs to be called
+ # by parent (ForInStatNode)
+ #
# Implements result = iter(sequence)
#
# sequence ExprNode
self.sequence.py_result(),
self.result()))
code.putln("} else {")
- code.putln("%s = -1; %s = PyObject_GetIter(%s); %s" % (
- self.counter.result(),
- self.result(),
- self.sequence.py_result(),
- code.error_goto_if_null(self.result(), self.pos)))
- code.put_gotref(self.result())
+ if is_builtin_sequence:
+ code.putln(
+ 'PyErr_SetString(PyExc_TypeError, "\'NoneType\' object is not iterable"); %s' %
+ code.error_goto(self.pos))
+ else:
+ code.putln("%s = -1; %s = PyObject_GetIter(%s); %s" % (
+ self.counter_cname,
+ self.result(),
+ self.sequence.py_result(),
+ code.error_goto_if_null(self.result(), self.pos)))
++ code.put_gotref(self.result())
code.putln("}")
self.stop.py_result(),
self.step.py_result(),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
-class CallNode(ExprNode):
+class CallNode(NewTempExprNode):
def gil_check(self, env):
# Make sure we're not in a nogil environment
if env.nogil:
item.result(),
typecast(item.ctype(), py_object_type, unpack_code),
code.error_goto_if_null(item.result(), self.pos)))
+ code.put_gotref(item.result())
value_node = self.coerced_unpacked_items[i]
value_node.generate_evaluation_code(code)
- self.args[i].generate_assignment_code(value_node, code)
code.put_error_if_neg(self.pos,
"__Pyx_EndUnpack(%s)" % (
self.iterator.py_result()))
self.function.py_result(),
self.class_cname,
code.error_goto_if_null(self.result(), self.pos)))
-
+ code.put_gotref(self.result())
-class PyCFunctionNode(AtomicExprNode):
+class PyCFunctionNode(AtomicNewTempExprNode):
# Helper class used in the implementation of Python
# class definitions. Constructs a PyCFunction object
# from a PyMethodDef struct.
self.rhs.py_result(),
extra,
code.error_goto_if_null(self.result_value.py_result(), self.pos)))
+ code.put_gotref(self.result_value.result())
self.result_value.generate_evaluation_code(code) # May be a type check...
self.rhs.generate_disposal_code(code)
+ self.rhs.free_temps(code)
self.dup.generate_disposal_code(code)
+ self.dup.free_temps(code)
self.lhs.generate_assignment_code(self.result_value, code)
else:
c_op = self.operator
for var in Naming.exc_save_vars:
code.put_xdecref_clear(var, py_object_type)
code.put_goto(try_end_label)
+ if code.label_used(try_return_label):
+ code.put_label(try_return_label)
+ for var in Naming.exc_save_vars:
+ code.put_xdecref_clear(var, py_object_type)
+ code.put_goto(old_return_label)
code.put_label(our_error_label)
code.put_var_xdecrefs_clear(self.cleanup_list)
+ for temp_name, type in temps_to_clean_up:
+ code.put_xdecref_clear(temp_name, type)
for except_clause in self.except_clauses:
except_clause.generate_handling_code(code, except_end_label)
self.module.py_result(),
cname,
code.error_goto_if_null(self.item.result(), self.pos)))
+ code.put_gotref(self.item.result())
target.generate_assignment_code(self.item, code)
self.module.generate_disposal_code(code)
+ self.module.free_temps(code)
# Must resolve, try entire hierarchy
pattern = "visit_%s"
mro = inspect.getmro(cls)
+ handler_method = None
for mro_cls in mro:
- try:
+ if hasattr(self, pattern % mro_cls.__name__):
handler_method = getattr(self, pattern % mro_cls.__name__)
break
- except AttributeError:
- pass
- else:
+ if handler_method is None:
print type(self), type(obj)
- if hasattr(self, 'access_path'):
+ if hasattr(self, 'access_path') and self.access_path:
print self.access_path
- print self.access_path[-1][0].pos
- print self.access_path[-1][0].__dict__
- raise RuntimeError("Visitor does not accept object: %s" % (obj,))
+ if self.access_path:
+ print self.access_path[-1][0].pos
+ print self.access_path[-1][0].__dict__
+ raise RuntimeError("Visitor does not accept object: %s" % obj)
#print "Caching " + cls.__name__
self.dispatch_table[cls] = handler_method
return handler_method(obj)