Commit 633fde8d authored by Dylan Trotter's avatar Dylan Trotter

Remove unused globals param from Block.Exec().

parent 56d294f7
...@@ -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')
......
...@@ -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("""\
\treturn πBlock.Exec(πF, πGlobals) \treturn πBlock.Exec(πF)
}).Eval(πF, πGlobals, nil, nil) }).Eval(πF, πGlobals, nil, nil)
if πE != nil { if πE != nil {
\treturn nil, πE \treturn nil, πE
......
...@@ -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)
} }
......
...@@ -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) {
......
...@@ -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("""\
\treturn πBlock.Exec(πF, πGlobals) \treturn πBlock.Exec(πF)
} }
var Code *πg.Code""")) var Code *πg.Code"""))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment