diff --git a/lang/interfaces/ast.go b/lang/interfaces/ast.go index 2ac0812f..cfba6ad4 100644 --- a/lang/interfaces/ast.go +++ b/lang/interfaces/ast.go @@ -107,7 +107,7 @@ type Expr interface { Ordering(map[string]Node) (*pgraph.Graph, map[Node]string, error) // SetScope sets the scope here and propagates it downwards. - SetScope(*Scope) error + SetScope(*Scope, map[string]Expr) error // SetType sets the type definitively, and errors if it is incompatible. SetType(*types.Type) error @@ -122,8 +122,9 @@ type Expr interface { Unify() ([]Invariant, error) // Graph returns the reactive function graph expressed by this node. It - // also returns the function for this node. - Graph() (*pgraph.Graph, Func, error) + // takes in the environment of any functions in scope. It also returns + // the function for this node. + Graph(env map[string]Func) (*pgraph.Graph, Func, error) // SetValue stores the result of the last computation of this expression // node. diff --git a/lang/interfaces/structs.go b/lang/interfaces/structs.go index b57399e1..9a0ecdee 100644 --- a/lang/interfaces/structs.go +++ b/lang/interfaces/structs.go @@ -76,7 +76,7 @@ func (obj *ExprAny) Ordering(produces map[string]Node) (*pgraph.Graph, map[Node] // SetScope does nothing for this struct, because it has no child nodes, and it // does not need to know about the parent scope. -func (obj *ExprAny) SetScope(*Scope) error { return nil } +func (obj *ExprAny) SetScope(*Scope, map[string]Expr) error { return nil } // SetType is used to set the type of this expression once it is known. This // usually happens during type unification, but it can also happen during @@ -145,7 +145,7 @@ func (obj *ExprAny) Func() (Func, error) { // that fulfill the Stmt interface do not produces vertices, where as their // children might. This returns a graph with a single vertex (itself) in it, and // the edges from all of the child graphs to this. -func (obj *ExprAny) Graph() (*pgraph.Graph, Func, error) { +func (obj *ExprAny) Graph(env map[string]Func) (*pgraph.Graph, Func, error) { graph, err := pgraph.NewGraph("any") if err != nil { return nil, nil, err