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
9f4e7b8f
Commit
9f4e7b8f
authored
Mar 28, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ClassNode to new temps
parent
6b9f9037
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
9 deletions
+15
-9
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+6
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+6
-4
No files found.
Cython/Compiler/Code.py
View file @
9f4e7b8f
...
...
@@ -687,14 +687,18 @@ class CCodeWriter(object):
# generation (labels and temps state etc.)
# globalstate GlobalState contains state global for a C file (input file info,
# utility code, declared constants etc.)
# emit_linenums boolean whether or not to write #line pragmas
# emit_linenums boolean whether or not to write #line pragmas
#
# pyclass_stack list used during recursive code generation to pass information
# about the current class one is in
def __init__(self, create_from=None, buffer=None, copy_formatting=False, emit_linenums=None):
if buffer is None: buffer = StringIOTree()
self.buffer = buffer
self.marker = None
self.last_marker_line = 0
self.source_desc = ""
self.pyclass_stack = []
self.funcstate = None
self.level = 0
...
...
Cython/Compiler/ExprNodes.py
View file @
9f4e7b8f
...
...
@@ -3567,7 +3567,7 @@ class DictItemNode(ExprNode):
return
iter
([
self
.
key
,
self
.
value
])
class
ClassNode
(
ExprNode
):
class
ClassNode
(
NewTemp
ExprNode
):
# Helper class used in the implementation of Python
# class definitions. Constructs a class object given
# a name, tuple of bases and class dictionary.
...
...
@@ -3615,7 +3615,6 @@ class UnboundMethodNode(NewTempExprNode):
# class definitions. Constructs an unbound method
# object from a class and a function.
#
# class_cname string C var holding the class object
# function ExprNode Function object
subexprs
=
[
'function'
]
...
...
@@ -3628,11 +3627,12 @@ class UnboundMethodNode(NewTempExprNode):
gil_message
=
"Constructing an unbound method"
def
generate_result_code
(
self
,
code
):
class_cname
=
code
.
pyclass_stack
[
-
1
].
classobj
.
result
()
code
.
putln
(
"%s = PyMethod_New(%s, 0, %s); %s"
%
(
self
.
result
(),
self
.
function
.
py_result
(),
self
.
class_cname
,
class_cname
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
py_result
())
...
...
Cython/Compiler/Nodes.py
View file @
9f4e7b8f
...
...
@@ -1781,13 +1781,12 @@ class DefNode(FuncDefNode):
self
.
analyse_default_values
(
env
)
if
env
.
is_py_class_scope
:
self
.
synthesize_assignment_node
(
env
)
def
synthesize_assignment_node
(
self
,
env
):
import
ExprNodes
self
.
assmt
=
SingleAssignmentNode
(
self
.
pos
,
lhs
=
ExprNodes
.
NameNode
(
self
.
pos
,
name
=
self
.
name
),
rhs
=
ExprNodes
.
UnboundMethodNode
(
self
.
pos
,
class_cname
=
env
.
class_obj_cname
,
function
=
ExprNodes
.
PyCFunctionNode
(
self
.
pos
,
pymethdef_cname
=
self
.
entry
.
pymethdef_cname
)))
self
.
assmt
.
analyse_declarations
(
env
)
...
...
@@ -2530,8 +2529,7 @@ class PyClassDefNode(ClassDefNode):
self
.
classobj
.
analyse_expressions
(
env
)
genv
=
env
.
global_scope
()
cenv
=
self
.
scope
cenv
.
class_dict_cname
=
self
.
dict
.
result
()
cenv
.
namespace_cname
=
cenv
.
class_obj_cname
=
self
.
classobj
.
result
()
cenv
.
class_dict_cname
=
self
.
dict
.
result
()
# TODO newtemps -- move to code generation
self
.
body
.
analyse_expressions
(
cenv
)
self
.
target
.
analyse_target_expression
(
env
,
self
.
classobj
)
self
.
dict
.
release_temp
(
env
)
...
...
@@ -2542,12 +2540,16 @@ class PyClassDefNode(ClassDefNode):
self
.
body
.
generate_function_definitions
(
self
.
scope
,
code
)
def
generate_execution_code
(
self
,
code
):
code
.
pyclass_stack
.
append
(
self
)
cenv
=
self
.
scope
self
.
dict
.
generate_evaluation_code
(
code
)
self
.
classobj
.
generate_evaluation_code
(
code
)
cenv
.
namespace_cname
=
cenv
.
class_obj_cname
=
self
.
classobj
.
result
()
self
.
body
.
generate_execution_code
(
code
)
self
.
target
.
generate_assignment_code
(
self
.
classobj
,
code
)
self
.
dict
.
generate_disposal_code
(
code
)
self
.
dict
.
free_temps
(
code
)
code
.
pyclass_stack
.
pop
()
class
CClassDefNode
(
ClassDefNode
):
...
...
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