lang: ast, interfaces: Plumb in the Graph sig changes and value pointers
The Graph signature changes are needed for future function work, and it also fits in nicely with the need for storing the value pointer for each function node. These are used to later extract values during the Output stage. Sam deserves all of the credit for realizing both of these points and convincing me to make the change! It worked out great, cheers! Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -128,22 +128,6 @@ func (obj *ExprAny) Unify() ([]Invariant, error) {
|
||||
return invariants, nil
|
||||
}
|
||||
|
||||
// Graph returns the reactive function graph which is expressed by this node. It
|
||||
// includes any vertices produced by this node, and the appropriate edges to any
|
||||
// vertices that are produced by its children. Nodes which fulfill the Expr
|
||||
// interface directly produce vertices (and possible children) where as nodes
|
||||
// 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, error) {
|
||||
graph, err := pgraph.NewGraph("any")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
graph.AddVertex(obj)
|
||||
return graph, nil
|
||||
}
|
||||
|
||||
// Func returns the reactive stream of values that this expression produces.
|
||||
func (obj *ExprAny) Func() (Func, error) {
|
||||
// // XXX: this could be a list too, so improve this code or improve the subgraph code...
|
||||
@@ -154,6 +138,27 @@ func (obj *ExprAny) Func() (Func, error) {
|
||||
return nil, fmt.Errorf("programming error using ExprAny") // this should not be called
|
||||
}
|
||||
|
||||
// Graph returns the reactive function graph which is expressed by this node. It
|
||||
// includes any vertices produced by this node, and the appropriate edges to any
|
||||
// vertices that are produced by its children. Nodes which fulfill the Expr
|
||||
// interface directly produce vertices (and possible children) where as nodes
|
||||
// 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) {
|
||||
graph, err := pgraph.NewGraph("any")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
function, err := obj.Func()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
graph.AddVertex(function)
|
||||
|
||||
return graph, function, nil
|
||||
}
|
||||
|
||||
// SetValue here is a no-op, because algorithmically when this is called from
|
||||
// the func engine, the child elements (the list elements) will have had this
|
||||
// done to them first, and as such when we try and retrieve the set value from
|
||||
|
||||
Reference in New Issue
Block a user