Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
grumpy
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
grumpy
Commits
633fde8d
Commit
633fde8d
authored
Dec 29, 2016
by
Dylan Trotter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused globals param from Block.Exec().
parent
56d294f7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
8 deletions
+7
-8
compiler/expr_visitor.py
compiler/expr_visitor.py
+1
-1
compiler/stmt.py
compiler/stmt.py
+1
-1
runtime/block.go
runtime/block.go
+1
-1
runtime/block_test.go
runtime/block_test.go
+3
-4
tools/grumpc
tools/grumpc
+1
-1
No files found.
compiler/expr_visitor.py
View file @
633fde8d
...
@@ -433,7 +433,7 @@ class ExprVisitor(ast.NodeVisitor):
...
@@ -433,7 +433,7 @@ class ExprVisitor(ast.NodeVisitor):
self
.
writer
.
write
(
'return πg.NewGenerator('
self
.
writer
.
write
(
'return πg.NewGenerator('
'πBlock, πGlobals).ToObject(), nil'
)
'πBlock, πGlobals).ToObject(), nil'
)
else
:
else
:
self
.
writer
.
write
(
'return πBlock.Exec(πF
, πGlobals
)'
)
self
.
writer
.
write
(
'return πBlock.Exec(πF)'
)
else
:
else
:
assert
not
func_block
.
is_generator
assert
not
func_block
.
is_generator
self
.
writer
.
write
(
'var πE *πg.BaseException
\
n
_ = πE'
)
self
.
writer
.
write
(
'var πE *πg.BaseException
\
n
_ = πE'
)
...
...
compiler/stmt.py
View file @
633fde8d
...
@@ -122,7 +122,7 @@ class StatementVisitor(ast.NodeVisitor):
...
@@ -122,7 +122,7 @@ class StatementVisitor(ast.NodeVisitor):
self
.
writer
.
write_block
(
body_visitor
.
block
,
self
.
writer
.
write_block
(
body_visitor
.
block
,
body_visitor
.
writer
.
out
.
getvalue
())
body_visitor
.
writer
.
out
.
getvalue
())
tmpl
=
textwrap
.
dedent
(
"""
\
tmpl
=
textwrap
.
dedent
(
"""
\
\
t
return πBlock.Exec(πF
, πGlobals
)
\
t
return πBlock.Exec(πF)
}).Eval(πF, πGlobals, nil, nil)
}).Eval(πF, πGlobals, nil, nil)
if πE != nil {
if πE != nil {
\
t
return nil, πE
\
t
return nil, πE
...
...
runtime/block.go
View file @
633fde8d
...
@@ -28,7 +28,7 @@ func NewBlock(fn func(*Frame, *Object) (*Object, *BaseException)) *Block {
...
@@ -28,7 +28,7 @@ func NewBlock(fn func(*Frame, *Object) (*Object, *BaseException)) *Block {
}
}
// Exec runs b in the context of a new child frame of back.
// Exec runs b in the context of a new child frame of back.
func
(
b
*
Block
)
Exec
(
f
*
Frame
,
globals
*
Dict
)
(
*
Object
,
*
BaseException
)
{
func
(
b
*
Block
)
Exec
(
f
*
Frame
)
(
*
Object
,
*
BaseException
)
{
return
b
.
execInternal
(
f
,
nil
)
return
b
.
execInternal
(
f
,
nil
)
}
}
...
...
runtime/block_test.go
View file @
633fde8d
...
@@ -44,7 +44,7 @@ func TestBlockExecTryExcept(t *testing.T) {
...
@@ -44,7 +44,7 @@ func TestBlockExecTryExcept(t *testing.T) {
args
=
append
(
args
,
blockArgs
{
f
,
e
})
args
=
append
(
args
,
blockArgs
{
f
,
e
})
return
None
,
nil
return
None
,
nil
})
})
b
.
Exec
(
newFrame
(
nil
)
,
NewDict
()
)
b
.
Exec
(
newFrame
(
nil
))
wantExc
:=
mustCreateException
(
RuntimeErrorType
,
"foo"
)
wantExc
:=
mustCreateException
(
RuntimeErrorType
,
"foo"
)
if
len
(
args
)
!=
2
{
if
len
(
args
)
!=
2
{
t
.
Errorf
(
"called %d times, want 2"
,
len
(
args
))
t
.
Errorf
(
"called %d times, want 2"
,
len
(
args
))
...
@@ -59,16 +59,15 @@ func TestBlockExecTryExcept(t *testing.T) {
...
@@ -59,16 +59,15 @@ func TestBlockExecTryExcept(t *testing.T) {
func
TestBlockExecRaises
(
t
*
testing
.
T
)
{
func
TestBlockExecRaises
(
t
*
testing
.
T
)
{
var
f1
,
f2
*
Frame
var
f1
,
f2
*
Frame
globals
:=
NewDict
()
b1
:=
NewBlock
(
func
(
f
*
Frame
,
_
*
Object
)
(
*
Object
,
*
BaseException
)
{
b1
:=
NewBlock
(
func
(
f
*
Frame
,
_
*
Object
)
(
*
Object
,
*
BaseException
)
{
f1
=
f
f1
=
f
return
nil
,
f
.
RaiseType
(
ValueErrorType
,
"bar"
)
return
nil
,
f
.
RaiseType
(
ValueErrorType
,
"bar"
)
})
})
b2
:=
NewBlock
(
func
(
f
*
Frame
,
_
*
Object
)
(
*
Object
,
*
BaseException
)
{
b2
:=
NewBlock
(
func
(
f
*
Frame
,
_
*
Object
)
(
*
Object
,
*
BaseException
)
{
f2
=
f
f2
=
f
return
b1
.
Exec
(
f
,
globals
)
return
b1
.
Exec
(
f
)
})
})
b2
.
Exec
(
newFrame
(
nil
)
,
NewDict
()
)
b2
.
Exec
(
newFrame
(
nil
))
e
,
tb
:=
f1
.
ExcInfo
()
e
,
tb
:=
f1
.
ExcInfo
()
wantExc
:=
mustCreateException
(
ValueErrorType
,
"bar"
)
wantExc
:=
mustCreateException
(
ValueErrorType
,
"bar"
)
if
!
exceptionsAreEquivalent
(
e
,
wantExc
)
{
if
!
exceptionsAreEquivalent
(
e
,
wantExc
)
{
...
...
tools/grumpc
View file @
633fde8d
...
@@ -84,7 +84,7 @@ def main(args):
...
@@ -84,7 +84,7 @@ def main(args):
_ = πGlobals"""
))
# Suppress possible Go "declared and not used" error.
_ = πGlobals"""
))
# Suppress possible Go "declared and not used" error.
writer
.
write_block
(
mod_block
,
visitor
.
writer
.
out
.
getvalue
())
writer
.
write_block
(
mod_block
,
visitor
.
writer
.
out
.
getvalue
())
writer
.
write
(
textwrap
.
dedent
(
"""
\
writer
.
write
(
textwrap
.
dedent
(
"""
\
\
t
return πBlock.Exec(πF
, πGlobals
)
\
t
return πBlock.Exec(πF)
}
}
var Code *πg.Code"""
))
var Code *πg.Code"""
))
...
...
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