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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
0a6c138d
Commit
0a6c138d
authored
Nov 18, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backed out class closures patch - breaks CPython regression testing
parent
e7cd2180
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
28 deletions
+17
-28
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+14
-21
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-6
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-1
No files found.
Cython/Compiler/Nodes.py
View file @
0a6c138d
...
...
@@ -1177,7 +1177,7 @@ class FuncDefNode(StatNode, BlockNode):
def
create_local_scope
(
self
,
env
):
genv
=
env
while
genv
.
is_py_class_scope
or
genv
.
is_c_class_scope
:
genv
=
g
env
.
outer_scope
genv
=
env
.
outer_scope
if
self
.
needs_closure
:
lenv
=
ClosureScope
(
name
=
self
.
entry
.
name
,
outer_scope
=
genv
,
...
...
@@ -1255,15 +1255,11 @@ class FuncDefNode(StatNode, BlockNode):
self
.
generate_function_header
(
code
,
with_pymethdef
=
with_pymethdef
)
# ----- Local variable declarations
# Find function scope
cenv
=
env
while
cenv
.
is_py_class_scope
or
cenv
.
is_c_class_scope
:
cenv
=
cenv
.
outer_scope
if
lenv
.
is_closure_scope
:
code
.
put
(
lenv
.
scope_class
.
type
.
declaration_code
(
Naming
.
cur_scope_cname
))
code
.
putln
(
";"
)
elif
c
env
.
is_closure_scope
:
code
.
put
(
c
env
.
scope_class
.
type
.
declaration_code
(
Naming
.
outer_scope_cname
))
elif
env
.
is_closure_scope
:
code
.
put
(
env
.
scope_class
.
type
.
declaration_code
(
Naming
.
outer_scope_cname
))
code
.
putln
(
";"
)
self
.
generate_argument_declarations
(
lenv
,
code
)
for
entry
in
lenv
.
var_entries
:
...
...
@@ -1314,14 +1310,14 @@ class FuncDefNode(StatNode, BlockNode):
code
.
putln
(
"}"
)
code
.
put_gotref
(
Naming
.
cur_scope_cname
)
# Note that it is unsafe to decref the scope at this point.
if
c
env
.
is_closure_scope
:
if
env
.
is_closure_scope
:
code
.
putln
(
"%s = (%s)%s;"
%
(
outer_scope_cname
,
c
env
.
scope_class
.
type
.
declaration_code
(
''
),
env
.
scope_class
.
type
.
declaration_code
(
''
),
Naming
.
self_cname
))
if
self
.
needs_closure
:
# inner closures own a reference to their outer parent
code
.
put_incref
(
outer_scope_cname
,
c
env
.
scope_class
.
type
)
code
.
put_incref
(
outer_scope_cname
,
env
.
scope_class
.
type
)
code
.
put_giveref
(
outer_scope_cname
)
# ----- Trace function call
if
profile
:
...
...
@@ -2215,21 +2211,18 @@ class DefNode(FuncDefNode):
def
synthesize_assignment_node
(
self
,
env
):
import
ExprNodes
genv
=
env
while
genv
.
is_py_class_scope
or
genv
.
is_c_class_scope
:
genv
=
genv
.
outer_scope
if
env
.
is_py_class_scope
:
rhs
=
ExprNodes
.
PyCFunctionNode
(
self
.
pos
,
pymethdef_cname
=
self
.
entry
.
pymethdef_cname
)
if
not
self
.
is_staticmethod
and
not
self
.
is_classmethod
:
rhs
.
binding
=
True
if
g
env
.
is_closure_scope
:
elif
env
.
is_closure_scope
:
rhs
=
ExprNodes
.
InnerFunctionNode
(
self
.
pos
,
pymethdef_cname
=
self
.
entry
.
pymethdef_cname
)
else
:
rhs
=
ExprNodes
.
PyCFunctionNode
(
self
.
pos
,
pymethdef_cname
=
self
.
entry
.
pymethdef_cname
,
binding
=
env
.
directives
[
'binding'
])
if
env
.
is_py_class_scope
:
if
not
self
.
is_staticmethod
and
not
self
.
is_classmethod
:
rhs
.
binding
=
True
self
.
assmt
=
SingleAssignmentNode
(
self
.
pos
,
lhs
=
ExprNodes
.
NameNode
(
self
.
pos
,
name
=
self
.
name
),
rhs
=
rhs
)
...
...
@@ -3009,8 +3002,8 @@ class PyClassDefNode(ClassDefNode):
def
create_scope
(
self
,
env
):
genv
=
env
while
genv
.
is_py_class_scope
or
g
env
.
is_c_class_scope
:
genv
=
g
env
.
outer_scope
while
env
.
is_py_class_scope
or
env
.
is_c_class_scope
:
env
=
env
.
outer_scope
cenv
=
self
.
scope
=
PyClassScope
(
name
=
self
.
name
,
outer_scope
=
genv
)
return
cenv
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
0a6c138d
...
...
@@ -1327,15 +1327,11 @@ class CreateClosureClasses(CythonTransform):
class_scope
=
entry
.
type
.
scope
class_scope
.
is_internal
=
True
class_scope
.
directives
=
{
'final'
:
True
}
cscope
=
node
.
entry
.
scope
while
cscope
.
is_py_class_scope
or
cscope
.
is_c_class_scope
:
cscope
=
cscope
.
outer_scope
if
cscope
.
is_closure_scope
:
if
node
.
entry
.
scope
.
is_closure_scope
:
class_scope
.
declare_var
(
pos
=
node
.
pos
,
name
=
Naming
.
outer_scope_cname
,
# this could conflict?
cname
=
Naming
.
outer_scope_cname
,
type
=
c
scope
.
scope_class
.
type
,
type
=
node
.
entry
.
scope
.
scope_class
.
type
,
is_cdef
=
True
)
entries
=
func_scope
.
entries
.
items
()
entries
.
sort
()
...
...
Cython/Compiler/Parsing.py
View file @
0a6c138d
...
...
@@ -1740,7 +1740,7 @@ def p_statement(s, ctx, first_statement = 0):
s
.
level
=
ctx
.
level
return
p_def_statement
(
s
,
decorators
)
elif
s
.
sy
==
'class'
:
if
ctx
.
level
not
in
(
'module'
,
'function'
,
'class'
)
:
if
ctx
.
level
!=
'module'
:
s
.
error
(
"class definition not allowed here"
)
return
p_class_statement
(
s
,
decorators
)
elif
s
.
sy
==
'include'
:
...
...
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