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
77a4a0e7
Commit
77a4a0e7
authored
Sep 15, 2011
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LocalsExprNode
parent
cf7f1e1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-6
No files found.
Cython/Compiler/ExprNodes.py
View file @
77a4a0e7
...
@@ -5454,6 +5454,16 @@ class GlobalsExprNode(AtomicExprNode):
...
@@ -5454,6 +5454,16 @@ class GlobalsExprNode(AtomicExprNode):
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
result
())
class
LocalsExprNode
(
DictNode
):
def
__init__
(
self
,
pos
,
env
):
local_vars
=
[
var
.
name
for
var
in
env
.
entries
.
values
()
if
var
.
name
]
items
=
[
DictItemNode
(
pos
,
key
=
IdentifierStringNode
(
pos
,
value
=
var
),
value
=
NameNode
(
pos
,
name
=
var
,
allow_null
=
True
))
for
var
in
local_vars
]
DictNode
.
__init__
(
self
,
pos
,
key_value_pairs
=
items
,
exclude_null_values
=
True
)
#-------------------------------------------------------------------
#-------------------------------------------------------------------
#
#
# Unary operator nodes
# Unary operator nodes
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
77a4a0e7
...
@@ -2258,7 +2258,6 @@ class TransformBuiltinMethods(EnvTransform):
...
@@ -2258,7 +2258,6 @@ class TransformBuiltinMethods(EnvTransform):
# not the builtin
# not the builtin
return
node
return
node
pos
=
node
.
pos
pos
=
node
.
pos
local_names
=
[
var
.
name
for
var
in
lenv
.
entries
.
values
()
if
var
.
name
]
if
func_name
in
(
'locals'
,
'vars'
):
if
func_name
in
(
'locals'
,
'vars'
):
if
func_name
==
'locals'
and
len
(
node
.
args
)
>
0
:
if
func_name
==
'locals'
and
len
(
node
.
args
)
>
0
:
error
(
self
.
pos
,
"Builtin 'locals()' called with wrong number of args, expected 0, got %d"
error
(
self
.
pos
,
"Builtin 'locals()' called with wrong number of args, expected 0, got %d"
...
@@ -2270,11 +2269,7 @@ class TransformBuiltinMethods(EnvTransform):
...
@@ -2270,11 +2269,7 @@ class TransformBuiltinMethods(EnvTransform):
%
len
(
node
.
args
))
%
len
(
node
.
args
))
if
len
(
node
.
args
)
>
0
:
if
len
(
node
.
args
)
>
0
:
return
node
# nothing to do
return
node
# nothing to do
items
=
[
ExprNodes
.
DictItemNode
(
pos
,
return
ExprNodes
.
LocalsExprNode
(
pos
,
lenv
)
key
=
ExprNodes
.
IdentifierStringNode
(
pos
,
value
=
var
),
value
=
ExprNodes
.
NameNode
(
pos
,
name
=
var
,
allow_null
=
True
))
for
var
in
local_names
]
return
ExprNodes
.
DictNode
(
pos
,
key_value_pairs
=
items
,
exclude_null_values
=
True
)
else
:
# dir()
else
:
# dir()
if
len
(
node
.
args
)
>
1
:
if
len
(
node
.
args
)
>
1
:
error
(
self
.
pos
,
"Builtin 'dir()' called with wrong number of args, expected 0-1, got %d"
error
(
self
.
pos
,
"Builtin 'dir()' called with wrong number of args, expected 0-1, got %d"
...
@@ -2282,6 +2277,7 @@ class TransformBuiltinMethods(EnvTransform):
...
@@ -2282,6 +2277,7 @@ class TransformBuiltinMethods(EnvTransform):
if
len
(
node
.
args
)
>
0
:
if
len
(
node
.
args
)
>
0
:
# optimised in Builtin.py
# optimised in Builtin.py
return
node
return
node
local_names
=
[
var
.
name
for
var
in
lenv
.
entries
.
values
()
if
var
.
name
]
items
=
[
ExprNodes
.
IdentifierStringNode
(
pos
,
value
=
var
)
items
=
[
ExprNodes
.
IdentifierStringNode
(
pos
,
value
=
var
)
for
var
in
local_names
]
for
var
in
local_names
]
return
ExprNodes
.
ListNode
(
pos
,
args
=
items
)
return
ExprNodes
.
ListNode
(
pos
,
args
=
items
)
...
...
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