Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
c6050b86
Commit
c6050b86
authored
Jul 02, 2009
by
Danilo Freitas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
same work
parent
28601834
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
16 deletions
+23
-16
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+20
-12
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-4
No files found.
Cython/Compiler/ExprNodes.py
View file @
c6050b86
...
...
@@ -1080,20 +1080,27 @@ class ImagNode(AtomicNewTempExprNode):
class
NewExprNode
(
AtomicExprNode
):
type
=
PyrexTypes
.
cpp_class_type
subexpr
=
[
'
arg
s'
]
subexpr
=
[
'
cppclas
s'
]
def
analyse_types
(
self
,
env
):
for
arg
in
self
.
args
:
arg
.
analyse_types
(
env
)
def
coerce_to
(
self
,
type
,
env
):
return
self
entry
=
env
.
lookup
(
self
.
cppclass
)
if
entry
is
None
or
not
entry
.
is_cpp_class
:
error
(
self
.
pos
,
"new operator can only be applied to a C++ class"
)
return
constructor
=
entry
.
scope
.
lookup
(
'__init__'
)
if
constructor
is
None
:
print
"no constructor declared"
# create one
self
.
class_entry
=
entry
self
.
type
=
PyrexTypes
.
CPtrType
(
entry
.
type
)
self
.
func_type
=
constructor
.
type
def
generate_result_code
(
self
,
code
):
pass
def
calculate_result_code
(
self
):
return
"
"
return
"
new "
+
self
.
entry
.
cname
class
NameNode
(
AtomicExprNode
):
...
...
@@ -2377,10 +2384,11 @@ class SimpleCallNode(CallNode):
if
func_type
.
is_cpp_class
:
for
arg
in
self
.
args
:
arg
.
analyse_types
(
env
)
entry
=
env
.
lookup
(
self
.
function
.
name
)
entry
=
env
.
lookup
(
self
.
function
.
cppclass
)
print
entry
.
name
self
.
type
=
entry
.
type
self
.
function
.
type
=
PyrexTypes
.
CppMethodType
(
self
.
function
.
name
,
PyrexTypes
.
CppClassType
(
self
.
function
.
name
,
"cppclass"
,
self
.
function
.
type
=
PyrexTypes
.
CppMethodType
(
self
.
function
.
cppclass
,
PyrexTypes
.
CppClassType
(
self
.
function
.
cppclass
,
"cppclass"
,
entry
.
scope
,
0
,
entry
.
cname
,
[]),
self
.
args
)
self
.
analyse_c_function_call
(
env
)
else
:
...
...
Cython/Compiler/Parsing.py
View file @
c6050b86
...
...
@@ -292,12 +292,11 @@ def p_power(s):
return
n1
def
p_new_expr
(
s
):
# s.systring == 'new'
# s.systring == 'new'
.
pos
=
s
.
position
()
s
.
next
()
args
=
p_simple_expr_list
(
s
)
return
ExprNodes
.
NewExprNode
(
pos
,
args
=
args
)
name
=
p_ident
(
s
)
return
p_call
(
s
,
ExprNodes
.
NewExprNode
(
pos
,
cppclass
=
name
))
#trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment