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 {
|
if edgeVal.Graph != nil {
|
||||||
|
|
||||||
opFromGraph, err := FunctionFromGraph(
|
opFromGraph, err := FunctionFromGraph(edgeVal.Graph, scope)
|
||||||
edgeVal.Graph,
|
|
||||||
scope.NewScope(),
|
|
||||||
)
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("compiling graph to operation: %w", err)
|
return nil, fmt.Errorf("compiling graph to operation: %w", err)
|
||||||
}
|
}
|
||||||
@ -198,7 +194,7 @@ func FunctionFromGraph(g *gg.Graph, scope Scope) (Function, error) {
|
|||||||
})), nil
|
})), 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
|
// it must become one at runtime. We must resolve edgeVal to an
|
||||||
// edgeFn as well (edgeEdgeFn), and then at runtime that is
|
// edgeFn as well (edgeEdgeFn), and then at runtime that is
|
||||||
// given the inArg and (hopefully) the resultant Function 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 {
|
if runtimeEdgeVal.Graph != nil {
|
||||||
|
|
||||||
runtimeFn, err := FunctionFromGraph(
|
runtimeFn, err := FunctionFromGraph(
|
||||||
runtimeEdgeVal.Graph,
|
runtimeEdgeVal.Graph, scope,
|
||||||
scope.NewScope(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,10 +9,6 @@ type Scope interface {
|
|||||||
|
|
||||||
// Resolve accepts a name and returns an Value.
|
// Resolve accepts a name and returns an Value.
|
||||||
Resolve(string) (Value, error)
|
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.
|
// ScopeMap implements the Scope interface.
|
||||||
@ -33,11 +29,6 @@ func (m ScopeMap) Resolve(name string) (Value, error) {
|
|||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewScope returns the ScopeMap as-is.
|
|
||||||
func (m ScopeMap) NewScope() Scope {
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
type scopeWith struct {
|
type scopeWith struct {
|
||||||
Scope // parent
|
Scope // parent
|
||||||
name string
|
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")
|
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 {
|
if err != nil {
|
||||||
return Value{}, err
|
return Value{}, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user