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
237396d2
Commit
237396d2
authored
Nov 29, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgraded NewTempExprNode, converted PrimaryCmpNode to it
parent
ca5a8207
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
16 deletions
+46
-16
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+36
-16
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+10
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
237396d2
...
@@ -569,8 +569,22 @@ class ExprNode(Node):
...
@@ -569,8 +569,22 @@ class ExprNode(Node):
return
None
return
None
class
RemoveAllocateTemps
(
type
):
def
__init__
(
cls
,
name
,
bases
,
dct
):
super
(
RemoveAllocateTemps
,
cls
).
__init__
(
name
,
bases
,
dct
)
def
noop
(
self
,
env
):
pass
setattr
(
cls
,
'allocate_temps'
,
noop
)
setattr
(
cls
,
'allocate_temp'
,
noop
)
setattr
(
cls
,
'release_temps'
,
noop
)
setattr
(
cls
,
'release_temp'
,
noop
)
class
NewTempExprNode
(
ExprNode
):
class
NewTempExprNode
(
ExprNode
):
backwards_compatible_result
=
None
backwards_compatible_result
=
None
# Do not enable this unless you are trying to make all ExprNodes
# NewTempExprNodes (child nodes reached via recursion may not have
# transferred).
# __metaclass__ = RemoveAllocateTemps
def
result
(
self
):
def
result
(
self
):
if
self
.
is_temp
:
if
self
.
is_temp
:
...
@@ -598,6 +612,22 @@ class NewTempExprNode(ExprNode):
...
@@ -598,6 +612,22 @@ class NewTempExprNode(ExprNode):
else
:
else
:
self
.
release_subexpr_temps
(
env
)
self
.
release_subexpr_temps
(
env
)
def
allocate_temp_result
(
self
,
code
):
type
=
self
.
type
if
not
type
.
is_void
:
if
type
.
is_pyobject
:
type
=
PyrexTypes
.
py_object_type
if
self
.
backwards_compatible_result
:
self
.
temp_code
=
self
.
backwards_compatible_result
else
:
self
.
temp_code
=
code
.
funcstate
.
allocate_temp
(
type
,
manage_ref
=
True
)
else
:
self
.
temp_code
=
None
def
release_temp_result
(
self
,
code
):
code
.
funcstate
.
release_temp
(
self
.
temp_code
)
def
generate_evaluation_code
(
self
,
code
):
def
generate_evaluation_code
(
self
,
code
):
code
.
mark_pos
(
self
.
pos
)
code
.
mark_pos
(
self
.
pos
)
...
@@ -607,17 +637,7 @@ class NewTempExprNode(ExprNode):
...
@@ -607,17 +637,7 @@ class NewTempExprNode(ExprNode):
self
.
generate_subexpr_evaluation_code
(
code
)
self
.
generate_subexpr_evaluation_code
(
code
)
if
self
.
is_temp
:
if
self
.
is_temp
:
type
=
self
.
type
self
.
allocate_temp_result
(
code
)
if
not
type
.
is_void
:
if
type
.
is_pyobject
:
type
=
PyrexTypes
.
py_object_type
if
self
.
backwards_compatible_result
:
self
.
temp_code
=
self
.
backwards_compatible_result
else
:
self
.
temp_code
=
code
.
funcstate
.
allocate_temp
(
type
,
manage_ref
=
True
)
else
:
self
.
temp_code
=
None
self
.
generate_result_code
(
code
)
self
.
generate_result_code
(
code
)
if
self
.
is_temp
:
if
self
.
is_temp
:
...
@@ -628,7 +648,7 @@ class NewTempExprNode(ExprNode):
...
@@ -628,7 +648,7 @@ class NewTempExprNode(ExprNode):
if
self
.
type
.
is_pyobject
:
if
self
.
type
.
is_pyobject
:
code
.
put_decref_clear
(
self
.
result
(),
self
.
ctype
())
code
.
put_decref_clear
(
self
.
result
(),
self
.
ctype
())
if
not
self
.
backwards_compatible_result
:
if
not
self
.
backwards_compatible_result
:
code
.
funcstate
.
release_temp
(
self
.
temp_
code
)
self
.
release_temp_result
(
code
)
else
:
else
:
self
.
generate_subexpr_disposal_code
(
code
)
self
.
generate_subexpr_disposal_code
(
code
)
...
@@ -641,8 +661,7 @@ class NewTempExprNode(ExprNode):
...
@@ -641,8 +661,7 @@ class NewTempExprNode(ExprNode):
else
:
else
:
self
.
generate_subexpr_disposal_code
(
code
)
self
.
generate_subexpr_disposal_code
(
code
)
# ExprNode = NewTempExprNode
class
AtomicExprNode
(
ExprNode
):
class
AtomicExprNode
(
ExprNode
):
# Abstract base class for expression nodes which have
# Abstract base class for expression nodes which have
...
@@ -4228,7 +4247,7 @@ class CmpNode:
...
@@ -4228,7 +4247,7 @@ class CmpNode:
return
op
return
op
class
PrimaryCmpNode
(
ExprNode
,
CmpNode
):
class
PrimaryCmpNode
(
NewTemp
ExprNode
,
CmpNode
):
# Non-cascaded comparison or first comparison of
# Non-cascaded comparison or first comparison of
# a cascaded sequence.
# a cascaded sequence.
#
#
...
@@ -4327,11 +4346,12 @@ class PrimaryCmpNode(ExprNode, CmpNode):
...
@@ -4327,11 +4346,12 @@ class PrimaryCmpNode(ExprNode, CmpNode):
self
.
operand1
.
result
(),
self
.
operand1
.
result
(),
self
.
c_operator
(
self
.
operator
),
self
.
c_operator
(
self
.
operator
),
self
.
operand2
.
result
())
self
.
operand2
.
result
())
def
generate_evaluation_code
(
self
,
code
):
def
generate_evaluation_code
(
self
,
code
):
self
.
operand1
.
generate_evaluation_code
(
code
)
self
.
operand1
.
generate_evaluation_code
(
code
)
self
.
operand2
.
generate_evaluation_code
(
code
)
self
.
operand2
.
generate_evaluation_code
(
code
)
if
self
.
is_temp
:
if
self
.
is_temp
:
self
.
allocate_temp_result
(
code
)
self
.
generate_operation_code
(
code
,
self
.
result
(),
self
.
generate_operation_code
(
code
,
self
.
result
(),
self
.
operand1
,
self
.
operator
,
self
.
operand2
)
self
.
operand1
,
self
.
operator
,
self
.
operand2
)
if
self
.
cascade
:
if
self
.
cascade
:
...
...
Cython/Compiler/Main.py
View file @
237396d2
...
@@ -87,6 +87,15 @@ class Context:
...
@@ -87,6 +87,15 @@ class Context:
from
Buffer
import
IntroduceBufferAuxiliaryVars
from
Buffer
import
IntroduceBufferAuxiliaryVars
from
ModuleNode
import
check_c_declarations
from
ModuleNode
import
check_c_declarations
# Temporary hack that can be used to ensure that all result_code's
# are generated at code generation time.
import
Visitor
class
ClearResultCodes
(
Visitor
.
CythonTransform
):
def
visit_ExprNode
(
self
,
node
):
self
.
visitchildren
(
node
)
node
.
result_code
=
"<cleared>"
return
node
if
pxd
:
if
pxd
:
_check_c_declarations
=
None
_check_c_declarations
=
None
_specific_post_parse
=
PxdPostParse
(
self
)
_specific_post_parse
=
PxdPostParse
(
self
)
...
@@ -118,6 +127,7 @@ class Context:
...
@@ -118,6 +127,7 @@ class Context:
DictIterTransform
(),
DictIterTransform
(),
SwitchTransform
(),
SwitchTransform
(),
FinalOptimizePhase
(
self
),
FinalOptimizePhase
(
self
),
# ClearResultCodes(self),
# SpecialFunctions(self),
# SpecialFunctions(self),
# CreateClosureClasses(context),
# CreateClosureClasses(context),
]
]
...
...
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