Remove NewScope method from vm.Scope
This commit is contained in:
parent
ec443899c3
commit
4cde5179f1
@ -177,11 +177,7 @@ func FunctionFromGraph(g *gg.Graph, scope Scope) (Function, error) {
|
||||
|
||||
if edgeVal.Graph != nil {
|
||||
|
||||
opFromGraph, err := FunctionFromGraph(
|
||||
edgeVal.Graph,
|
||||
scope.NewScope(),
|
||||
)
|
||||
|
||||
opFromGraph, err := FunctionFromGraph(edgeVal.Graph, scope)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("compiling graph to operation: %w", err)
|
||||
}
|
||||
@ -198,7 +194,7 @@ func FunctionFromGraph(g *gg.Graph, scope Scope) (Function, error) {
|
||||
})), nil
|
||||
}
|
||||
|
||||
// the edgeVal is not an Function at compile time, and so
|
||||
// the edgeVal is not a Function at compile time, and so
|
||||
// it must become one at runtime. We must resolve edgeVal to an
|
||||
// edgeFn as well (edgeEdgeFn), and then at runtime that is
|
||||
// given the inArg and (hopefully) the resultant Function is
|
||||
@ -217,8 +213,7 @@ func FunctionFromGraph(g *gg.Graph, scope Scope) (Function, error) {
|
||||
if runtimeEdgeVal.Graph != nil {
|
||||
|
||||
runtimeFn, err := FunctionFromGraph(
|
||||
runtimeEdgeVal.Graph,
|
||||
scope.NewScope(),
|
||||
runtimeEdgeVal.Graph, scope,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
@ -9,10 +9,6 @@ type Scope interface {
|
||||
|
||||
// Resolve accepts a name and returns an Value.
|
||||
Resolve(string) (Value, error)
|
||||
|
||||
// NewScope returns a new Scope which sub-operations within this Scope
|
||||
// should use for themselves.
|
||||
NewScope() Scope
|
||||
}
|
||||
|
||||
// ScopeMap implements the Scope interface.
|
||||
@ -33,11 +29,6 @@ func (m ScopeMap) Resolve(name string) (Value, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// NewScope returns the ScopeMap as-is.
|
||||
func (m ScopeMap) NewScope() Scope {
|
||||
return m
|
||||
}
|
||||
|
||||
type scopeWith struct {
|
||||
Scope // parent
|
||||
name string
|
||||
|
2
vm/vm.go
2
vm/vm.go
@ -114,7 +114,7 @@ func EvaluateSource(opSrc io.Reader, input Value, scope Scope) (Value, error) {
|
||||
return Value{}, errors.New("value must be a graph")
|
||||
}
|
||||
|
||||
fn, err := FunctionFromGraph(v.Value.Graph, scope.NewScope())
|
||||
fn, err := FunctionFromGraph(v.Value.Graph, scope)
|
||||
if err != nil {
|
||||
return Value{}, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user