Commit a5e1b89a authored by Robert Bradshaw's avatar Robert Bradshaw

disable builtin functions that conflict with type names

add dummy py_index for cdef arrays so subexprs valid
parent 24e2d102
...@@ -1056,6 +1056,7 @@ class IndexNode(ExprNode): ...@@ -1056,6 +1056,7 @@ class IndexNode(ExprNode):
self.type = py_object_type self.type = py_object_type
self.is_temp = 1 self.is_temp = 1
else: else:
self.py_index = CloneNode(self.index) # so that it exists for subexpr processing
if self.base.type.is_ptr or self.base.type.is_array: if self.base.type.is_ptr or self.base.type.is_array:
self.type = self.base.type.base_type self.type = self.base.type.base_type
else: else:
......
...@@ -457,11 +457,13 @@ class BuiltinScope(Scope): ...@@ -457,11 +457,13 @@ class BuiltinScope(Scope):
entry.is_builtin = 1 entry.is_builtin = 1
return entry return entry
# TODO: built in functions conflict with built in types of same name...
builtin_functions = { builtin_functions = {
"hasattr": ["PyObject_HasAttrString", c_int_type, (py_object_type, c_char_ptr_type)], "hasattr": ["PyObject_HasAttrString", c_int_type, (py_object_type, c_char_ptr_type)],
"cmp": ["PyObject_Compare", c_int_type, (py_object_type, py_object_type), None, True], "cmp": ["PyObject_Compare", c_int_type, (py_object_type, py_object_type), None, True],
"repr": ["PyObject_Repr", py_object_type, (py_object_type, ), 0], "repr": ["PyObject_Repr", py_object_type, (py_object_type, ), 0],
"str": ["PyObject_Str", py_object_type, (py_object_type, ), 0], # "str": ["PyObject_Str", py_object_type, (py_object_type, ), 0],
"unicode": ["PyObject_Unicode", py_object_type, (py_object_type, ), 0], "unicode": ["PyObject_Unicode", py_object_type, (py_object_type, ), 0],
"isinstance": ["PyObject_IsInstance", c_int_type, (py_object_type, py_object_type), -1], "isinstance": ["PyObject_IsInstance", c_int_type, (py_object_type, py_object_type), -1],
"hash": ["PyObject_Hash", c_long_type, (py_object_type, ), -1, True], "hash": ["PyObject_Hash", c_long_type, (py_object_type, ), -1, True],
...@@ -469,6 +471,17 @@ class BuiltinScope(Scope): ...@@ -469,6 +471,17 @@ class BuiltinScope(Scope):
"len": ["PyObject_Size", c_py_ssize_t_type, (py_object_type, ), -1], "len": ["PyObject_Size", c_py_ssize_t_type, (py_object_type, ), -1],
"dir": ["PyObject_Dir", py_object_type, (py_object_type, ), 0], "dir": ["PyObject_Dir", py_object_type, (py_object_type, ), 0],
"iter": ["PyObject_GetIter", py_object_type, (py_object_type, ), 0], "iter": ["PyObject_GetIter", py_object_type, (py_object_type, ), 0],
"abs": ["PyNumber_Absolute", py_object_type, (py_object_type, ), 0],
"divmod": ["PyNumber_Divmod", py_object_type, (py_object_type, py_object_type), 0],
"pow": ["PyNumber_Power", py_object_type, (py_object_type, py_object_type, py_object_type), 0],
# "int": ["PyNumber_Int", py_object_type, (py_object_type, ), 0],
# "long": ["PyNumber_Long", py_object_type, (py_object_type, ), 0],
# "float": ["PyNumber_Float", py_object_type, (py_object_type, ), 0],
# "list": ["PyNumber_List", py_object_type, (py_object_type, ), 0],
# "tuple": ["PySequence_Tuple", py_object_type, (py_object_type, ), 0],
} }
class ModuleScope(Scope): class ModuleScope(Scope):
......
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