package ast
import "github.com/purpleidea/mgmt/lang/ast"
Package ast contains the structs implementing and some utility functions for interacting with the abstract syntax tree for the mcl language.
Index ¶
- Constants
- func CollectFiles(ast interfaces.Stmt) ([]string, error)
- func CopyNodeMapping(in map[string]interfaces.Node) map[string]interfaces.Node
- func FuncPrefixToFunctionsScope(prefix string) map[string]interfaces.Expr
- func MergeExprMaps(m, extra map[string]interfaces.Expr, prefix ...string) (map[string]interfaces.Expr, error)
- func ValueToExpr(val types.Value) (interfaces.Expr, error)
- func VarPrefixToVariablesScope(prefix string) map[string]interfaces.Expr
- type ExprBool
- func (obj *ExprBool) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprBool) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprBool) Copy() (interfaces.Expr, error)
- func (obj *ExprBool) Func() (interfaces.Func, error)
- func (obj *ExprBool) Graph(*interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprBool) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprBool) Init(data *interfaces.Data) error
- func (obj *ExprBool) Interpolate() (interfaces.Expr, error)
- func (obj *ExprBool) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprBool) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprBool) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprBool) SetType(typ *types.Type) error
- func (obj *ExprBool) SetValue(value types.Value) error
- func (obj *ExprBool) String() string
- func (obj *ExprBool) Type() (*types.Type, error)
- func (obj *ExprBool) Value() (types.Value, error)
- type ExprCall
- func (obj *ExprCall) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprCall) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprCall) Copy() (interfaces.Expr, error)
- func (obj *ExprCall) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprCall) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprCall) Init(data *interfaces.Data) error
- func (obj *ExprCall) Interpolate() (interfaces.Expr, error)
- func (obj *ExprCall) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprCall) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprCall) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprCall) SetType(typ *types.Type) error
- func (obj *ExprCall) SetValue(value types.Value) error
- func (obj *ExprCall) String() string
- func (obj *ExprCall) Type() (*types.Type, error)
- func (obj *ExprCall) Value() (types.Value, error)
- type ExprFloat
- func (obj *ExprFloat) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprFloat) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprFloat) Copy() (interfaces.Expr, error)
- func (obj *ExprFloat) Func() (interfaces.Func, error)
- func (obj *ExprFloat) Graph(*interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprFloat) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprFloat) Init(data *interfaces.Data) error
- func (obj *ExprFloat) Interpolate() (interfaces.Expr, error)
- func (obj *ExprFloat) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprFloat) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprFloat) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprFloat) SetType(typ *types.Type) error
- func (obj *ExprFloat) SetValue(value types.Value) error
- func (obj *ExprFloat) String() string
- func (obj *ExprFloat) Type() (*types.Type, error)
- func (obj *ExprFloat) Value() (types.Value, error)
- type ExprFunc
- func (obj *ExprFunc) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprFunc) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprFunc) Copy() (interfaces.Expr, error)
- func (obj *ExprFunc) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprFunc) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprFunc) Init(data *interfaces.Data) error
- func (obj *ExprFunc) Interpolate() (interfaces.Expr, error)
- func (obj *ExprFunc) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprFunc) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprFunc) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprFunc) SetType(typ *types.Type) error
- func (obj *ExprFunc) SetValue(value types.Value) error
- func (obj *ExprFunc) String() string
- func (obj *ExprFunc) Type() (*types.Type, error)
- func (obj *ExprFunc) Value() (types.Value, error)
- type ExprIf
- func (obj *ExprIf) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprIf) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprIf) Copy() (interfaces.Expr, error)
- func (obj *ExprIf) Func() (interfaces.Func, error)
- func (obj *ExprIf) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprIf) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprIf) Init(data *interfaces.Data) error
- func (obj *ExprIf) Interpolate() (interfaces.Expr, error)
- func (obj *ExprIf) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprIf) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprIf) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprIf) SetType(typ *types.Type) error
- func (obj *ExprIf) SetValue(value types.Value) error
- func (obj *ExprIf) String() string
- func (obj *ExprIf) Type() (*types.Type, error)
- func (obj *ExprIf) Value() (types.Value, error)
- type ExprInt
- func (obj *ExprInt) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprInt) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprInt) Copy() (interfaces.Expr, error)
- func (obj *ExprInt) Func() (interfaces.Func, error)
- func (obj *ExprInt) Graph(*interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprInt) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprInt) Init(data *interfaces.Data) error
- func (obj *ExprInt) Interpolate() (interfaces.Expr, error)
- func (obj *ExprInt) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprInt) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprInt) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprInt) SetType(typ *types.Type) error
- func (obj *ExprInt) SetValue(value types.Value) error
- func (obj *ExprInt) String() string
- func (obj *ExprInt) Type() (*types.Type, error)
- func (obj *ExprInt) Value() (types.Value, error)
- type ExprIterated
- func (obj *ExprIterated) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprIterated) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprIterated) Copy() (interfaces.Expr, error)
- func (obj *ExprIterated) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprIterated) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprIterated) Init(*interfaces.Data) error
- func (obj *ExprIterated) Interpolate() (interfaces.Expr, error)
- func (obj *ExprIterated) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprIterated) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprIterated) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprIterated) SetType(typ *types.Type) error
- func (obj *ExprIterated) SetValue(value types.Value) error
- func (obj *ExprIterated) String() string
- func (obj *ExprIterated) Type() (*types.Type, error)
- func (obj *ExprIterated) Value() (types.Value, error)
- type ExprList
- func (obj *ExprList) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprList) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprList) Copy() (interfaces.Expr, error)
- func (obj *ExprList) Func() (interfaces.Func, error)
- func (obj *ExprList) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprList) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprList) Init(data *interfaces.Data) error
- func (obj *ExprList) Interpolate() (interfaces.Expr, error)
- func (obj *ExprList) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprList) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprList) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprList) SetType(typ *types.Type) error
- func (obj *ExprList) SetValue(value types.Value) error
- func (obj *ExprList) String() string
- func (obj *ExprList) Type() (*types.Type, error)
- func (obj *ExprList) Value() (types.Value, error)
- type ExprMap
- func (obj *ExprMap) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprMap) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprMap) Copy() (interfaces.Expr, error)
- func (obj *ExprMap) Func() (interfaces.Func, error)
- func (obj *ExprMap) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprMap) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprMap) Init(data *interfaces.Data) error
- func (obj *ExprMap) Interpolate() (interfaces.Expr, error)
- func (obj *ExprMap) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprMap) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprMap) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprMap) SetType(typ *types.Type) error
- func (obj *ExprMap) SetValue(value types.Value) error
- func (obj *ExprMap) String() string
- func (obj *ExprMap) Type() (*types.Type, error)
- func (obj *ExprMap) Value() (types.Value, error)
- type ExprMapKV
- type ExprParam
- func (obj *ExprParam) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprParam) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprParam) Copy() (interfaces.Expr, error)
- func (obj *ExprParam) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprParam) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprParam) Init(*interfaces.Data) error
- func (obj *ExprParam) Interpolate() (interfaces.Expr, error)
- func (obj *ExprParam) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprParam) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprParam) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprParam) SetType(typ *types.Type) error
- func (obj *ExprParam) SetValue(value types.Value) error
- func (obj *ExprParam) String() string
- func (obj *ExprParam) Type() (*types.Type, error)
- func (obj *ExprParam) Value() (types.Value, error)
- type ExprPoly
- func (obj *ExprPoly) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprPoly) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprPoly) Copy() (interfaces.Expr, error)
- func (obj *ExprPoly) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprPoly) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprPoly) Init(data *interfaces.Data) error
- func (obj *ExprPoly) Interpolate() (interfaces.Expr, error)
- func (obj *ExprPoly) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprPoly) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprPoly) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprPoly) SetType(typ *types.Type) error
- func (obj *ExprPoly) SetValue(value types.Value) error
- func (obj *ExprPoly) String() string
- func (obj *ExprPoly) Type() (*types.Type, error)
- func (obj *ExprPoly) Value() (types.Value, error)
- type ExprSingleton
- func (obj *ExprSingleton) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprSingleton) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprSingleton) Copy() (interfaces.Expr, error)
- func (obj *ExprSingleton) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprSingleton) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprSingleton) Init(data *interfaces.Data) error
- func (obj *ExprSingleton) Interpolate() (interfaces.Expr, error)
- func (obj *ExprSingleton) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprSingleton) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprSingleton) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprSingleton) SetType(typ *types.Type) error
- func (obj *ExprSingleton) SetValue(value types.Value) error
- func (obj *ExprSingleton) String() string
- func (obj *ExprSingleton) Type() (*types.Type, error)
- func (obj *ExprSingleton) Value() (types.Value, error)
- type ExprStr
- func (obj *ExprStr) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprStr) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprStr) Copy() (interfaces.Expr, error)
- func (obj *ExprStr) Func() (interfaces.Func, error)
- func (obj *ExprStr) Graph(*interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprStr) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprStr) Init(data *interfaces.Data) error
- func (obj *ExprStr) Interpolate() (interfaces.Expr, error)
- func (obj *ExprStr) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprStr) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprStr) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprStr) SetType(typ *types.Type) error
- func (obj *ExprStr) SetValue(value types.Value) error
- func (obj *ExprStr) String() string
- func (obj *ExprStr) Type() (*types.Type, error)
- func (obj *ExprStr) Value() (types.Value, error)
- type ExprStruct
- func (obj *ExprStruct) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprStruct) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprStruct) Copy() (interfaces.Expr, error)
- func (obj *ExprStruct) Func() (interfaces.Func, error)
- func (obj *ExprStruct) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprStruct) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprStruct) Init(data *interfaces.Data) error
- func (obj *ExprStruct) Interpolate() (interfaces.Expr, error)
- func (obj *ExprStruct) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprStruct) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprStruct) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprStruct) SetType(typ *types.Type) error
- func (obj *ExprStruct) SetValue(value types.Value) error
- func (obj *ExprStruct) String() string
- func (obj *ExprStruct) Type() (*types.Type, error)
- func (obj *ExprStruct) Value() (types.Value, error)
- type ExprStructField
- type ExprTopLevel
- func (obj *ExprTopLevel) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprTopLevel) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprTopLevel) Copy() (interfaces.Expr, error)
- func (obj *ExprTopLevel) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprTopLevel) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprTopLevel) Init(data *interfaces.Data) error
- func (obj *ExprTopLevel) Interpolate() (interfaces.Expr, error)
- func (obj *ExprTopLevel) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprTopLevel) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprTopLevel) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprTopLevel) SetType(typ *types.Type) error
- func (obj *ExprTopLevel) SetValue(value types.Value) error
- func (obj *ExprTopLevel) String() string
- func (obj *ExprTopLevel) Type() (*types.Type, error)
- func (obj *ExprTopLevel) Value() (types.Value, error)
- type ExprVar
- func (obj *ExprVar) Apply(fn func(interfaces.Node) error) error
- func (obj *ExprVar) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
- func (obj *ExprVar) Copy() (interfaces.Expr, error)
- func (obj *ExprVar) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
- func (obj *ExprVar) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
- func (obj *ExprVar) Init(data *interfaces.Data) error
- func (obj *ExprVar) Interpolate() (interfaces.Expr, error)
- func (obj *ExprVar) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *ExprVar) ScopeGraph(g *pgraph.Graph)
- func (obj *ExprVar) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
- func (obj *ExprVar) SetType(typ *types.Type) error
- func (obj *ExprVar) SetValue(value types.Value) error
- func (obj *ExprVar) String() string
- func (obj *ExprVar) Type() (*types.Type, error)
- func (obj *ExprVar) Value() (types.Value, error)
- type StmtBind
- func (obj *StmtBind) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtBind) Copy() (interfaces.Stmt, error)
- func (obj *StmtBind) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtBind) Init(data *interfaces.Data) error
- func (obj *StmtBind) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtBind) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtBind) Output(map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtBind) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtBind) SetScope(scope *interfaces.Scope) error
- func (obj *StmtBind) String() string
- func (obj *StmtBind) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtClass
- func (obj *StmtClass) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtClass) Copy() (interfaces.Stmt, error)
- func (obj *StmtClass) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtClass) Init(data *interfaces.Data) error
- func (obj *StmtClass) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtClass) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtClass) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtClass) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtClass) SetScope(scope *interfaces.Scope) error
- func (obj *StmtClass) String() string
- func (obj *StmtClass) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtComment
- func (obj *StmtComment) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtComment) Copy() (interfaces.Stmt, error)
- func (obj *StmtComment) Graph(*interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtComment) Init(data *interfaces.Data) error
- func (obj *StmtComment) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtComment) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtComment) Output(map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtComment) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtComment) SetScope(*interfaces.Scope) error
- func (obj *StmtComment) String() string
- func (obj *StmtComment) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtEdge
- func (obj *StmtEdge) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtEdge) Copy() (interfaces.Stmt, error)
- func (obj *StmtEdge) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtEdge) Init(data *interfaces.Data) error
- func (obj *StmtEdge) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtEdge) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtEdge) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtEdge) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtEdge) SetScope(scope *interfaces.Scope) error
- func (obj *StmtEdge) String() string
- func (obj *StmtEdge) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtEdgeHalf
- func (obj *StmtEdgeHalf) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtEdgeHalf) Copy() (*StmtEdgeHalf, error)
- func (obj *StmtEdgeHalf) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtEdgeHalf) Init(data *interfaces.Data) error
- func (obj *StmtEdgeHalf) Interpolate() (*StmtEdgeHalf, error)
- func (obj *StmtEdgeHalf) SetScope(scope *interfaces.Scope) error
- func (obj *StmtEdgeHalf) String() string
- func (obj *StmtEdgeHalf) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtFor
- func (obj *StmtFor) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtFor) Copy() (interfaces.Stmt, error)
- func (obj *StmtFor) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtFor) Init(data *interfaces.Data) error
- func (obj *StmtFor) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtFor) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtFor) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtFor) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtFor) SetScope(scope *interfaces.Scope) error
- func (obj *StmtFor) String() string
- func (obj *StmtFor) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtForKV
- func (obj *StmtForKV) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtForKV) Copy() (interfaces.Stmt, error)
- func (obj *StmtForKV) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtForKV) Init(data *interfaces.Data) error
- func (obj *StmtForKV) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtForKV) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtForKV) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtForKV) SetScope(scope *interfaces.Scope) error
- func (obj *StmtForKV) String() string
- func (obj *StmtForKV) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtFunc
- func (obj *StmtFunc) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtFunc) Copy() (interfaces.Stmt, error)
- func (obj *StmtFunc) Graph(*interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtFunc) Init(data *interfaces.Data) error
- func (obj *StmtFunc) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtFunc) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtFunc) Output(map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtFunc) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtFunc) SetScope(scope *interfaces.Scope) error
- func (obj *StmtFunc) String() string
- func (obj *StmtFunc) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtIf
- func (obj *StmtIf) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtIf) Copy() (interfaces.Stmt, error)
- func (obj *StmtIf) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtIf) Init(data *interfaces.Data) error
- func (obj *StmtIf) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtIf) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtIf) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtIf) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtIf) SetScope(scope *interfaces.Scope) error
- func (obj *StmtIf) String() string
- func (obj *StmtIf) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtImport
- func (obj *StmtImport) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtImport) Copy() (interfaces.Stmt, error)
- func (obj *StmtImport) Graph(*interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtImport) Init(data *interfaces.Data) error
- func (obj *StmtImport) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtImport) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtImport) Output(map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtImport) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtImport) SetScope(*interfaces.Scope) error
- func (obj *StmtImport) String() string
- func (obj *StmtImport) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtInclude
- func (obj *StmtInclude) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtInclude) Copy() (interfaces.Stmt, error)
- func (obj *StmtInclude) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtInclude) Init(data *interfaces.Data) error
- func (obj *StmtInclude) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtInclude) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtInclude) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtInclude) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtInclude) SetScope(scope *interfaces.Scope) error
- func (obj *StmtInclude) String() string
- func (obj *StmtInclude) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtProg
- func (obj *StmtProg) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtProg) Copy() (interfaces.Stmt, error)
- func (obj *StmtProg) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtProg) Init(data *interfaces.Data) error
- func (obj *StmtProg) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtProg) IsModuleUnsafe() error
- func (obj *StmtProg) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtProg) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtProg) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtProg) SetScope(scope *interfaces.Scope) error
- func (obj *StmtProg) String() string
- func (obj *StmtProg) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtRes
- func (obj *StmtRes) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtRes) Copy() (interfaces.Stmt, error)
- func (obj *StmtRes) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtRes) Init(data *interfaces.Data) error
- func (obj *StmtRes) Interpolate() (interfaces.Stmt, error)
- func (obj *StmtRes) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtRes) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
- func (obj *StmtRes) ScopeGraph(g *pgraph.Graph)
- func (obj *StmtRes) SetScope(scope *interfaces.Scope) error
- func (obj *StmtRes) String() string
- func (obj *StmtRes) TypeCheck() ([]*interfaces.UnificationInvariant, error)
- type StmtResContents
- type StmtResEdge
- func (obj *StmtResEdge) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtResEdge) Copy() (StmtResContents, error)
- func (obj *StmtResEdge) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtResEdge) Init(data *interfaces.Data) error
- func (obj *StmtResEdge) Interpolate() (StmtResContents, error)
- func (obj *StmtResEdge) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtResEdge) SetScope(scope *interfaces.Scope) error
- func (obj *StmtResEdge) String() string
- func (obj *StmtResEdge) TypeCheck(kind string) ([]*interfaces.UnificationInvariant, error)
- type StmtResField
- func (obj *StmtResField) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtResField) Copy() (StmtResContents, error)
- func (obj *StmtResField) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtResField) Init(data *interfaces.Data) error
- func (obj *StmtResField) Interpolate() (StmtResContents, error)
- func (obj *StmtResField) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtResField) SetScope(scope *interfaces.Scope) error
- func (obj *StmtResField) String() string
- func (obj *StmtResField) TypeCheck(kind string) ([]*interfaces.UnificationInvariant, error)
- type StmtResMeta
- func (obj *StmtResMeta) Apply(fn func(interfaces.Node) error) error
- func (obj *StmtResMeta) Copy() (StmtResContents, error)
- func (obj *StmtResMeta) Graph(env *interfaces.Env) (*pgraph.Graph, error)
- func (obj *StmtResMeta) Init(data *interfaces.Data) error
- func (obj *StmtResMeta) Interpolate() (StmtResContents, error)
- func (obj *StmtResMeta) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
- func (obj *StmtResMeta) SetScope(scope *interfaces.Scope) error
- func (obj *StmtResMeta) String() string
- func (obj *StmtResMeta) TypeCheck(kind string) ([]*interfaces.UnificationInvariant, error)
- type Textarea
- func (obj *Textarea) Byline() string
- func (obj *Textarea) End() (int, int)
- func (obj *Textarea) Filename() string
- func (obj *Textarea) HighlightText() string
- func (obj *Textarea) IsSet() bool
- func (obj *Textarea) Locate(line int, col int, endline int, endcol int)
- func (obj *Textarea) Path() string
- func (obj *Textarea) Pos() (int, int)
- func (obj *Textarea) Setup(data *interfaces.Data)
Constants ¶
const ( // EdgeNotify declares an edge a -> b, such that a notification occurs. // This is most similar to "notify" in Puppet. EdgeNotify = "notify" // EdgeBefore declares an edge a -> b, such that no notification occurs. // This is most similar to "before" in Puppet. EdgeBefore = "before" // EdgeListen declares an edge a <- b, such that a notification occurs. // This is most similar to "subscribe" in Puppet. EdgeListen = "listen" // EdgeDepend declares an edge a <- b, such that no notification occurs. // This is most similar to "require" in Puppet. EdgeDepend = "depend" // MetaField is the prefix used to specify a meta parameter for the res. MetaField = "meta" // AllowBareClassIncluding specifies that a simple include without an // `as` suffix, will be pulled in under the name of the included class. // We want this on if it turns out to be common to pull in values from // classes. // // If we allow bare including of classes, then we have to also prevent // duplicate class inclusion for many cases. For example: // // class c1($s) { // test $s {} // $x = "${s}" // } // include c1("hey") // include c1("there") // test $x {} // // What value should $x have? We want to import two useful `test` // resources, but with a bare import this makes `$x` ambiguous. We'd // have to detect this and ensure this is a compile time error to use // it. Being able to allow compatible, duplicate classes is a key // important feature of the language, and as a result, enabling this // would probably be disastrous. The fact that the import statement // allows bare imports is an ergonomic consideration that is allowed // because duplicate imports aren't essential. As an aside, the use of // bare imports isn't recommended because it makes it more difficult to // know where certain things are coming from. AllowBareClassIncluding = false // AllowBareIncludes specifies that you're allowed to use an include // which flattens the included scope on top of the current scope. This // means includes of the form: `include foo as *`. These are unlikely to // get enabled for many reasons. AllowBareIncludes = false // AllowBareImports specifies that you're allowed to use an import which // flattens the imported scope on top of the current scope. This means // imports of the form: `import foo as *`. These are being provisionally // enabled, despite being less explicit and harder to parse. AllowBareImports = true // AllowUserDefinedPolyFunc specifies if we allow user-defined // polymorphic functions or not. At the moment this is not implemented. // XXX: not implemented AllowUserDefinedPolyFunc = false // RequireStrictModulePath can be set to true if you wish to ignore any // of the metadata parent path searching. By default that is allowed, // unless it is disabled per module with ParentPathBlock. This option is // here in case we decide that the parent module searching is confusing. RequireStrictModulePath = false // RequireTopologicalOrdering specifies if the code *must* be written in // a topologically correct order. This prevents "out-of-order" code that // is valid, but possibly confusing to the read. The main author // (purpleidea) believes that this is better of as false. This is // because occasionally code might be more logical when out-of-order, // and hiding the fundamental structure of the language isn't elegant. RequireTopologicalOrdering = false // TopologicalOrderingWarning specifies whether a warning is emitted if // the code is not in a topologically correct order. If this warning is // seen too often, then we should consider disabling this by default. TopologicalOrderingWarning = true // ErrNoStoredScope is an error that tells us we can't get a scope here. ErrNoStoredScope = util.Error("scope is not stored in this node") // ErrFuncPointerNil is an error that explains the function pointer for // table lookup is missing. If this happens, it's most likely a // programming error. ErrFuncPointerNil = util.Error("missing func pointer for table") // ErrTableNoValue is an error that explains the table is missing a // value. If this happens, it's most likely a programming error. ErrTableNoValue = util.Error("missing value in table") )
Functions ¶
func CollectFiles ¶
func CollectFiles(ast interfaces.Stmt) ([]string, error)
CollectFiles collects all the files used in the AST. You will see more files based on how many compiling steps have run. In general, this is useful for collecting all the files needed to store in our file system for a deploy.
func CopyNodeMapping ¶
func CopyNodeMapping(in map[string]interfaces.Node) map[string]interfaces.Node
CopyNodeMapping copies the map of string to node and is used in Ordering.
func FuncPrefixToFunctionsScope ¶
func FuncPrefixToFunctionsScope(prefix string) map[string]interfaces.Expr
FuncPrefixToFunctionsScope is a helper function to return the functions portion of the scope from a function prefix lookup. Basically this wraps the implementation in the Func interface in the *ExprFunc struct.
func MergeExprMaps ¶
func MergeExprMaps(m, extra map[string]interfaces.Expr, prefix ...string) (map[string]interfaces.Expr, error)
MergeExprMaps merges the two maps of Expr's, and errors if any overwriting would occur. If any prefix string is specified, that is added to the keys of the second "extra" map before doing the merge. This doesn't change the input maps.
func ValueToExpr ¶
func ValueToExpr(val types.Value) (interfaces.Expr, error)
ValueToExpr converts a Value into the equivalent Expr. FIXME: Add some tests for this function.
func VarPrefixToVariablesScope ¶
func VarPrefixToVariablesScope(prefix string) map[string]interfaces.Expr
VarPrefixToVariablesScope is a helper function to return the variables portion of the scope from a variable prefix lookup. Basically this is useful to pull out a portion of the variables we've defined by API. TODO: pass `data` into here so we can plumb it into Init for Expr's ?
Types ¶
type ExprBool ¶
ExprBool is a representation of a boolean.
func (*ExprBool) Apply ¶
func (obj *ExprBool) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprBool) Check ¶
func (obj *ExprBool) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprBool) Copy ¶
func (obj *ExprBool) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprBool) Func ¶
func (obj *ExprBool) Func() (interfaces.Func, error)
Func returns the reactive stream of values that this expression produces.
func (*ExprBool) Graph ¶
func (obj *ExprBool) Graph(*interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprBool) Infer ¶
func (obj *ExprBool) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprBool) Init ¶
func (obj *ExprBool) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprBool) Interpolate ¶
func (obj *ExprBool) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.
func (*ExprBool) Ordering ¶
func (obj *ExprBool) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprBool) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprBool) SetScope ¶
func (obj *ExprBool) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope. It does however store it for later possible use.
func (*ExprBool) SetType ¶
SetType will make no changes if called here. It will error if anything other than a Bool is passed in, and doesn't need to be called for this expr to work.
func (*ExprBool) SetValue ¶
SetValue for a bool expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.
func (*ExprBool) String ¶
String returns a short representation of this expression.
func (*ExprBool) Type ¶
Type returns the type of this expression. This method always returns Bool here.
func (*ExprBool) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.
type ExprCall ¶
type ExprCall struct { Textarea V types.Value // stored result (set with SetValue) // Name of the function to be called. We look for it in the scope. Name string // Args are the list of inputs to this function. Args []interfaces.Expr // list of args in parsed order // Var specifies whether the function being called is a lambda in a var. Var bool // Anon is an *ExprFunc which is used if we are calling anonymously. If // this is specified, Name must be the empty string. Anon interfaces.Expr // contains filtered or unexported fields }
ExprCall is a representation of a function call. This does not represent the declaration or implementation of a new function value. This struct has an analogous symmetry with ExprVar.
func (*ExprCall) Apply ¶
func (obj *ExprCall) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprCall) Check ¶
func (obj *ExprCall) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprCall) Copy ¶
func (obj *ExprCall) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprCall) Graph ¶
func (obj *ExprCall) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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 (*ExprCall) Infer ¶
func (obj *ExprCall) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprCall) Init ¶
func (obj *ExprCall) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprCall) Interpolate ¶
func (obj *ExprCall) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprCall) Ordering ¶
func (obj *ExprCall) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprCall) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprCall) SetScope ¶
func (obj *ExprCall) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to. This particular function has been heavily optimized to work correctly with calling functions with the correct args. Edit cautiously and with extensive testing.
func (*ExprCall) SetType ¶
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error. Remember that for this function expression, the type is the *return type* of the function, not the full type of the function signature.
func (*ExprCall) SetValue ¶
SetValue here is used to store the result of the last computation of this expression node after it has received all the required input values. This value is cached and can be retrieved by calling Value.
func (*ExprCall) String ¶
String returns a short representation of this expression.
func (*ExprCall) Type ¶
Type returns the type of this expression, which is the return type of the function call.
func (*ExprCall) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. It is often unlikely that this kind of speculative execution finds something. This particular implementation of the function returns the previously stored and cached value as received by SetValue.
type ExprFloat ¶
ExprFloat is a representation of a float.
func (*ExprFloat) Apply ¶
func (obj *ExprFloat) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprFloat) Check ¶
func (obj *ExprFloat) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprFloat) Copy ¶
func (obj *ExprFloat) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprFloat) Func ¶
func (obj *ExprFloat) Func() (interfaces.Func, error)
Func returns the reactive stream of values that this expression produces.
func (*ExprFloat) Graph ¶
func (obj *ExprFloat) Graph(*interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprFloat) Infer ¶
func (obj *ExprFloat) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprFloat) Init ¶
func (obj *ExprFloat) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprFloat) Interpolate ¶
func (obj *ExprFloat) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.
func (*ExprFloat) Ordering ¶
func (obj *ExprFloat) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprFloat) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprFloat) SetScope ¶
func (obj *ExprFloat) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope. It does however store it for later possible use.
func (*ExprFloat) SetType ¶
SetType will make no changes if called here. It will error if anything other than a Float is passed in, and doesn't need to be called for this expr to work.
func (*ExprFloat) SetValue ¶
SetValue for a float expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.
func (*ExprFloat) String ¶
String returns a short representation of this expression.
func (*ExprFloat) Type ¶
Type returns the type of this expression. This method always returns Float here.
func (*ExprFloat) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.
type ExprFunc ¶
type ExprFunc struct { Textarea // Title is a friendly-name to use for identifying the function. It can // be used in debugging and error-handling. It is not required. It is // *not* called Name, because that could get confused with the Name // field in ExprCall and similar nodes. Title string // Args are the list of args that were used when defining the function. // This can include a string name and a type, however the type might be // absent here. Args []*interfaces.Arg // Return is the return type of the function if it was defined. Return *types.Type // return type if specified // Body is the contents of the function. It can be any expression. Body interfaces.Expr // Function is the built implementation of the function interface as // represented by the top-level function API. Function func() interfaces.Func // store like this to build on demand! // Values represents a list of simple functions. This means this can be // polymorphic if more than one was specified! Values []*types.FuncValue // contains filtered or unexported fields }
ExprFunc is a representation of a function value. This is not a function call, that is represented by ExprCall.
There are several kinds of functions which can be represented: 1. The contents of a StmtFunc (set Args, Return, and Body) 2. A lambda function (also set Args, Return, and Body) 3. A stateful built-in function (set Function) 4. A pure built-in function (set Values to a singleton) 5. A pure polymorphic built-in function (set Values to a list)
func (*ExprFunc) Apply ¶
func (obj *ExprFunc) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprFunc) Check ¶
func (obj *ExprFunc) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprFunc) Copy ¶
func (obj *ExprFunc) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied. All the constants aren't copied, because we don't want to duplicate them unnecessarily in the function graph. For example, an static integer will not ever change, where as a function value (expr) might get used with two different signatures depending on the caller.
func (*ExprFunc) Graph ¶
func (obj *ExprFunc) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprFunc) Infer ¶
func (obj *ExprFunc) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprFunc) Init ¶
func (obj *ExprFunc) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprFunc) Interpolate ¶
func (obj *ExprFunc) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.
func (*ExprFunc) Ordering ¶
func (obj *ExprFunc) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in. XXX: do we need to add ordering around named args, eg: obj.Args Name strings?
func (*ExprFunc) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprFunc) SetScope ¶
func (obj *ExprFunc) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*ExprFunc) SetType ¶
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprFunc) SetValue ¶
SetValue for a func expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.
func (*ExprFunc) String ¶
String returns a short representation of this expression.
func (*ExprFunc) Type ¶
Type returns the type of this expression. It will attempt to speculate on the type if it can be determined statically before type unification.
func (*ExprFunc) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.
type ExprIf ¶
type ExprIf struct { Textarea Condition interfaces.Expr ThenBranch interfaces.Expr // could be an ExprBranch ElseBranch interfaces.Expr // could be an ExprBranch // contains filtered or unexported fields }
ExprIf represents an if expression which *must* have both branches, and which returns a value. As a result, it has a type. This is different from a StmtIf, which does not need to have both branches, and which does not return a value.
func (*ExprIf) Apply ¶
func (obj *ExprIf) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprIf) Check ¶
func (obj *ExprIf) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprIf) Copy ¶
func (obj *ExprIf) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprIf) Func ¶
func (obj *ExprIf) Func() (interfaces.Func, error)
Func returns a function which returns the correct branch based on the ever changing conditional boolean input.
func (*ExprIf) Graph ¶
func (obj *ExprIf) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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 particular if expression doesn't do anything clever here other than adding in both branches of the graph. Since we're functional, this shouldn't have any ill effects. XXX: is this completely true if we're running technically impure, but safe built-in functions on both branches? Can we turn off half of this?
func (*ExprIf) Infer ¶
func (obj *ExprIf) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprIf) Init ¶
func (obj *ExprIf) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprIf) Interpolate ¶
func (obj *ExprIf) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprIf) Ordering ¶
func (obj *ExprIf) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprIf) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprIf) SetScope ¶
func (obj *ExprIf) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*ExprIf) SetType ¶
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprIf) SetValue ¶
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the branches expr's) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprIf) String ¶
String returns a short representation of this expression.
func (*ExprIf) Type ¶
Type returns the type of this expression.
func (*ExprIf) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular expression evaluates the condition and returns the correct branch's value accordingly.
type ExprInt ¶
ExprInt is a representation of an int.
func (*ExprInt) Apply ¶
func (obj *ExprInt) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprInt) Check ¶
func (obj *ExprInt) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprInt) Copy ¶
func (obj *ExprInt) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprInt) Func ¶
func (obj *ExprInt) Func() (interfaces.Func, error)
Func returns the reactive stream of values that this expression produces.
func (*ExprInt) Graph ¶
func (obj *ExprInt) Graph(*interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprInt) Infer ¶
func (obj *ExprInt) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprInt) Init ¶
func (obj *ExprInt) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprInt) Interpolate ¶
func (obj *ExprInt) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.
func (*ExprInt) Ordering ¶
func (obj *ExprInt) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprInt) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprInt) SetScope ¶
func (obj *ExprInt) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope. It does however store it for later possible use.
func (*ExprInt) SetType ¶
SetType will make no changes if called here. It will error if anything other than an Int is passed in, and doesn't need to be called for this expr to work.
func (*ExprInt) SetValue ¶
SetValue for an int expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.
func (*ExprInt) String ¶
String returns a short representation of this expression.
func (*ExprInt) Type ¶
Type returns the type of this expression. This method always returns Int here.
func (*ExprInt) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.
type ExprIterated ¶
type ExprIterated struct { // Name is the name (Ident) of the StmtBind. Name string // Definition is the wrapped expression. Definition interfaces.Expr // contains filtered or unexported fields }
ExprIterated tags an Expr to indicate that we want to use the env instead of the scope in Graph() because this variable was defined inside a for loop. We create a new ExprIterated which wraps an Expr and indicates that we want to use an iteration-specific value instead of the wrapped Expr. It delegates to the Expr for SetScope() and Infer(), and looks up in the env for Graph(), the same as ExprParam.Graph(), and panics if any later phase is called.
func (*ExprIterated) Apply ¶
func (obj *ExprIterated) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprIterated) Check ¶
func (obj *ExprIterated) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprIterated) Copy ¶
func (obj *ExprIterated) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied. This intentionally returns a copy, because if a function (usually a lambda) that is used more than once, contains this variable, we will want each instantiation of it to be unique, otherwise they will be the same pointer, and they won't be able to have different values.
func (*ExprIterated) Graph ¶
func (obj *ExprIterated) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprIterated) Infer ¶
func (obj *ExprIterated) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer. This Infer returns a quasi-equivalent to my ExprAny invariant idea.
func (*ExprIterated) Init ¶
func (obj *ExprIterated) Init(*interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprIterated) Interpolate ¶
func (obj *ExprIterated) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprIterated) Ordering ¶
func (obj *ExprIterated) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprIterated) ScopeGraph ¶
func (obj *ExprIterated) ScopeGraph(g *pgraph.Graph)
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprIterated) SetScope ¶
func (obj *ExprIterated) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for use in this resource.
func (*ExprIterated) SetType ¶
func (obj *ExprIterated) SetType(typ *types.Type) error
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprIterated) SetValue ¶
func (obj *ExprIterated) SetValue(value types.Value) error
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the dest lookup expr) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprIterated) String ¶
func (obj *ExprIterated) String() string
String returns a short representation of this expression.
func (*ExprIterated) Type ¶
func (obj *ExprIterated) Type() (*types.Type, error)
Type returns the type of this expression.
func (*ExprIterated) Value ¶
func (obj *ExprIterated) Value() (types.Value, error)
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.
type ExprList ¶
type ExprList struct { Textarea //Elements []*ExprListElement Elements []interfaces.Expr // contains filtered or unexported fields }
ExprList is a representation of a list.
func (*ExprList) Apply ¶
func (obj *ExprList) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprList) Check ¶
func (obj *ExprList) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprList) Copy ¶
func (obj *ExprList) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprList) Func ¶
func (obj *ExprList) Func() (interfaces.Func, error)
Func returns the reactive stream of values that this expression produces.
func (*ExprList) Graph ¶
func (obj *ExprList) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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 (*ExprList) Infer ¶
func (obj *ExprList) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprList) Init ¶
func (obj *ExprList) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprList) Interpolate ¶
func (obj *ExprList) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprList) Ordering ¶
func (obj *ExprList) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprList) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprList) SetScope ¶
func (obj *ExprList) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*ExprList) SetType ¶
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprList) SetValue ¶
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 this expression by calling `Value`, it will build it from scratch!
func (*ExprList) String ¶
String returns a short representation of this expression.
func (*ExprList) Type ¶
Type returns the type of this expression.
func (*ExprList) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.
type ExprMap ¶
ExprMap is a representation of a (dictionary) map.
func (*ExprMap) Apply ¶
func (obj *ExprMap) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprMap) Check ¶
func (obj *ExprMap) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprMap) Copy ¶
func (obj *ExprMap) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprMap) Func ¶
func (obj *ExprMap) Func() (interfaces.Func, error)
Func returns the reactive stream of values that this expression produces.
func (*ExprMap) Graph ¶
func (obj *ExprMap) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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 (*ExprMap) Infer ¶
func (obj *ExprMap) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprMap) Init ¶
func (obj *ExprMap) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprMap) Interpolate ¶
func (obj *ExprMap) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprMap) Ordering ¶
func (obj *ExprMap) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprMap) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprMap) SetScope ¶
func (obj *ExprMap) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*ExprMap) SetType ¶
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprMap) SetValue ¶
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child key/value's (the map elements) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprMap) String ¶
String returns a short representation of this expression.
func (*ExprMap) Type ¶
Type returns the type of this expression.
func (*ExprMap) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.
type ExprMapKV ¶
type ExprMapKV struct { Textarea Key interfaces.Expr // keys can be strings, int's, etc... Val interfaces.Expr }
ExprMapKV represents a key and value pair in a (dictionary) map. This does not satisfy the Expr interface.
type ExprParam ¶
type ExprParam struct { Name string // name of the parameter // contains filtered or unexported fields }
ExprParam represents a parameter to a function.
func (*ExprParam) Apply ¶
func (obj *ExprParam) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprParam) Check ¶
func (obj *ExprParam) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprParam) Copy ¶
func (obj *ExprParam) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied. This intentionally returns a copy, because if a function (usually a lambda) that is used more than once, contains this variable, we will want each instantiation of it to be unique, otherwise they will be the same pointer, and they won't be able to have different values.
func (*ExprParam) Graph ¶
func (obj *ExprParam) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprParam) Infer ¶
func (obj *ExprParam) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer. This Infer returns a quasi-equivalent to my ExprAny invariant idea.
func (*ExprParam) Init ¶
func (obj *ExprParam) Init(*interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprParam) Interpolate ¶
func (obj *ExprParam) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprParam) Ordering ¶
func (obj *ExprParam) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprParam) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprParam) SetScope ¶
func (obj *ExprParam) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for use in this resource.
func (*ExprParam) SetType ¶
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprParam) SetValue ¶
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the dest lookup expr) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprParam) String ¶
String returns a short representation of this expression.
func (*ExprParam) Type ¶
Type returns the type of this expression.
func (*ExprParam) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.
type ExprPoly ¶
type ExprPoly struct { Definition interfaces.Expr // The definition. }
ExprPoly is a polymorphic expression that is a definition that can be used in multiple places with different types. We must copy the definition at each call site in order for the type checker to find a different type at each call site. We create this copy inside SetScope, at which point we also recursively call SetScope on the copy. We must be careful to use the scope captured at the definition site, not the scope which is available at the call site.
func (*ExprPoly) Apply ¶
func (obj *ExprPoly) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprPoly) Check ¶
func (obj *ExprPoly) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprPoly) Copy ¶
func (obj *ExprPoly) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied. This implementation intentionally does not copy anything, because the Definition is already intended to be copied at each use site.
func (*ExprPoly) Graph ¶
func (obj *ExprPoly) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprPoly) Infer ¶
func (obj *ExprPoly) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer. This Infer should never be called.
func (*ExprPoly) Init ¶
func (obj *ExprPoly) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprPoly) Interpolate ¶
func (obj *ExprPoly) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprPoly) Ordering ¶
func (obj *ExprPoly) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprPoly) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprPoly) SetScope ¶
func (obj *ExprPoly) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for use in this resource.
func (*ExprPoly) SetType ¶
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprPoly) SetValue ¶
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the dest lookup expr) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprPoly) String ¶
String returns a short representation of this expression.
func (*ExprPoly) Type ¶
Type returns the type of this expression.
func (*ExprPoly) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.
type ExprSingleton ¶
type ExprSingleton struct { Definition interfaces.Expr // contains filtered or unexported fields }
ExprSingleton is intended to wrap top-level variable definitions. It ensures that a single Func is created even if multiple use sites call ExprSingleton.Graph().
func (*ExprSingleton) Apply ¶
func (obj *ExprSingleton) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprSingleton) Check ¶
func (obj *ExprSingleton) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprSingleton) Copy ¶
func (obj *ExprSingleton) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprSingleton) Graph ¶
func (obj *ExprSingleton) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprSingleton) Infer ¶
func (obj *ExprSingleton) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer. This Infer is an exception to that pattern.
func (*ExprSingleton) Init ¶
func (obj *ExprSingleton) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprSingleton) Interpolate ¶
func (obj *ExprSingleton) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprSingleton) Ordering ¶
func (obj *ExprSingleton) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprSingleton) ScopeGraph ¶
func (obj *ExprSingleton) ScopeGraph(g *pgraph.Graph)
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprSingleton) SetScope ¶
func (obj *ExprSingleton) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for use in this resource.
func (*ExprSingleton) SetType ¶
func (obj *ExprSingleton) SetType(typ *types.Type) error
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprSingleton) SetValue ¶
func (obj *ExprSingleton) SetValue(value types.Value) error
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the dest lookup expr) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprSingleton) String ¶
func (obj *ExprSingleton) String() string
String returns a short representation of this expression.
func (*ExprSingleton) Type ¶
func (obj *ExprSingleton) Type() (*types.Type, error)
Type returns the type of this expression.
func (*ExprSingleton) Value ¶
func (obj *ExprSingleton) Value() (types.Value, error)
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.
type ExprStr ¶
type ExprStr struct { Textarea V string // value of this string // contains filtered or unexported fields }
ExprStr is a representation of a string.
func (*ExprStr) Apply ¶
func (obj *ExprStr) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprStr) Check ¶
func (obj *ExprStr) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprStr) Copy ¶
func (obj *ExprStr) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprStr) Func ¶
func (obj *ExprStr) Func() (interfaces.Func, error)
Func returns the reactive stream of values that this expression produces.
func (*ExprStr) Graph ¶
func (obj *ExprStr) Graph(*interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprStr) Infer ¶
func (obj *ExprStr) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprStr) Init ¶
func (obj *ExprStr) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprStr) Interpolate ¶
func (obj *ExprStr) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it attempts to expand the string if there are any internal variables which need interpolation. If any are found, it returns a larger AST which has a function which returns a string as its root. Otherwise it returns itself.
func (*ExprStr) Ordering ¶
func (obj *ExprStr) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in. This Ordering method runs *after* the Interpolate method, so if this originally would have expanded into a bigger AST, but the time Ordering runs, this is only used on a raw string expression. As a result, it doesn't need to build a map of consumed nodes, because none are consumed. The returned graph is empty!
func (*ExprStr) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprStr) SetScope ¶
func (obj *ExprStr) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope. It does however store it for later possible use.
func (*ExprStr) SetType ¶
SetType will make no changes if called here. It will error if anything other than an Str is passed in, and doesn't need to be called for this expr to work.
func (*ExprStr) SetValue ¶
SetValue for an str expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.
func (*ExprStr) String ¶
String returns a short representation of this expression.
func (*ExprStr) Type ¶
Type returns the type of this expression. This method always returns Str here.
func (*ExprStr) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.
type ExprStruct ¶
type ExprStruct struct { Textarea Fields []*ExprStructField // the list (fields) are intentionally ordered! // contains filtered or unexported fields }
ExprStruct is a representation of a struct.
func (*ExprStruct) Apply ¶
func (obj *ExprStruct) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprStruct) Check ¶
func (obj *ExprStruct) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprStruct) Copy ¶
func (obj *ExprStruct) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprStruct) Func ¶
func (obj *ExprStruct) Func() (interfaces.Func, error)
Func returns the reactive stream of values that this expression produces.
func (*ExprStruct) Graph ¶
func (obj *ExprStruct) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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 (*ExprStruct) Infer ¶
func (obj *ExprStruct) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer.
func (*ExprStruct) Init ¶
func (obj *ExprStruct) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprStruct) Interpolate ¶
func (obj *ExprStruct) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprStruct) Ordering ¶
func (obj *ExprStruct) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprStruct) ScopeGraph ¶
func (obj *ExprStruct) ScopeGraph(g *pgraph.Graph)
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprStruct) SetScope ¶
func (obj *ExprStruct) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*ExprStruct) SetType ¶
func (obj *ExprStruct) SetType(typ *types.Type) error
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprStruct) SetValue ¶
func (obj *ExprStruct) SetValue(value types.Value) error
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the struct elements) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprStruct) String ¶
func (obj *ExprStruct) String() string
String returns a short representation of this expression.
func (*ExprStruct) Type ¶
func (obj *ExprStruct) Type() (*types.Type, error)
Type returns the type of this expression.
func (*ExprStruct) Value ¶
func (obj *ExprStruct) Value() (types.Value, error)
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.
type ExprStructField ¶
type ExprStructField struct { Textarea Name string Value interfaces.Expr }
ExprStructField represents a name value pair in a struct field. This does not satisfy the Expr interface.
type ExprTopLevel ¶
type ExprTopLevel struct { Definition interfaces.Expr // The definition. CapturedScope *interfaces.Scope // The scope at the definition site. }
ExprTopLevel is intended to wrap top-level definitions. It captures the variables which are in scope at the the top-level, so that when use sites call ExprTopLevel.SetScope() with the variables which are in scope at the use site, ExprTopLevel can automatically correct this by using the variables which are in scope at the definition site.
func (*ExprTopLevel) Apply ¶
func (obj *ExprTopLevel) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprTopLevel) Check ¶
func (obj *ExprTopLevel) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprTopLevel) Copy ¶
func (obj *ExprTopLevel) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*ExprTopLevel) Graph ¶
func (obj *ExprTopLevel) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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.
func (*ExprTopLevel) Infer ¶
func (obj *ExprTopLevel) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer. This Infer is an exception to that pattern.
func (*ExprTopLevel) Init ¶
func (obj *ExprTopLevel) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprTopLevel) Interpolate ¶
func (obj *ExprTopLevel) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*ExprTopLevel) Ordering ¶
func (obj *ExprTopLevel) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprTopLevel) ScopeGraph ¶
func (obj *ExprTopLevel) ScopeGraph(g *pgraph.Graph)
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprTopLevel) SetScope ¶
func (obj *ExprTopLevel) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for use in this resource.
func (*ExprTopLevel) SetType ¶
func (obj *ExprTopLevel) SetType(typ *types.Type) error
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprTopLevel) SetValue ¶
func (obj *ExprTopLevel) SetValue(value types.Value) error
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the dest lookup expr) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprTopLevel) String ¶
func (obj *ExprTopLevel) String() string
String returns a short representation of this expression.
func (*ExprTopLevel) Type ¶
func (obj *ExprTopLevel) Type() (*types.Type, error)
Type returns the type of this expression.
func (*ExprTopLevel) Value ¶
func (obj *ExprTopLevel) Value() (types.Value, error)
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.
type ExprVar ¶
type ExprVar struct { Textarea Name string // name of the variable // contains filtered or unexported fields }
ExprVar is a representation of a variable lookup. It returns the expression that that variable refers to.
func (*ExprVar) Apply ¶
func (obj *ExprVar) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*ExprVar) Check ¶
func (obj *ExprVar) Check(typ *types.Type) ([]*interfaces.UnificationInvariant, error)
Check is checking that the input type is equal to the object that Check is running on. In doing so, it adds any invariants that are necessary. Check must always call Infer to produce the invariant. The implementation can be generic for all expressions.
func (*ExprVar) Copy ¶
func (obj *ExprVar) Copy() (interfaces.Expr, error)
Copy returns a light copy of this struct. Anything static will not be copied. This intentionally returns a copy, because if a function (usually a lambda) that is used more than once, contains this variable, we will want each instantiation of it to be unique, otherwise they will be the same pointer, and they won't be able to have different values.
func (*ExprVar) Graph ¶
func (obj *ExprVar) Graph(env *interfaces.Env) (*pgraph.Graph, interfaces.Func, error)
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. The child graph in this case is the graph which is obtained from the bound expression. The edge points from that expression to this vertex. The function used for this vertex is a simple placeholder which sucks incoming values in and passes them on. This is important for filling the logical requirements of the graph type checker, and to avoid duplicating production of the incoming input value from the bound expression.
func (*ExprVar) Infer ¶
func (obj *ExprVar) Infer() (*types.Type, []*interfaces.UnificationInvariant, error)
Infer returns the type of itself and a collection of invariants. The returned type may contain unification variables. It collects the invariants by calling Check on its children expressions. In making those calls, it passes in the known type for that child to get it to "Check" it. When the type is not known, it should create a new unification variable to pass in to the child Check calls. Infer usually only calls Check on things inside of it, and often does not call another Infer. This Infer is an exception to that pattern.
func (*ExprVar) Init ¶
func (obj *ExprVar) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*ExprVar) Interpolate ¶
func (obj *ExprVar) Interpolate() (interfaces.Expr, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it returns itself, since variable names cannot be interpolated. We don't support variable, variables or anything crazy like that.
func (*ExprVar) Ordering ¶
func (obj *ExprVar) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*ExprVar) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*ExprVar) SetScope ¶
func (obj *ExprVar) SetScope(scope *interfaces.Scope, sctx map[string]interfaces.Expr) error
SetScope stores the scope for use in this resource.
func (*ExprVar) SetType ¶
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 parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.
func (*ExprVar) SetValue ¶
SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the dest lookup expr) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!
func (*ExprVar) String ¶
String returns a short representation of this expression.
func (*ExprVar) Type ¶
Type returns the type of this expression.
func (*ExprVar) Value ¶
Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This returns the value this variable points to. It is able to do so because it can lookup in the previous set scope which expression this points to, and then it can call Value on that expression.
type StmtBind ¶
type StmtBind struct { Textarea Ident string Value interfaces.Expr Type *types.Type // contains filtered or unexported fields }
StmtBind is a representation of an assignment, which binds a variable to an expression.
func (*StmtBind) Apply ¶
func (obj *StmtBind) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtBind) Copy ¶
func (obj *StmtBind) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtBind) Graph ¶
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 particular bind statement adds its linked expression to the graph. It is not logically done in the ExprVar since that could exist multiple times for the single binding operation done here.
func (*StmtBind) Init ¶
func (obj *StmtBind) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtBind) Interpolate ¶
func (obj *StmtBind) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtBind) Ordering ¶
func (obj *StmtBind) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in. We only really care about the consumers here, because the "produces" aspect of this resource is handled by the StmtProg Ordering function. This is because the "prog" allows out-of-order statements, therefore it solves this by running an early (second) loop through the program and peering into this Stmt and extracting the produced name.
func (*StmtBind) Output ¶
func (obj *StmtBind) Output(map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output for the bind statement produces no output. Any values of interest come from the use of the var which this binds the expression to.
func (*StmtBind) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtBind) SetScope ¶
func (obj *StmtBind) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtBind) String ¶
String returns a short representation of this statement.
func (*StmtBind) TypeCheck ¶
func (obj *StmtBind) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtClass ¶
type StmtClass struct { Textarea Name string Args []*interfaces.Arg // XXX: sam thinks we should name this Params and interfaces.Param Body interfaces.Stmt // probably a *StmtProg // contains filtered or unexported fields }
StmtClass represents a user defined class. It's effectively a program body that can optionally take some parameterized inputs. TODO: We don't currently support defining polymorphic classes (eg: different signatures for the same class name) but it might be something to consider.
func (*StmtClass) Apply ¶
func (obj *StmtClass) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtClass) Copy ¶
func (obj *StmtClass) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtClass) Graph ¶
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 particular func statement adds its linked expression to the graph.
func (*StmtClass) Init ¶
func (obj *StmtClass) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtClass) Interpolate ¶
func (obj *StmtClass) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtClass) Ordering ¶
func (obj *StmtClass) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in. We only really care about the consumers here, because the "produces" aspect of this resource is handled by the StmtProg Ordering function. This is because the "prog" allows out-of-order statements, therefore it solves this by running an early (second) loop through the program and peering into this Stmt and extracting the produced name. TODO: Is Ordering in StmtInclude done properly and in sync with this? XXX: do we need to add ordering around named args, eg: obj.Args Name strings?
func (*StmtClass) Output ¶
func (obj *StmtClass) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output for the class statement produces no output. Any values of interest come from the use of the include which this binds the statements to. This is usually called from the parent in StmtProg, but it skips running it so that it can be called from the StmtInclude Output method.
func (*StmtClass) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtClass) SetScope ¶
func (obj *StmtClass) SetScope(scope *interfaces.Scope) error
SetScope sets the scope of the child expression bound to it. It seems this is necessary in order to reach this, in particular in situations when a bound expression points to a previously bound expression.
func (*StmtClass) String ¶
String returns a short representation of this statement.
func (*StmtClass) TypeCheck ¶
func (obj *StmtClass) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtComment ¶
StmtComment is a representation of a comment. It is currently unused. It probably makes sense to make a third kind of Node (not a Stmt or an Expr) so that comments can still be part of the AST (for eventual automatic code formatting) but so that they can exist anywhere in the code. Currently these are dropped by the lexer.
func (*StmtComment) Apply ¶
func (obj *StmtComment) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtComment) Copy ¶
func (obj *StmtComment) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtComment) Graph ¶
func (obj *StmtComment) Graph(*interfaces.Env) (*pgraph.Graph, error)
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 particular graph does nothing clever.
func (*StmtComment) Init ¶
func (obj *StmtComment) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtComment) Interpolate ¶
func (obj *StmtComment) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.
func (*StmtComment) Ordering ¶
func (obj *StmtComment) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtComment) Output ¶
func (obj *StmtComment) Output(map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output for the comment statement produces no output.
func (*StmtComment) ScopeGraph ¶
func (obj *StmtComment) ScopeGraph(g *pgraph.Graph)
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtComment) SetScope ¶
func (obj *StmtComment) SetScope(*interfaces.Scope) error
SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope.
func (*StmtComment) String ¶
func (obj *StmtComment) String() string
String returns a short representation of this statement.
func (*StmtComment) TypeCheck ¶
func (obj *StmtComment) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtEdge ¶
type StmtEdge struct { Textarea EdgeHalfList []*StmtEdgeHalf // represents a chain of edges // TODO: should notify be an Expr? Notify bool // specifies that this edge sends a notification as well // contains filtered or unexported fields }
StmtEdge is a representation of a dependency. It also supports send/recv. Edges represents that the first resource (Kind/Name) listed in the EdgeHalfList should happen in the resource graph *before* the next resource in the list. If there are multiple StmtEdgeHalf structs listed, then they should represent a chain, eg: a->b->c, should compile into a->b & b->c. If specified, values are sent and received along these edges if the Send/Recv names are compatible and listed. In this case of Send/Recv, only lists of length two are legal.
func (*StmtEdge) Apply ¶
func (obj *StmtEdge) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtEdge) Copy ¶
func (obj *StmtEdge) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtEdge) Graph ¶
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. It is interesting to note that nothing directly adds an edge to the edges created, but rather, once all the values (expressions) with no outgoing function graph edges have produced at least a single value, then the edges know they're able to be built.
func (*StmtEdge) Init ¶
func (obj *StmtEdge) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtEdge) Interpolate ¶
func (obj *StmtEdge) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. TODO: could we expand the Name's from the EdgeHalf (if they're lists) to have them return a list of Edges's ? XXX: type check the kind1:send -> kind2:recv fields are compatible! XXX: we won't know the names yet, but it's okay.
func (*StmtEdge) Ordering ¶
func (obj *StmtEdge) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtEdge) Output ¶
func (obj *StmtEdge) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output. In the case of this edge statement, this is definitely the case. This edge stmt returns output consisting of edges.
func (*StmtEdge) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtEdge) SetScope ¶
func (obj *StmtEdge) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtEdge) String ¶
String returns a short representation of this statement.
func (*StmtEdge) TypeCheck ¶
func (obj *StmtEdge) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtEdgeHalf ¶
type StmtEdgeHalf struct { Textarea Kind string // kind of resource, eg: pkg, file, svc, etc... Name interfaces.Expr // unique name for the res of this kind SendRecv string // name of field to send/recv from/to, empty to ignore // contains filtered or unexported fields }
StmtEdgeHalf represents half of an edge in the parsed edge representation. This does not satisfy the Stmt interface. The `Name` value can be a single string or a list of strings. The former will produce a single edge half, the latter produces a list of resources. Using this list mechanism is a safe alternative to traditional flow control like `for` loops. The `Name` value can only be a single string when it can be detected statically. Otherwise, it is assumed that a list of strings should be expected. More mechanisms to determine if the value is static may be added over time.
func (*StmtEdgeHalf) Apply ¶
func (obj *StmtEdgeHalf) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtEdgeHalf) Copy ¶
func (obj *StmtEdgeHalf) Copy() (*StmtEdgeHalf, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtEdgeHalf) Graph ¶
func (obj *StmtEdgeHalf) Graph(env *interfaces.Env) (*pgraph.Graph, error)
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. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.
func (*StmtEdgeHalf) Init ¶
func (obj *StmtEdgeHalf) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtEdgeHalf) Interpolate ¶
func (obj *StmtEdgeHalf) Interpolate() (*StmtEdgeHalf, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. This interpolate is different It is different from the interpolate found in the Expr and Stmt interfaces because it returns a different type as output.
func (*StmtEdgeHalf) SetScope ¶
func (obj *StmtEdgeHalf) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtEdgeHalf) String ¶
func (obj *StmtEdgeHalf) String() string
String returns a short representation of this statement.
func (*StmtEdgeHalf) TypeCheck ¶
func (obj *StmtEdgeHalf) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtFor ¶
type StmtFor struct { Textarea Index string // no $ prefix Value string // no $ prefix TypeIndex *types.Type TypeValue *types.Type Expr interfaces.Expr Body interfaces.Stmt // optional, but usually present // contains filtered or unexported fields }
StmtFor represents an iteration over a list. The body contains statements.
func (*StmtFor) Apply ¶
func (obj *StmtFor) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtFor) Copy ¶
func (obj *StmtFor) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtFor) Graph ¶
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 particular for statement has lots of complex magic to make it all work.
func (*StmtFor) Init ¶
func (obj *StmtFor) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtFor) Interpolate ¶
func (obj *StmtFor) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtFor) Ordering ¶
func (obj *StmtFor) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtFor) Output ¶
func (obj *StmtFor) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output.
func (*StmtFor) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtFor) SetScope ¶
func (obj *StmtFor) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtFor) String ¶
String returns a short representation of this statement.
func (*StmtFor) TypeCheck ¶
func (obj *StmtFor) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtForKV ¶
type StmtForKV struct { Textarea Key string // no $ prefix Val string // no $ prefix TypeKey *types.Type TypeVal *types.Type Expr interfaces.Expr Body interfaces.Stmt // optional, but usually present // contains filtered or unexported fields }
StmtForKV represents an iteration over a map. The body contains statements.
func (*StmtForKV) Apply ¶
func (obj *StmtForKV) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtForKV) Copy ¶
func (obj *StmtForKV) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtForKV) Graph ¶
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 particular for statement has lots of complex magic to make it all work.
func (*StmtForKV) Init ¶
func (obj *StmtForKV) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtForKV) Interpolate ¶
func (obj *StmtForKV) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtForKV) Ordering ¶
func (obj *StmtForKV) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtForKV) Output ¶
func (obj *StmtForKV) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output.
func (*StmtForKV) SetScope ¶
func (obj *StmtForKV) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtForKV) String ¶
String returns a short representation of this statement.
func (*StmtForKV) TypeCheck ¶
func (obj *StmtForKV) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtFunc ¶
type StmtFunc struct { Textarea Name string Func interfaces.Expr Type *types.Type // contains filtered or unexported fields }
StmtFunc represents a user defined function. It binds the specified name to the supplied function in the current scope and irrespective of the order of definition.
func (*StmtFunc) Apply ¶
func (obj *StmtFunc) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtFunc) Copy ¶
func (obj *StmtFunc) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtFunc) Graph ¶
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 particular func statement adds its linked expression to the graph.
func (*StmtFunc) Init ¶
func (obj *StmtFunc) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtFunc) Interpolate ¶
func (obj *StmtFunc) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtFunc) Ordering ¶
func (obj *StmtFunc) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in. We only really care about the consumers here, because the "produces" aspect of this resource is handled by the StmtProg Ordering function. This is because the "prog" allows out-of-order statements, therefore it solves this by running an early (second) loop through the program and peering into this Stmt and extracting the produced name.
func (*StmtFunc) Output ¶
func (obj *StmtFunc) Output(map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output for the func statement produces no output. Any values of interest come from the use of the func which this binds the function to.
func (*StmtFunc) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtFunc) SetScope ¶
func (obj *StmtFunc) SetScope(scope *interfaces.Scope) error
SetScope sets the scope of the child expression bound to it. It seems this is necessary in order to reach this, in particular in situations when a bound expression points to a previously bound expression.
func (*StmtFunc) String ¶
String returns a short representation of this statement.
func (*StmtFunc) TypeCheck ¶
func (obj *StmtFunc) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtIf ¶
type StmtIf struct { Textarea Condition interfaces.Expr ThenBranch interfaces.Stmt // optional, but usually present ElseBranch interfaces.Stmt // optional // contains filtered or unexported fields }
StmtIf represents an if condition that contains between one and two branches of statements to be executed based on the evaluation of the boolean condition over time. In particular, this is different from an ExprIf which returns a value, where as this produces some Output. Normally if one of the branches is optional, it is the else branch, although this struct allows either to be optional, even if it is not commonly used.
func (*StmtIf) Apply ¶
func (obj *StmtIf) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtIf) Copy ¶
func (obj *StmtIf) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtIf) Graph ¶
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 particular if statement doesn't do anything clever here other than adding in both branches of the graph. Since we're functional, this shouldn't have any ill effects. XXX: is this completely true if we're running technically impure, but safe built-in functions on both branches? Can we turn off half of this?
func (*StmtIf) Init ¶
func (obj *StmtIf) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtIf) Interpolate ¶
func (obj *StmtIf) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtIf) Ordering ¶
func (obj *StmtIf) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtIf) Output ¶
func (obj *StmtIf) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output.
func (*StmtIf) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtIf) SetScope ¶
func (obj *StmtIf) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtIf) String ¶
String returns a short representation of this statement.
func (*StmtIf) TypeCheck ¶
func (obj *StmtIf) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtImport ¶
type StmtImport struct { Textarea Name string Alias string // contains filtered or unexported fields }
StmtImport adds the exported scope definitions of a module into the current scope. It can be used anywhere a statement is allowed, and can even be nested inside a class definition. By convention, it is commonly used at the top of a file. As with any statement, it produces output, but that output is empty. To benefit from its inclusion, reference the scope definitions you want.
func (*StmtImport) Apply ¶
func (obj *StmtImport) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtImport) Copy ¶
func (obj *StmtImport) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtImport) Graph ¶
func (obj *StmtImport) Graph(*interfaces.Env) (*pgraph.Graph, error)
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 particular statement just returns an empty graph.
func (*StmtImport) Init ¶
func (obj *StmtImport) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtImport) Interpolate ¶
func (obj *StmtImport) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtImport) Ordering ¶
func (obj *StmtImport) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in. Nothing special happens in this method, the import magic happens in StmtProg.
func (*StmtImport) Output ¶
func (obj *StmtImport) Output(map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output returns the output that this include produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output. This import statement itself produces no output, as it is only used to populate the scope so that others can use that to produce values and output.
func (*StmtImport) ScopeGraph ¶
func (obj *StmtImport) ScopeGraph(g *pgraph.Graph)
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtImport) SetScope ¶
func (obj *StmtImport) SetScope(*interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtImport) String ¶
func (obj *StmtImport) String() string
String returns a short representation of this statement.
func (*StmtImport) TypeCheck ¶
func (obj *StmtImport) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtInclude ¶
type StmtInclude struct { Textarea Name string Args []interfaces.Expr Alias string // contains filtered or unexported fields }
StmtInclude causes a user defined class to get used. It's effectively the way to call a class except that it produces output instead of a value. Most of the interesting logic for classes happens here or in StmtProg.
func (*StmtInclude) Apply ¶
func (obj *StmtInclude) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtInclude) Copy ¶
func (obj *StmtInclude) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtInclude) Graph ¶
func (obj *StmtInclude) Graph(env *interfaces.Env) (*pgraph.Graph, error)
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 particular func statement adds its linked expression to the graph.
func (*StmtInclude) Init ¶
func (obj *StmtInclude) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtInclude) Interpolate ¶
func (obj *StmtInclude) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtInclude) Ordering ¶
func (obj *StmtInclude) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in. TODO: Is Ordering in StmtClass done properly and in sync with this?
func (*StmtInclude) Output ¶
func (obj *StmtInclude) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output returns the output that this include produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output. The ultimate source of this output comes from the previously defined StmtClass which should be found in our scope.
func (*StmtInclude) ScopeGraph ¶
func (obj *StmtInclude) ScopeGraph(g *pgraph.Graph)
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtInclude) SetScope ¶
func (obj *StmtInclude) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for use in this statement. Since this is the first location where recursion would play an important role, this also detects and handles the recursion scenario.
func (*StmtInclude) String ¶
func (obj *StmtInclude) String() string
String returns a short representation of this statement.
func (*StmtInclude) TypeCheck ¶
func (obj *StmtInclude) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtProg ¶
type StmtProg struct { Textarea Body []interfaces.Stmt // contains filtered or unexported fields }
StmtProg represents a list of stmt's. This usually occurs at the top-level of any program, and often within an if stmt. It also contains the logic so that the bind statement's are correctly applied in this scope, and irrespective of their order of definition.
func (*StmtProg) Apply ¶
func (obj *StmtProg) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtProg) Copy ¶
func (obj *StmtProg) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtProg) Graph ¶
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.
func (*StmtProg) Init ¶
func (obj *StmtProg) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtProg) Interpolate ¶
func (obj *StmtProg) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. This particular implementation can currently modify the source AST in-place, and then finally return a copy. This isn't ideal, but it is much more optimal as it avoids a lot of copying, and the code is simpler. If we need our AST to be static, then we can improve this.
func (*StmtProg) IsModuleUnsafe ¶
IsModuleUnsafe returns whether or not this StmtProg is unsafe to consume as a module scope. IOW, if someone writes a module which is imported and which has statements other than bind, func, class or import, then it is not correct to import, since those other elements wouldn't be used, and might provide a false belief that they'll get included when mgmt imports that module. SetScope should be called before this is used. (TODO: verify this) TODO: return a multierr with all the unsafe elements, to provide better info TODO: technically this could be a method on Stmt, possibly using Apply...
func (*StmtProg) Ordering ¶
func (obj *StmtProg) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in. The interesting part of the Ordering determination happens right here in StmtProg. This first looks at all the children to see what this produces, and then it recursively builds the graph by looking into all the children with this information from the first pass. We link production and consumption via a unique string name which is used to determine flow. Of particular note, all of this happens *before* SetScope, so we cannot follow references in the scope. The input to this method is a mapping of the the produced unique names in the parent "scope", to their associated node pointers. This returns a map of what is consumed in the child AST. The map is reversed, because two different nodes could consume the same variable key. TODO: deal with StmtImport's by returning them as first if necessary?
func (*StmtProg) Output ¶
func (obj *StmtProg) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output.
func (*StmtProg) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtProg) SetScope ¶
func (obj *StmtProg) SetScope(scope *interfaces.Scope) error
SetScope propagates the scope into its list of statements. It does so cleverly by first collecting all bind and func statements and adding those into the scope after checking for any collisions. Finally it pushes the new scope downwards to all child statements. If we support user defined function polymorphism via multiple function definition, then these are built together here. This SetScope is the one which follows the import statements. If it can't follow one (perhaps it wasn't downloaded yet, and is missing) then it leaves some information about these missing imports in the AST and errors, so that a subsequent AST traversal (usually via Apply) can collect this detailed information to be used by the downloader. When it propagates the scope downwards, it first pushes it into all the classes, and then into everything else (including the include stmt's) because the include statements require that the scope already be known so that it can be combined with the include args.
func (*StmtProg) String ¶
String returns a short representation of this statement.
func (*StmtProg) TypeCheck ¶
func (obj *StmtProg) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtRes ¶
type StmtRes struct { Textarea Kind string // kind of resource, eg: pkg, file, svc, etc... Name interfaces.Expr // unique name for the res of this kind Contents []StmtResContents // list of fields/edges in parsed order // contains filtered or unexported fields }
StmtRes is a representation of a resource and possibly some edges. The `Name` value can be a single string or a list of strings. The former will produce a single resource, the latter produces a list of resources. Using this list mechanism is a safe alternative to traditional flow control like `for` loops. The `Name` value can only be a single string when it can be detected statically. Otherwise, it is assumed that a list of strings should be expected. More mechanisms to determine if the value is static may be added over time. TODO: Consider expanding Name to have this return a list of Res's in the Output function if it is a map[name]struct{}, or even a map[[]name]struct{}.
func (*StmtRes) Apply ¶
func (obj *StmtRes) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtRes) Copy ¶
func (obj *StmtRes) Copy() (interfaces.Stmt, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtRes) Graph ¶
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. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.
This runs right after type unification. For this particular resource, we can do some additional static analysis, but only after unification has been done. Since I don't think it's worth extending the Stmt API for this, we can do the checks here at the beginning, and error out if something was invalid. In this particular case, the issue is one of catching duplicate meta fields.
func (*StmtRes) Init ¶
func (obj *StmtRes) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtRes) Interpolate ¶
func (obj *StmtRes) Interpolate() (interfaces.Stmt, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.
func (*StmtRes) Ordering ¶
func (obj *StmtRes) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtRes) Output ¶
func (obj *StmtRes) Output(table map[interfaces.Func]types.Value) (*interfaces.Output, error)
Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output. In the case of this resource statement, this is definitely the case.
func (*StmtRes) ScopeGraph ¶
ScopeGraph adds nodes and vertices to the supplied graph.
func (*StmtRes) SetScope ¶
func (obj *StmtRes) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtRes) String ¶
String returns a short representation of this statement.
func (*StmtRes) TypeCheck ¶
func (obj *StmtRes) TypeCheck() ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions.
type StmtResContents ¶
type StmtResContents interface { interfaces.Node Init(*interfaces.Data) error Interpolate() (StmtResContents, error) // different! Copy() (StmtResContents, error) Ordering(map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error) SetScope(*interfaces.Scope) error TypeCheck(kind string) ([]*interfaces.UnificationInvariant, error) Graph(env *interfaces.Env) (*pgraph.Graph, error) }
StmtResContents is the interface that is met by the resource contents. Look closely for while it is similar to the Stmt interface, it is quite different.
type StmtResEdge ¶
type StmtResEdge struct { Textarea Property string // TODO: iota constant instead? EdgeHalf *StmtEdgeHalf Condition interfaces.Expr // the value will be used if nil or true // contains filtered or unexported fields }
StmtResEdge represents a single edge property in the parsed resource representation. This does not satisfy the Stmt interface.
func (*StmtResEdge) Apply ¶
func (obj *StmtResEdge) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtResEdge) Copy ¶
func (obj *StmtResEdge) Copy() (StmtResContents, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtResEdge) Graph ¶
func (obj *StmtResEdge) Graph(env *interfaces.Env) (*pgraph.Graph, error)
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. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.
func (*StmtResEdge) Init ¶
func (obj *StmtResEdge) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtResEdge) Interpolate ¶
func (obj *StmtResEdge) Interpolate() (StmtResContents, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. This interpolate is different It is different from the interpolate found in the Expr and Stmt interfaces because it returns a different type as output.
func (*StmtResEdge) Ordering ¶
func (obj *StmtResEdge) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtResEdge) SetScope ¶
func (obj *StmtResEdge) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtResEdge) String ¶
func (obj *StmtResEdge) String() string
String returns a short representation of this statement.
func (*StmtResEdge) TypeCheck ¶
func (obj *StmtResEdge) TypeCheck(kind string) ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions. It is different from the TypeCheck method found in the Stmt interface because it adds an input parameter.
type StmtResField ¶
type StmtResField struct { Textarea Field string Value interfaces.Expr Condition interfaces.Expr // the value will be used if nil or true // contains filtered or unexported fields }
StmtResField represents a single field in the parsed resource representation. This does not satisfy the Stmt interface.
func (*StmtResField) Apply ¶
func (obj *StmtResField) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtResField) Copy ¶
func (obj *StmtResField) Copy() (StmtResContents, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtResField) Graph ¶
func (obj *StmtResField) Graph(env *interfaces.Env) (*pgraph.Graph, error)
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. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.
func (*StmtResField) Init ¶
func (obj *StmtResField) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtResField) Interpolate ¶
func (obj *StmtResField) Interpolate() (StmtResContents, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. This interpolate is different It is different from the interpolate found in the Expr and Stmt interfaces because it returns a different type as output.
func (*StmtResField) Ordering ¶
func (obj *StmtResField) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtResField) SetScope ¶
func (obj *StmtResField) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtResField) String ¶
func (obj *StmtResField) String() string
String returns a short representation of this statement.
func (*StmtResField) TypeCheck ¶
func (obj *StmtResField) TypeCheck(kind string) ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions. It is different from the TypeCheck method found in the Stmt interface because it adds an input parameter.
type StmtResMeta ¶
type StmtResMeta struct { Textarea Property string // TODO: iota constant instead? MetaExpr interfaces.Expr Condition interfaces.Expr // the value will be used if nil or true // contains filtered or unexported fields }
StmtResMeta represents a single meta value in the parsed resource representation. It can also contain a struct that contains one or more meta parameters. If it contains such a struct, then the `Property` field contains the string found in the MetaField constant, otherwise this field will correspond to the particular meta parameter specified. This does not satisfy the Stmt interface.
func (*StmtResMeta) Apply ¶
func (obj *StmtResMeta) Apply(fn func(interfaces.Node) error) error
Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only apply to a select number of node types, since they won't need extra noop iterators...
func (*StmtResMeta) Copy ¶
func (obj *StmtResMeta) Copy() (StmtResContents, error)
Copy returns a light copy of this struct. Anything static will not be copied.
func (*StmtResMeta) Graph ¶
func (obj *StmtResMeta) Graph(env *interfaces.Env) (*pgraph.Graph, error)
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. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.
func (*StmtResMeta) Init ¶
func (obj *StmtResMeta) Init(data *interfaces.Data) error
Init initializes this branch of the AST, and returns an error if it fails to validate.
func (*StmtResMeta) Interpolate ¶
func (obj *StmtResMeta) Interpolate() (StmtResContents, error)
Interpolate returns a new node (aka a copy) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. This interpolate is different It is different from the interpolate found in the Expr and Stmt interfaces because it returns a different type as output.
func (*StmtResMeta) Ordering ¶
func (obj *StmtResMeta) Ordering(produces map[string]interfaces.Node) (*pgraph.Graph, map[interfaces.Node]string, error)
Ordering returns a graph of the scope ordering that represents the data flow. This can be used in SetScope so that it knows the correct order to run it in.
func (*StmtResMeta) SetScope ¶
func (obj *StmtResMeta) SetScope(scope *interfaces.Scope) error
SetScope stores the scope for later use in this resource and its children, which it propagates this downwards to.
func (*StmtResMeta) String ¶
func (obj *StmtResMeta) String() string
String returns a short representation of this statement.
func (*StmtResMeta) TypeCheck ¶
func (obj *StmtResMeta) TypeCheck(kind string) ([]*interfaces.UnificationInvariant, error)
TypeCheck returns the list of invariants that this node produces. It does so recursively on any children elements that exist in the AST, and returns the collection to the caller. It calls TypeCheck for child statements, and Infer/Check for child expressions. It is different from the TypeCheck method found in the Stmt interface because it adds an input parameter.
type Textarea ¶
type Textarea struct { // Bug5819 works around issue https://github.com/golang/go/issues/5819 Bug5819 interface{} // XXX: workaround // contains filtered or unexported fields }
Textarea stores the coordinates of a statement or expression in the form of a starting line/column and ending line/column.
func (*Textarea) Byline ¶
Byline gives a succinct representation of the Textarea, but is useful only in debugging. In order to generate pretty error messages, see HighlightText.
func (*Textarea) End ¶
End returns the end line/column of an AST node.
func (*Textarea) Filename ¶
Filename returns the printable filename that we'd like to display. It tries to return a relative version if possible.
func (*Textarea) HighlightText ¶
HighlightText generates a generic description that just visually indicates part of the line described by a Textarea. If the coordinates that are passed span multiple lines, don't show those lines, but just a description of the area. If it can't generate a valid snippet, then it returns the empty string.
func (*Textarea) IsSet ¶
IsSet returns if the position was already set with Locate already.
func (*Textarea) Locate ¶
Locate is used by the parser to store the token positions in AST nodes. The path will be filled during AST node initialization usually, because the parser does not know the name of the file it is processing.
func (*Textarea) Path ¶
Path returns the name of the source file that holds the code for an AST node.
func (*Textarea) Pos ¶
Pos returns the starting line/column of an AST node.
func (*Textarea) Setup ¶
func (obj *Textarea) Setup(data *interfaces.Data)
Setup is used during AST initialization in order to store in each AST node the name of the source file from which it was generated.
Source Files ¶
scopegraph.go structs.go util.go
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 26 packages
- Last checked
- 4 days ago –
Tools for package owners.