|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package vm |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"errors" |
|
|
|
|
"fmt" |
|
|
|
|
|
|
|
|
|
"code.betamike.com/mediocregopher/ginger/gg" |
|
|
|
@ -79,8 +80,6 @@ func FunctionFromGraph(g *gg.Graph, scope Scope) (Function, error) { |
|
|
|
|
return edgeFn(Identity(val)), nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
name := *val.Name |
|
|
|
|
|
|
|
|
|
if val.Equal(valNameIn) { |
|
|
|
|
return edgeFn(FunctionFunc(func(inArg Value) Value { |
|
|
|
|
return inArg |
|
|
|
@ -89,15 +88,17 @@ func FunctionFromGraph(g *gg.Graph, scope Scope) (Function, error) { |
|
|
|
|
|
|
|
|
|
edgesIn := g.ValueIns(val.Value) |
|
|
|
|
|
|
|
|
|
if l := len(edgesIn); l == 0 { |
|
|
|
|
|
|
|
|
|
val, err := scope.Resolve(name) |
|
|
|
|
name := *val.Name |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
if l := len(edgesIn); l == 0 { |
|
|
|
|
resolvedVal, err := scope.Resolve(name) |
|
|
|
|
if errors.Is(err, ErrNameNotDefined) { |
|
|
|
|
return edgeFn(Identity(val)), nil |
|
|
|
|
} else if err != nil { |
|
|
|
|
return nil, fmt.Errorf("resolving name %q from the outer scope: %w", name, err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return edgeFn(Identity(val)), nil |
|
|
|
|
return edgeFn(Identity(resolvedVal)), nil |
|
|
|
|
|
|
|
|
|
} else if l != 1 { |
|
|
|
|
return nil, fmt.Errorf("resolved name %q to %d input edges, rather than one", name, l) |
|
|
|
@ -123,7 +124,6 @@ func FunctionFromGraph(g *gg.Graph, scope Scope) (Function, error) { |
|
|
|
|
return valToEdgeFn(Value{Value: ggVal}) |
|
|
|
|
}, |
|
|
|
|
func(ggEdgeVal gg.OptionalValue, inEdgeFns []edgeFn) (edgeFn, error) { |
|
|
|
|
|
|
|
|
|
if ggEdgeVal.Equal(valNameIf.Value) { |
|
|
|
|
|
|
|
|
|
if len(inEdgeFns) != 3 { |
|
|
|
|