Commit 22e2b0e0 authored by Danilo Freitas's avatar Danilo Freitas

Workint with 'new' operator

parent ebd8a5d2
......@@ -1077,6 +1077,26 @@ class ImagNode(AtomicNewTempExprNode):
self.c99_complex = code.globalstate.directives['c99_complex']
class NewExprNode(AtomicExprNode):
type = PyrexTypes.cpp_class_type
subexpr = ['arg']
def analyse_types(self, env):
entry = env.lookup(self.arg.name)
if not entry:
self.type = PyrexTypes.error_type
return
def coerce_to(self, type, env):
return self
def generate_result_code(self, code):
pass
def calculate_result_code(self):
pass
class NameNode(AtomicExprNode):
# Reference to a local or global variable name.
......
......@@ -279,6 +279,8 @@ def p_yield_expression(s):
#power: atom trailer* ('**' factor)*
def p_power(s):
if s.systring == 'new':
return p_new_expr(s)
n1 = p_atom(s)
while s.sy in ('(', '[', '.'):
n1 = p_trailer(s, n1)
......@@ -289,6 +291,14 @@ def p_power(s):
n1 = ExprNodes.binop_node(pos, '**', n1, n2)
return n1
def p_new_expr(s):
# s.systring == 'new'
pos = s.position()
s.next()
args = p_simple_expr_list(s)
return ExprNodes.NewExprNode(pos, arg = args[0])
#trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
def p_trailer(s, node1):
......
......@@ -1586,6 +1586,8 @@ c_anon_enum_type = CAnonEnumType(-1, 1)
c_py_buffer_type = CStructOrUnionType("Py_buffer", "struct", None, 1, "Py_buffer")
c_py_buffer_ptr_type = CPtrType(c_py_buffer_type)
cpp_class_type = CppClassType("cpp_class", "cppclass", None, 1, "cpp_class", [])
error_type = ErrorType()
unspecified_type = UnspecifiedType()
......
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