Commit 878d8413 authored by Stefan Behnel's avatar Stefan Behnel

type inference for builtin/extension types

parent d98a76b0
...@@ -1073,7 +1073,7 @@ class NameNode(AtomicExprNode): ...@@ -1073,7 +1073,7 @@ class NameNode(AtomicExprNode):
self.name == self.entry.type.name: self.name == self.entry.type.name:
# Unfortunately the type attribute of type objects # Unfortunately the type attribute of type objects
# is used for the pointer to the type they represent. # is used for the pointer to the type they represent.
return self.entry.type # type_type return type_type
else: else:
return self.entry.type return self.entry.type
...@@ -2400,19 +2400,22 @@ class SimpleCallNode(CallNode): ...@@ -2400,19 +2400,22 @@ class SimpleCallNode(CallNode):
return self.function.type_dependencies(env) return self.function.type_dependencies(env)
def infer_type(self, env): def infer_type(self, env):
func_type = self.function.infer_type(env) function = self.function
func_type = function.infer_type(env)
if func_type.is_ptr: if func_type.is_ptr:
func_type = func_type.base_type func_type = func_type.base_type
if func_type.is_cfunction: if func_type.is_cfunction:
return func_type.return_type return func_type.return_type
elif func_type.is_extension_type: elif func_type is type_type:
return func_type if function.is_name and function.entry and function.entry.type:
elif func_type.is_builtin_type and \ result_type = function.entry.type
func_type.name in Builtin.types_that_construct_their_instance: if result_type.is_extension_type:
return func_type return result_type
else: elif result_type.is_builtin_type:
return py_object_type if function.entry.name in Builtin.types_that_construct_their_instance:
return result_type
return py_object_type
def analyse_as_type(self, env): def analyse_as_type(self, env):
attr = self.function.as_cython_attribute() attr = self.function.as_cython_attribute()
if attr == 'pointer': if attr == 'pointer':
......
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