self.result(),
self.value,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
class ImagNode(AtomicExprNode):
self.result(),
self.value,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
+
class NameNode(AtomicExprNode):
namespace,
self.interned_cname,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
+
elif entry.is_local and False:
# control flow not good enough yet
assigned = entry.scope.control_flow.get_state((entry.name, 'initalized'), self.pos)
if assigned is False:
error(self.pos, "local variable '%s' referenced before assignment" % entry.name)
elif not Options.init_local_none and assigned is None:
- code.putln('if (%s == 0) { PyErr_SetString(PyExc_UnboundLocalError, "%s"); %s }' % (entry.cname, entry.name, code.error_goto(self.pos)))
+ code.putln('if (%s == 0) { PyErr_SetString(PyExc_UnboundLocalError, "%s"); %s }' %
+ (entry.cname, entry.name, code.error_goto(self.pos)))
entry.scope.control_flow.set_state(self.pos, (entry.name, 'initalized'), True)
def generate_assignment_code(self, rhs, code):
self.result(),
self.arg.py_result(),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
+
class ImportNode(ExprNode):
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):
self.result(),
self.sequence.py_result(),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
code.putln("}")
code.putln(code.error_goto_if_PyErr(self.pos))
code.putln("break;")
code.putln("}")
+ code.put_gotref(self.result())
code.putln("}")
self.index_unsigned_parameter(),
self.result(),
code.error_goto(self.pos)))
-
+ code.put_gotref(self.result())
+
def generate_setitem_code(self, value_code, code):
if self.index.type.is_int:
function = "__Pyx_SetItemInt"
value_code,
self.index_unsigned_parameter(),
code.error_goto(self.pos)))
+ code.put_gotref(self.base.py_result())
def generate_buffer_setitem_code(self, rhs, code, op=""):
# Used from generate_assignment_code and InPlaceAssignmentNode
self.start_code(),
self.stop_code(),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
def generate_assignment_code(self, rhs, code):
self.generate_subexpr_evaluation_code(code)
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):
self.function.py_result(),
arg_code,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
elif func_type.is_cfunction:
if self.has_optional_args:
actual_nargs = len(self.args)
else:
goto_error = ""
code.putln("%s%s; %s" % (lhs, rhs, goto_error))
+ if self.type.is_pyobject and self.result():
+ code.put_gotref(self.result())
+
class GeneralCallNode(CallNode):
# General Python function call, including keyword,
self.result(),
call_code,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
class AsTupleNode(ExprNode):
self.result(),
self.arg.py_result(),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
class AttributeNode(ExprNode):
self.obj.py_result(),
self.interned_attr_cname,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
else:
# result_code contains what is needed, but we may need to insert
# a check and raise an exception
self.iterator.result(),
rhs.py_result(),
code.error_goto_if_null(self.iterator.result(), self.pos)))
+ code.put_gotref(self.iterator.result())
rhs.generate_disposal_code(code)
for i in range(len(self.args)):
item = self.unpacked_items[i]
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)
self.result(),
len(self.args),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
for i in range(len(self.args)):
arg = self.args[i]
if not arg.result_in_temp():
(self.result(),
0,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
self.loop.generate_execution_code(code)
def annotate(self, code):
"%s = PyDict_New(); %s" % (
self.result(),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
for item in self.key_value_pairs:
item.generate_evaluation_code(code)
if self.type.is_pyobject:
self.cname,
self.module_name,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
class UnboundMethodNode(ExprNode):
self.function.py_result(),
self.class_cname,
code.error_goto_if_null(self.result(), self.pos)))
-
+ code.put_gotref(self.result())
class PyCFunctionNode(AtomicExprNode):
# Helper class used in the implementation of Python
self.result(),
self.pymethdef_cname,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
#-------------------------------------------------------------------
#
function,
self.operand.py_result(),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
def type_error(self):
if not self.operand.type.is_error:
self.operand2.py_result(),
extra_args,
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
else:
if self.is_temp:
self.generate_c_operation_code(code)
operand2.py_result(),
richcmp_constants[op],
code.error_goto_if_null(result_code, self.pos)))
+ code.put_gotref(result_code)
else:
type1 = operand1.type
type2 = operand2.type
function,
self.arg.result(),
code.error_goto_if_null(self.result(), self.pos)))
+ code.put_gotref(self.result())
class CoerceFromPyTypeNode(CoercionNode):
self.result(),
rhs,
code.error_goto_if(self.type.error_condition(self.result()), self.pos)))
+ if self.type.is_pyobject:
+ code.put_gotref(self.result())
class CoerceToBooleanNode(CoercionNode):
self.temp,
item.cname,
code.error_goto_if_null(self.temp, item.pos)))
+ code.put_gotref(self.temp) #TODO: Is this right?
code.putln('if (PyObject_SetAttrString(%s, "%s", %s) < 0) %s' % (
Naming.module_cname,
item.name,
func,
arg.hdr_cname,
code.error_goto_if_null(arg.entry.cname, arg.pos)))
+ code.put_gotref(arg.entry.cname)
else:
error(arg.pos,
"Cannot convert argument of type '%s' to Python object"
else:
code.putln("else if (unlikely(Py_TYPE(%s)->tp_dictoffset != 0)) {" % self_arg)
err = code.error_goto_if_null(self.func_node.result(), self.pos)
+ code.put_gotref(self.func_node.result())
# need to get attribute manually--scope would return cdef method
code.putln("%s = PyObject_GetAttr(%s, %s); %s" % (self.func_node.result(), self_arg, self.py_func.interned_attr_cname, err))
# It appears that this type is not anywhere exposed in the Python/C API
def as_cclass(self):
"""
- Return this node as if it were declared as an extension class"
+ Return this node as if it were declared as an extension class
"""
bases = self.classobj.bases.args
if len(bases) == 0:
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.dup.generate_disposal_code(code)
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)