Documentation ¶
Overview ¶
The semantic package provides a graph structure that represents the meaning of a Flux script. An AST is converted into a semantic graph for use with other systems. Using a semantic graph representation of the Flux, enables highlevel meaning to be specified programatically.
The semantic structures are to be designed to facilitate the interpretation and compilation of Flux.
For example since Flux uses the javascript AST structures, arguments to a function are represented as a single positional argument that is always an object expression. The semantic graph validates that the AST correctly follows these semantics, and use structures that are strongly typed for this expectation.
Index ¶
- Constants
- Variables
- func Formatted(n Node, opts ...FormatOption) fmt.Formatter
- func SortNodes(nodes []Node)
- func Walk(v Visitor, node Node)
- type Addable
- type Annotator
- type ArrayExpression
- func (e *ArrayExpression) Copy() Node
- func (rcv *ArrayExpression) FromBuf(fb *fbsemantic.ArrayExpression) error
- func (l ArrayExpression) Location() ast.SourceLocation
- func (e *ArrayExpression) MarshalJSON() ([]byte, error)
- func (*ArrayExpression) NodeType() string
- func (e *ArrayExpression) TypeOf() *types.MonoType
- func (e *ArrayExpression) UnmarshalJSON(data []byte) error
- type Assignment
- type BinaryExpression
- func (e *BinaryExpression) Copy() Node
- func (rcv *BinaryExpression) FromBuf(fb *fbsemantic.BinaryExpression) error
- func (l BinaryExpression) Location() ast.SourceLocation
- func (e *BinaryExpression) MarshalJSON() ([]byte, error)
- func (*BinaryExpression) NodeType() string
- func (e *BinaryExpression) TypeOf() *types.MonoType
- func (e *BinaryExpression) UnmarshalJSON(data []byte) error
- type Block
- func (s *Block) Copy() Node
- func (rcv *Block) FromBuf(fb *fbsemantic.Block) error
- func (l Block) Location() ast.SourceLocation
- func (s *Block) MarshalJSON() ([]byte, error)
- func (*Block) NodeType() string
- func (s *Block) ReturnStatement() *ReturnStatement
- func (s *Block) UnmarshalJSON(data []byte) error
- type BooleanLiteral
- func (l *BooleanLiteral) Copy() Node
- func (rcv *BooleanLiteral) FromBuf(fb *fbsemantic.BooleanLiteral) error
- func (l BooleanLiteral) Location() ast.SourceLocation
- func (l *BooleanLiteral) MarshalJSON() ([]byte, error)
- func (*BooleanLiteral) NodeType() string
- func (e *BooleanLiteral) TypeOf() *types.MonoType
- type BuiltinStatement
- type CallExpression
- func (e *CallExpression) Copy() Node
- func (rcv *CallExpression) FromBuf(fb *fbsemantic.CallExpression) error
- func (l CallExpression) Location() ast.SourceLocation
- func (e *CallExpression) MarshalJSON() ([]byte, error)
- func (*CallExpression) NodeType() string
- func (e *CallExpression) TypeOf() *types.MonoType
- func (e *CallExpression) UnmarshalJSON(data []byte) error
- type Comparable
- type ConditionalExpression
- func (e *ConditionalExpression) Copy() Node
- func (rcv *ConditionalExpression) FromBuf(fb *fbsemantic.ConditionalExpression) error
- func (l ConditionalExpression) Location() ast.SourceLocation
- func (e *ConditionalExpression) MarshalJSON() ([]byte, error)
- func (*ConditionalExpression) NodeType() string
- func (e *ConditionalExpression) TypeOf() *types.MonoType
- func (e *ConditionalExpression) UnmarshalJSON(data []byte) error
- type ConstraintGenerator
- type Constraints
- type DateTimeLiteral
- func (l *DateTimeLiteral) Copy() Node
- func (rcv *DateTimeLiteral) FromBuf(fb *fbsemantic.DateTimeLiteral) error
- func (l DateTimeLiteral) Location() ast.SourceLocation
- func (l *DateTimeLiteral) MarshalJSON() ([]byte, error)
- func (*DateTimeLiteral) NodeType() string
- func (e *DateTimeLiteral) TypeOf() *types.MonoType
- type DurationLiteral
- func (l *DurationLiteral) Copy() Node
- func (rcv *DurationLiteral) FromBuf(fb *fbsemantic.DurationLiteral) error
- func (l DurationLiteral) Location() ast.SourceLocation
- func (l *DurationLiteral) MarshalJSON() ([]byte, error)
- func (*DurationLiteral) NodeType() string
- func (e *DurationLiteral) TypeOf() *types.MonoType
- type Env
- type Expression
- type ExpressionStatement
- func (s *ExpressionStatement) Copy() Node
- func (rcv *ExpressionStatement) FromBuf(fb *fbsemantic.ExpressionStatement) error
- func (l ExpressionStatement) Location() ast.SourceLocation
- func (s *ExpressionStatement) MarshalJSON() ([]byte, error)
- func (*ExpressionStatement) NodeType() string
- func (s *ExpressionStatement) UnmarshalJSON(data []byte) error
- type Extern
- type ExternBlock
- type ExternalVariableAssignment
- func (s *ExternalVariableAssignment) Copy() Node
- func (l *ExternalVariableAssignment) FromBuf(fb *fbsemantic.SourceLocation) error
- func (l ExternalVariableAssignment) Location() ast.SourceLocation
- func (d *ExternalVariableAssignment) MarshalJSON() ([]byte, error)
- func (*ExternalVariableAssignment) NodeType() string
- type File
- type FloatLiteral
- type FormatOption
- type Fresher
- type FunctionBlock
- func (b *FunctionBlock) Copy() Node
- func (l *FunctionBlock) FromBuf(fb *fbsemantic.SourceLocation) error
- func (l FunctionBlock) Location() ast.SourceLocation
- func (e *FunctionBlock) MarshalJSON() ([]byte, error)
- func (*FunctionBlock) NodeType() string
- func (e *FunctionBlock) UnmarshalJSON(data []byte) error
- type FunctionExpression
- func (e *FunctionExpression) Copy() Node
- func (e *FunctionExpression) FromBuf(fb *fbsemantic.FunctionExpression) error
- func (l FunctionExpression) Location() ast.SourceLocation
- func (e *FunctionExpression) MarshalJSON() ([]byte, error)
- func (*FunctionExpression) NodeType() string
- func (e *FunctionExpression) TypeOf() *types.MonoType
- type FunctionParameter
- type FunctionParameters
- type FunctionPolySignature
- type FunctionSignature
- type Identifier
- type IdentifierExpression
- func (e *IdentifierExpression) Copy() Node
- func (rcv *IdentifierExpression) FromBuf(fb *fbsemantic.IdentifierExpression) error
- func (l IdentifierExpression) Location() ast.SourceLocation
- func (e *IdentifierExpression) MarshalJSON() ([]byte, error)
- func (*IdentifierExpression) NodeType() string
- func (e *IdentifierExpression) TypeOf() *types.MonoType
- type ImportDeclaration
- type Importer
- type IndexExpression
- func (e *IndexExpression) Copy() Node
- func (rcv *IndexExpression) FromBuf(fb *fbsemantic.IndexExpression) error
- func (l IndexExpression) Location() ast.SourceLocation
- func (e *IndexExpression) MarshalJSON() ([]byte, error)
- func (*IndexExpression) NodeType() string
- func (e *IndexExpression) TypeOf() *types.MonoType
- func (e *IndexExpression) UnmarshalJSON(data []byte) error
- type IntegerLiteral
- func (l *IntegerLiteral) Copy() Node
- func (rcv *IntegerLiteral) FromBuf(fb *fbsemantic.IntegerLiteral) error
- func (l IntegerLiteral) Location() ast.SourceLocation
- func (l *IntegerLiteral) MarshalJSON() ([]byte, error)
- func (*IntegerLiteral) NodeType() string
- func (e *IntegerLiteral) TypeOf() *types.MonoType
- func (l *IntegerLiteral) UnmarshalJSON(data []byte) error
- type InterpolatedPart
- func (p *InterpolatedPart) Copy() Node
- func (l *InterpolatedPart) FromBuf(fb *fbsemantic.SourceLocation) error
- func (l InterpolatedPart) Location() ast.SourceLocation
- func (e *InterpolatedPart) MarshalJSON() ([]byte, error)
- func (*InterpolatedPart) NodeType() string
- func (e *InterpolatedPart) UnmarshalJSON(data []byte) error
- type KClass
- type Kind
- type KindConstrainter
- type LabelSet
- type Literal
- type LogicalExpression
- func (e *LogicalExpression) Copy() Node
- func (rcv *LogicalExpression) FromBuf(fb *fbsemantic.LogicalExpression) error
- func (l LogicalExpression) Location() ast.SourceLocation
- func (e *LogicalExpression) MarshalJSON() ([]byte, error)
- func (*LogicalExpression) NodeType() string
- func (e *LogicalExpression) TypeOf() *types.MonoType
- func (e *LogicalExpression) UnmarshalJSON(data []byte) error
- type MemberAssignment
- func (s *MemberAssignment) Copy() Node
- func (rcv *MemberAssignment) FromBuf(fb *fbsemantic.MemberAssignment) error
- func (l MemberAssignment) Location() ast.SourceLocation
- func (s *MemberAssignment) MarshalJSON() ([]byte, error)
- func (*MemberAssignment) NodeType() string
- func (s *MemberAssignment) UnmarshalJSON(data []byte) error
- type MemberExpression
- func (e *MemberExpression) Copy() Node
- func (rcv *MemberExpression) FromBuf(fb *fbsemantic.MemberExpression) error
- func (l MemberExpression) Location() ast.SourceLocation
- func (e *MemberExpression) MarshalJSON() ([]byte, error)
- func (*MemberExpression) NodeType() string
- func (e *MemberExpression) TypeOf() *types.MonoType
- func (e *MemberExpression) UnmarshalJSON(data []byte) error
- type NativeVariableAssignment
- func (s *NativeVariableAssignment) Copy() Node
- func (rcv *NativeVariableAssignment) FromBuf(fb *fbsemantic.NativeVariableAssignment) error
- func (l NativeVariableAssignment) Location() ast.SourceLocation
- func (d *NativeVariableAssignment) MarshalJSON() ([]byte, error)
- func (*NativeVariableAssignment) NodeType() string
- func (d *NativeVariableAssignment) UnmarshalJSON(data []byte) error
- type Nature
- func (n Nature) ElementType() Type
- func (n Nature) Equal(t PolyType) bool
- func (n Nature) FunctionSignature() FunctionSignature
- func (n Nature) MonoType() (Type, bool)
- func (n Nature) Nature() Nature
- func (n Nature) PolyType() PolyType
- func (n Nature) Properties() map[string]Type
- func (n Nature) PropertyType(name string) Type
- func (n Nature) String() string
- type NestingVisitor
- type Node
- type NullableKind
- type NullableTvar
- type Number
- type ObjectExpression
- func (e *ObjectExpression) Copy() Node
- func (rcv *ObjectExpression) FromBuf(fb *fbsemantic.ObjectExpression) error
- func (l ObjectExpression) Location() ast.SourceLocation
- func (e *ObjectExpression) MarshalJSON() ([]byte, error)
- func (*ObjectExpression) NodeType() string
- func (e *ObjectExpression) TypeOf() *types.MonoType
- type ObjectKind
- type OptionStatement
- func (s *OptionStatement) Copy() Node
- func (rcv *OptionStatement) FromBuf(fb *fbsemantic.OptionStatement) error
- func (l OptionStatement) Location() ast.SourceLocation
- func (s *OptionStatement) MarshalJSON() ([]byte, error)
- func (s *OptionStatement) NodeType() string
- func (s *OptionStatement) UnmarshalJSON(data []byte) error
- type Package
- type PackageClause
- type PackageType
- type PolyType
- type Property
- type PropertyKey
- type RegexpLiteral
- func (l *RegexpLiteral) Copy() Node
- func (rcv *RegexpLiteral) FromBuf(fb *fbsemantic.RegexpLiteral) error
- func (l RegexpLiteral) Location() ast.SourceLocation
- func (l *RegexpLiteral) MarshalJSON() ([]byte, error)
- func (*RegexpLiteral) NodeType() string
- func (e *RegexpLiteral) TypeOf() *types.MonoType
- func (l *RegexpLiteral) UnmarshalJSON(data []byte) error
- type ReturnStatement
- func (s *ReturnStatement) Copy() Node
- func (rcv *ReturnStatement) FromBuf(fb *fbsemantic.ReturnStatement) error
- func (l ReturnStatement) Location() ast.SourceLocation
- func (s *ReturnStatement) MarshalJSON() ([]byte, error)
- func (*ReturnStatement) NodeType() string
- func (s *ReturnStatement) UnmarshalJSON(data []byte) error
- type Scheme
- type ScopedVisitor
- type Solution
- type SolutionMap
- type Statement
- type StringExpression
- func (e *StringExpression) Copy() Node
- func (rcv *StringExpression) FromBuf(fb *fbsemantic.StringExpression) error
- func (l StringExpression) Location() ast.SourceLocation
- func (e *StringExpression) MarshalJSON() ([]byte, error)
- func (*StringExpression) NodeType() string
- func (e *StringExpression) TypeOf() *types.MonoType
- func (e *StringExpression) UnmarshalJSON(data []byte) error
- type StringExpressionPart
- type StringLiteral
- func (l *StringLiteral) Copy() Node
- func (rcv *StringLiteral) FromBuf(fb *fbsemantic.StringLiteral) error
- func (n *StringLiteral) Key() string
- func (l StringLiteral) Location() ast.SourceLocation
- func (l *StringLiteral) MarshalJSON() ([]byte, error)
- func (*StringLiteral) NodeType() string
- func (e *StringLiteral) TypeOf() *types.MonoType
- type Substitution
- func (s Substitution) ApplyEnv(env *Env) *Env
- func (s Substitution) ApplyKind(k Kind) Kind
- func (s Substitution) ApplyScheme(ts Scheme) Scheme
- func (s Substitution) ApplyTvar(tv Tvar) Tvar
- func (s Substitution) ApplyType(t PolyType) PolyType
- func (l Substitution) Merge(r Substitution)
- func (s Substitution) String() string
- type TestStatement
- type TextPart
- type Tvar
- type TvarSet
- type Type
- type TypeConstraint
- type TypeExpression
- type TypeSolution
- type UnaryExpression
- func (e *UnaryExpression) Copy() Node
- func (rcv *UnaryExpression) FromBuf(fb *fbsemantic.UnaryExpression) error
- func (l UnaryExpression) Location() ast.SourceLocation
- func (e *UnaryExpression) MarshalJSON() ([]byte, error)
- func (*UnaryExpression) NodeType() string
- func (e *UnaryExpression) TypeOf() *types.MonoType
- func (e *UnaryExpression) UnmarshalJSON(data []byte) error
- type UnsignedIntegerLiteral
- func (l *UnsignedIntegerLiteral) Copy() Node
- func (rcv *UnsignedIntegerLiteral) FromBuf(fb *fbsemantic.UnsignedIntegerLiteral) error
- func (l UnsignedIntegerLiteral) Location() ast.SourceLocation
- func (l *UnsignedIntegerLiteral) MarshalJSON() ([]byte, error)
- func (*UnsignedIntegerLiteral) NodeType() string
- func (e *UnsignedIntegerLiteral) TypeOf() *types.MonoType
- func (l *UnsignedIntegerLiteral) UnmarshalJSON(data []byte) error
- type Visitor
Constants ¶
const PackageMain = "main"
Variables ¶
var EmptyArrayType = NewArrayType(Nil)
TODO(nathanielc): Make empty array types polymorphic over element type?
var EmptyObject = NewObjectType(nil)
Functions ¶
func Formatted ¶ added in v0.50.0
func Formatted(n Node, opts ...FormatOption) fmt.Formatter
Formatted produces a Formatter object suitable for printing using the standard fmt package. Currently only works for some expressions.
Types ¶
type Annotator ¶
type Annotator struct {
// contains filtered or unexported fields
}
Annotator implements Visitor to walk the graph.
type ArrayExpression ¶
type ArrayExpression struct { Elements []Expression `json:"elements"` // contains filtered or unexported fields }
func (*ArrayExpression) Copy ¶
func (e *ArrayExpression) Copy() Node
func (*ArrayExpression) FromBuf ¶ added in v0.57.0
func (rcv *ArrayExpression) FromBuf(fb *fbsemantic.ArrayExpression) error
func (ArrayExpression) Location ¶
func (l ArrayExpression) Location() ast.SourceLocation
func (*ArrayExpression) MarshalJSON ¶
func (e *ArrayExpression) MarshalJSON() ([]byte, error)
func (*ArrayExpression) NodeType ¶
func (*ArrayExpression) NodeType() string
func (*ArrayExpression) TypeOf ¶ added in v0.58.0
func (e *ArrayExpression) TypeOf() *types.MonoType
func (*ArrayExpression) UnmarshalJSON ¶
func (e *ArrayExpression) UnmarshalJSON(data []byte) error
type Assignment ¶ added in v0.14.0
type Assignment interface { Statement // contains filtered or unexported methods }
type BinaryExpression ¶
type BinaryExpression struct { Operator ast.OperatorKind `json:"operator"` Left Expression `json:"left"` Right Expression `json:"right"` // contains filtered or unexported fields }
func (*BinaryExpression) Copy ¶
func (e *BinaryExpression) Copy() Node
func (*BinaryExpression) FromBuf ¶ added in v0.57.0
func (rcv *BinaryExpression) FromBuf(fb *fbsemantic.BinaryExpression) error
func (BinaryExpression) Location ¶
func (l BinaryExpression) Location() ast.SourceLocation
func (*BinaryExpression) MarshalJSON ¶
func (e *BinaryExpression) MarshalJSON() ([]byte, error)
func (*BinaryExpression) NodeType ¶
func (*BinaryExpression) NodeType() string
func (*BinaryExpression) TypeOf ¶ added in v0.58.0
func (e *BinaryExpression) TypeOf() *types.MonoType
func (*BinaryExpression) UnmarshalJSON ¶
func (e *BinaryExpression) UnmarshalJSON(data []byte) error
type Block ¶ added in v0.8.0
type Block struct { Body []Statement `json:"body"` // contains filtered or unexported fields }
func (Block) Location ¶ added in v0.8.0
func (l Block) Location() ast.SourceLocation
func (*Block) MarshalJSON ¶ added in v0.8.0
func (*Block) ReturnStatement ¶ added in v0.8.0
func (s *Block) ReturnStatement() *ReturnStatement
func (*Block) UnmarshalJSON ¶ added in v0.8.0
type BooleanLiteral ¶
type BooleanLiteral struct { Value bool `json:"value"` // contains filtered or unexported fields }
func (*BooleanLiteral) Copy ¶
func (l *BooleanLiteral) Copy() Node
func (*BooleanLiteral) FromBuf ¶ added in v0.57.0
func (rcv *BooleanLiteral) FromBuf(fb *fbsemantic.BooleanLiteral) error
func (BooleanLiteral) Location ¶
func (l BooleanLiteral) Location() ast.SourceLocation
func (*BooleanLiteral) MarshalJSON ¶
func (l *BooleanLiteral) MarshalJSON() ([]byte, error)
func (*BooleanLiteral) NodeType ¶
func (*BooleanLiteral) NodeType() string
func (*BooleanLiteral) TypeOf ¶ added in v0.58.0
func (e *BooleanLiteral) TypeOf() *types.MonoType
type BuiltinStatement ¶ added in v0.14.0
type BuiltinStatement struct { ID *Identifier `json:"id"` // contains filtered or unexported fields }
func (*BuiltinStatement) Copy ¶ added in v0.14.0
func (s *BuiltinStatement) Copy() Node
func (*BuiltinStatement) FromBuf ¶ added in v0.57.0
func (rcv *BuiltinStatement) FromBuf(fb *fbsemantic.BuiltinStatement) error
func (BuiltinStatement) Location ¶ added in v0.14.0
func (l BuiltinStatement) Location() ast.SourceLocation
func (*BuiltinStatement) MarshalJSON ¶ added in v0.14.0
func (s *BuiltinStatement) MarshalJSON() ([]byte, error)
func (*BuiltinStatement) NodeType ¶ added in v0.14.0
func (s *BuiltinStatement) NodeType() string
type CallExpression ¶
type CallExpression struct { Callee Expression `json:"callee"` Arguments *ObjectExpression `json:"arguments"` Pipe Expression `json:"pipe,omitempty"` // contains filtered or unexported fields }
func (*CallExpression) Copy ¶
func (e *CallExpression) Copy() Node
func (*CallExpression) FromBuf ¶ added in v0.57.0
func (rcv *CallExpression) FromBuf(fb *fbsemantic.CallExpression) error
func (CallExpression) Location ¶
func (l CallExpression) Location() ast.SourceLocation
func (*CallExpression) MarshalJSON ¶
func (e *CallExpression) MarshalJSON() ([]byte, error)
func (*CallExpression) NodeType ¶
func (*CallExpression) NodeType() string
func (*CallExpression) TypeOf ¶ added in v0.58.0
func (e *CallExpression) TypeOf() *types.MonoType
func (*CallExpression) UnmarshalJSON ¶
func (e *CallExpression) UnmarshalJSON(data []byte) error
type Comparable ¶
type Comparable struct{}
type ConditionalExpression ¶
type ConditionalExpression struct { Test Expression `json:"test"` Alternate Expression `json:"alternate"` Consequent Expression `json:"consequent"` // contains filtered or unexported fields }
func (*ConditionalExpression) Copy ¶
func (e *ConditionalExpression) Copy() Node
func (*ConditionalExpression) FromBuf ¶ added in v0.57.0
func (rcv *ConditionalExpression) FromBuf(fb *fbsemantic.ConditionalExpression) error
func (ConditionalExpression) Location ¶
func (l ConditionalExpression) Location() ast.SourceLocation
func (*ConditionalExpression) MarshalJSON ¶
func (e *ConditionalExpression) MarshalJSON() ([]byte, error)
func (*ConditionalExpression) NodeType ¶
func (*ConditionalExpression) NodeType() string
func (*ConditionalExpression) TypeOf ¶ added in v0.58.0
func (e *ConditionalExpression) TypeOf() *types.MonoType
func (*ConditionalExpression) UnmarshalJSON ¶
func (e *ConditionalExpression) UnmarshalJSON(data []byte) error
type ConstraintGenerator ¶
type ConstraintGenerator struct {
// contains filtered or unexported fields
}
ConstraintGenerator implements NestingVisitor and generates constraints as it walks the graph.
func (ConstraintGenerator) Done ¶
func (v ConstraintGenerator) Done(node Node)
Done visits nodes after all children of the node have been visited.
func (ConstraintGenerator) Nest ¶
func (v ConstraintGenerator) Nest() NestingVisitor
Nest nests the internal type environment to obey scoping rules.
func (ConstraintGenerator) Visit ¶
func (v ConstraintGenerator) Visit(node Node) Visitor
Visit visits each node, the algorithm is depth first so nothing is performed in Visit except for an error check.
type Constraints ¶
type Constraints struct {
// contains filtered or unexported fields
}
Constraints is a set of constraints.
func GenerateConstraints ¶
func GenerateConstraints(node Node, annotator Annotator, importer Importer) (*Constraints, error)
GenerateConstraints walks the graph and generates constraints between type vairables provided in the annotations.
func (*Constraints) AddKindConst ¶
func (c *Constraints) AddKindConst(tv Tvar, k Kind)
func (*Constraints) AddTypeConst ¶
func (c *Constraints) AddTypeConst(l, r PolyType, loc ast.SourceLocation)
func (*Constraints) Copy ¶
func (c *Constraints) Copy() *Constraints
func (*Constraints) Instantiate ¶
func (c *Constraints) Instantiate(s Scheme, loc ast.SourceLocation) (t PolyType)
Instantiate produces a new poly type where the free variables from the scheme have been made fresh. This way each new instantiation of a scheme is independent of the other but all have the same constraint structure.
func (*Constraints) String ¶
func (c *Constraints) String() string
type DateTimeLiteral ¶
type DateTimeLiteral struct { Value time.Time `json:"value"` // contains filtered or unexported fields }
func (*DateTimeLiteral) Copy ¶
func (l *DateTimeLiteral) Copy() Node
func (*DateTimeLiteral) FromBuf ¶ added in v0.57.0
func (rcv *DateTimeLiteral) FromBuf(fb *fbsemantic.DateTimeLiteral) error
func (DateTimeLiteral) Location ¶
func (l DateTimeLiteral) Location() ast.SourceLocation
func (*DateTimeLiteral) MarshalJSON ¶
func (l *DateTimeLiteral) MarshalJSON() ([]byte, error)
func (*DateTimeLiteral) NodeType ¶
func (*DateTimeLiteral) NodeType() string
func (*DateTimeLiteral) TypeOf ¶ added in v0.58.0
func (e *DateTimeLiteral) TypeOf() *types.MonoType
type DurationLiteral ¶
type DurationLiteral struct { Values []ast.Duration `json:"values"` // contains filtered or unexported fields }
func (*DurationLiteral) Copy ¶
func (l *DurationLiteral) Copy() Node
func (*DurationLiteral) FromBuf ¶ added in v0.57.0
func (rcv *DurationLiteral) FromBuf(fb *fbsemantic.DurationLiteral) error
func (DurationLiteral) Location ¶
func (l DurationLiteral) Location() ast.SourceLocation
func (*DurationLiteral) MarshalJSON ¶
func (l *DurationLiteral) MarshalJSON() ([]byte, error)
func (*DurationLiteral) NodeType ¶
func (*DurationLiteral) NodeType() string
func (*DurationLiteral) TypeOf ¶ added in v0.58.0
func (e *DurationLiteral) TypeOf() *types.MonoType
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is a type environment mapping identifiers in scope to their type schemes.
func (*Env) LocalLookup ¶
LocalLookup search for the identifier in the local scope only, it does not recurse to parents.
type Expression ¶
type Expression interface { Node TypeOf() *types.MonoType // contains filtered or unexported methods }
func ConjunctionsToExprSlice ¶
func ConjunctionsToExprSlice(expr Expression) []Expression
ConjunctionsToExprSlice finds all children of AndOperators that are not themselves AndOperators, and returns them in a slice. If the root node of expr is not an AndOperator, just returns expr.
AND / \ AND r => {p, q, r} / \ p q
func ExprsToConjunction ¶
func ExprsToConjunction(exprs ...Expression) Expression
ExprsToConjunction accepts a variable number of expressions and ANDs them together into a single expression.
AND / \ {p, q, r} => AND r / \ p q
func PartitionPredicates ¶
func PartitionPredicates(expr Expression, partitionFn func(expression Expression) (bool, error)) (passExpr, failExpr Expression, err error)
PartitionPredicates accepts a predicate expression, separates it into components that have been logically ANDed together, and applies partitionFn to them. Returns two expressions: one AND tree of the expressions for which partitionFn returned true, and an AND tree of expressions for which partitionFn returned false.
Suppose partitonFn returns true for p and r, and false for q:
AND passExpr failExpr / \ AND r => AND q / \ / \ p q p r
type ExpressionStatement ¶
type ExpressionStatement struct { Expression Expression `json:"expression"` // contains filtered or unexported fields }
func (*ExpressionStatement) Copy ¶
func (s *ExpressionStatement) Copy() Node
func (*ExpressionStatement) FromBuf ¶ added in v0.57.0
func (rcv *ExpressionStatement) FromBuf(fb *fbsemantic.ExpressionStatement) error
func (ExpressionStatement) Location ¶
func (l ExpressionStatement) Location() ast.SourceLocation
func (*ExpressionStatement) MarshalJSON ¶
func (s *ExpressionStatement) MarshalJSON() ([]byte, error)
func (*ExpressionStatement) NodeType ¶
func (*ExpressionStatement) NodeType() string
func (*ExpressionStatement) UnmarshalJSON ¶
func (s *ExpressionStatement) UnmarshalJSON(data []byte) error
type Extern ¶
type Extern struct { Assignments []*ExternalVariableAssignment `json:"assignments"` Block *ExternBlock `json:"block"` // contains filtered or unexported fields }
Extern is a node that represents a node with a set of external assignments defined.
func (*Extern) FromBuf ¶ added in v0.57.0
func (l *Extern) FromBuf(fb *fbsemantic.SourceLocation) error
func (Extern) Location ¶
func (l Extern) Location() ast.SourceLocation
func (*Extern) MarshalJSON ¶
type ExternBlock ¶
type ExternBlock struct { Node Node // contains filtered or unexported fields }
ExternBlock is a node that represents a node with a set of external declarations defined.
func (*ExternBlock) Copy ¶
func (e *ExternBlock) Copy() Node
func (*ExternBlock) FromBuf ¶ added in v0.57.0
func (l *ExternBlock) FromBuf(fb *fbsemantic.SourceLocation) error
func (ExternBlock) Location ¶
func (l ExternBlock) Location() ast.SourceLocation
func (*ExternBlock) MarshalJSON ¶
func (e *ExternBlock) MarshalJSON() ([]byte, error)
func (*ExternBlock) NodeType ¶
func (*ExternBlock) NodeType() string
func (*ExternBlock) UnmarshalJSON ¶
func (e *ExternBlock) UnmarshalJSON(data []byte) error
type ExternalVariableAssignment ¶ added in v0.8.0
type ExternalVariableAssignment struct { Identifier *Identifier `json:"identifier"` ExternType PolyType `json:""` // contains filtered or unexported fields }
ExternalVariableAssignment represents an externaly defined identifier and its type.
func (*ExternalVariableAssignment) Copy ¶ added in v0.8.0
func (s *ExternalVariableAssignment) Copy() Node
func (*ExternalVariableAssignment) FromBuf ¶ added in v0.57.0
func (l *ExternalVariableAssignment) FromBuf(fb *fbsemantic.SourceLocation) error
func (ExternalVariableAssignment) Location ¶ added in v0.8.0
func (l ExternalVariableAssignment) Location() ast.SourceLocation
func (*ExternalVariableAssignment) MarshalJSON ¶ added in v0.8.0
func (d *ExternalVariableAssignment) MarshalJSON() ([]byte, error)
func (*ExternalVariableAssignment) NodeType ¶ added in v0.8.0
func (*ExternalVariableAssignment) NodeType() string
type File ¶ added in v0.13.0
type File struct { Package *PackageClause `json:"package"` Imports []*ImportDeclaration `json:"imports"` Body []Statement `json:"body"` // contains filtered or unexported fields }
func (File) Location ¶ added in v0.13.0
func (l File) Location() ast.SourceLocation
func (*File) MarshalJSON ¶ added in v0.13.0
func (*File) UnmarshalJSON ¶ added in v0.13.0
type FloatLiteral ¶
type FloatLiteral struct { Value float64 `json:"value"` // contains filtered or unexported fields }
func (*FloatLiteral) Copy ¶
func (l *FloatLiteral) Copy() Node
func (*FloatLiteral) FromBuf ¶ added in v0.57.0
func (rcv *FloatLiteral) FromBuf(fb *fbsemantic.FloatLiteral) error
func (FloatLiteral) Location ¶
func (l FloatLiteral) Location() ast.SourceLocation
func (*FloatLiteral) MarshalJSON ¶
func (l *FloatLiteral) MarshalJSON() ([]byte, error)
func (*FloatLiteral) NodeType ¶
func (*FloatLiteral) NodeType() string
func (*FloatLiteral) TypeOf ¶ added in v0.58.0
func (e *FloatLiteral) TypeOf() *types.MonoType
type FormatOption ¶ added in v0.50.0
type FormatOption func(*formatter)
type Fresher ¶
type Fresher interface { // Fresh produces a new unused type variable. Fresh() Tvar }
Fresher produces fresh type variables.
func NewFresher ¶
func NewFresher() Fresher
type FunctionBlock ¶
type FunctionBlock struct { Parameters *FunctionParameters `json:"parameters"` Body Node `json:"body"` // contains filtered or unexported fields }
FunctionBlock represents the function parameters and the function body.
func (*FunctionBlock) Copy ¶
func (b *FunctionBlock) Copy() Node
func (*FunctionBlock) FromBuf ¶ added in v0.57.0
func (l *FunctionBlock) FromBuf(fb *fbsemantic.SourceLocation) error
func (FunctionBlock) Location ¶
func (l FunctionBlock) Location() ast.SourceLocation
func (*FunctionBlock) MarshalJSON ¶
func (e *FunctionBlock) MarshalJSON() ([]byte, error)
func (*FunctionBlock) NodeType ¶
func (*FunctionBlock) NodeType() string
func (*FunctionBlock) UnmarshalJSON ¶
func (e *FunctionBlock) UnmarshalJSON(data []byte) error
type FunctionExpression ¶
type FunctionExpression struct { Defaults *ObjectExpression `json:"defaults,omitempty"` Block *FunctionBlock `json:"block"` // contains filtered or unexported fields }
FunctionExpression represents the definition of a function
func (*FunctionExpression) Copy ¶
func (e *FunctionExpression) Copy() Node
func (*FunctionExpression) FromBuf ¶ added in v0.57.0
func (e *FunctionExpression) FromBuf(fb *fbsemantic.FunctionExpression) error
func (FunctionExpression) Location ¶
func (l FunctionExpression) Location() ast.SourceLocation
func (*FunctionExpression) MarshalJSON ¶
func (e *FunctionExpression) MarshalJSON() ([]byte, error)
func (*FunctionExpression) NodeType ¶
func (*FunctionExpression) NodeType() string
func (*FunctionExpression) TypeOf ¶ added in v0.58.0
func (e *FunctionExpression) TypeOf() *types.MonoType
type FunctionParameter ¶
type FunctionParameter struct { Key *Identifier `json:"key"` // contains filtered or unexported fields }
FunctionParameter represents a function parameter.
func (*FunctionParameter) Copy ¶
func (p *FunctionParameter) Copy() Node
func (*FunctionParameter) FromBuf ¶ added in v0.57.0
func (p *FunctionParameter) FromBuf(fb *fbsemantic.FunctionParameter) error
func (FunctionParameter) Location ¶
func (l FunctionParameter) Location() ast.SourceLocation
func (*FunctionParameter) MarshalJSON ¶
func (e *FunctionParameter) MarshalJSON() ([]byte, error)
func (*FunctionParameter) NodeType ¶
func (*FunctionParameter) NodeType() string
type FunctionParameters ¶
type FunctionParameters struct { List []*FunctionParameter `json:"list"` Pipe *Identifier `json:"pipe"` // contains filtered or unexported fields }
FunctionParameters represents the list of function parameters and which if any parameter is the pipe parameter.
func (*FunctionParameters) Copy ¶
func (p *FunctionParameters) Copy() Node
func (*FunctionParameters) FromBuf ¶ added in v0.57.0
func (l *FunctionParameters) FromBuf(fb *fbsemantic.SourceLocation) error
func (FunctionParameters) Location ¶
func (l FunctionParameters) Location() ast.SourceLocation
func (*FunctionParameters) MarshalJSON ¶
func (e *FunctionParameters) MarshalJSON() ([]byte, error)
func (*FunctionParameters) NodeType ¶
func (*FunctionParameters) NodeType() string
type FunctionPolySignature ¶
type FunctionSignature ¶
type Identifier ¶
type Identifier struct { Name string `json:"name"` // contains filtered or unexported fields }
func (*Identifier) Copy ¶
func (i *Identifier) Copy() Node
func (*Identifier) FromBuf ¶ added in v0.57.0
func (rcv *Identifier) FromBuf(fb *fbsemantic.Identifier) error
func (*Identifier) Key ¶ added in v0.12.0
func (n *Identifier) Key() string
func (Identifier) Location ¶
func (l Identifier) Location() ast.SourceLocation
func (*Identifier) MarshalJSON ¶
func (i *Identifier) MarshalJSON() ([]byte, error)
func (*Identifier) NodeType ¶
func (*Identifier) NodeType() string
type IdentifierExpression ¶
type IdentifierExpression struct { Name string `json:"name"` // contains filtered or unexported fields }
func (*IdentifierExpression) Copy ¶
func (e *IdentifierExpression) Copy() Node
func (*IdentifierExpression) FromBuf ¶ added in v0.57.0
func (rcv *IdentifierExpression) FromBuf(fb *fbsemantic.IdentifierExpression) error
func (IdentifierExpression) Location ¶
func (l IdentifierExpression) Location() ast.SourceLocation
func (*IdentifierExpression) MarshalJSON ¶
func (e *IdentifierExpression) MarshalJSON() ([]byte, error)
func (*IdentifierExpression) NodeType ¶
func (*IdentifierExpression) NodeType() string
func (*IdentifierExpression) TypeOf ¶ added in v0.58.0
func (e *IdentifierExpression) TypeOf() *types.MonoType
type ImportDeclaration ¶ added in v0.8.0
type ImportDeclaration struct { As *Identifier `json:"as"` Path *StringLiteral `json:"path"` // contains filtered or unexported fields }
func (*ImportDeclaration) Copy ¶ added in v0.8.0
func (d *ImportDeclaration) Copy() Node
func (*ImportDeclaration) FromBuf ¶ added in v0.57.0
func (rcv *ImportDeclaration) FromBuf(fb *fbsemantic.ImportDeclaration) error
func (ImportDeclaration) Location ¶ added in v0.8.0
func (l ImportDeclaration) Location() ast.SourceLocation
func (*ImportDeclaration) MarshalJSON ¶ added in v0.8.0
func (p *ImportDeclaration) MarshalJSON() ([]byte, error)
func (*ImportDeclaration) NodeType ¶ added in v0.8.0
func (*ImportDeclaration) NodeType() string
type Importer ¶ added in v0.8.0
type Importer interface {
Import(path string) (PackageType, bool)
}
Importer produces a package given an import path.
type IndexExpression ¶ added in v0.7.1
type IndexExpression struct { Array Expression `json:"array"` Index Expression `json:"index"` // contains filtered or unexported fields }
func (*IndexExpression) Copy ¶ added in v0.7.1
func (e *IndexExpression) Copy() Node
func (*IndexExpression) FromBuf ¶ added in v0.57.0
func (rcv *IndexExpression) FromBuf(fb *fbsemantic.IndexExpression) error
func (IndexExpression) Location ¶ added in v0.7.1
func (l IndexExpression) Location() ast.SourceLocation
func (*IndexExpression) MarshalJSON ¶ added in v0.7.1
func (e *IndexExpression) MarshalJSON() ([]byte, error)
func (*IndexExpression) NodeType ¶ added in v0.7.1
func (*IndexExpression) NodeType() string
func (*IndexExpression) TypeOf ¶ added in v0.58.0
func (e *IndexExpression) TypeOf() *types.MonoType
func (*IndexExpression) UnmarshalJSON ¶ added in v0.7.1
func (e *IndexExpression) UnmarshalJSON(data []byte) error
type IntegerLiteral ¶
type IntegerLiteral struct { Value int64 `json:"value"` // contains filtered or unexported fields }
func (*IntegerLiteral) Copy ¶
func (l *IntegerLiteral) Copy() Node
func (*IntegerLiteral) FromBuf ¶ added in v0.57.0
func (rcv *IntegerLiteral) FromBuf(fb *fbsemantic.IntegerLiteral) error
func (IntegerLiteral) Location ¶
func (l IntegerLiteral) Location() ast.SourceLocation
func (*IntegerLiteral) MarshalJSON ¶
func (l *IntegerLiteral) MarshalJSON() ([]byte, error)
func (*IntegerLiteral) NodeType ¶
func (*IntegerLiteral) NodeType() string
func (*IntegerLiteral) TypeOf ¶ added in v0.58.0
func (e *IntegerLiteral) TypeOf() *types.MonoType
func (*IntegerLiteral) UnmarshalJSON ¶
func (l *IntegerLiteral) UnmarshalJSON(data []byte) error
type InterpolatedPart ¶ added in v0.41.0
type InterpolatedPart struct { Expression Expression `json:"expression"` // contains filtered or unexported fields }
func (*InterpolatedPart) Copy ¶ added in v0.41.0
func (p *InterpolatedPart) Copy() Node
func (*InterpolatedPart) FromBuf ¶ added in v0.57.0
func (l *InterpolatedPart) FromBuf(fb *fbsemantic.SourceLocation) error
func (InterpolatedPart) Location ¶ added in v0.41.0
func (l InterpolatedPart) Location() ast.SourceLocation
func (*InterpolatedPart) MarshalJSON ¶ added in v0.41.0
func (e *InterpolatedPart) MarshalJSON() ([]byte, error)
func (*InterpolatedPart) NodeType ¶ added in v0.41.0
func (*InterpolatedPart) NodeType() string
func (*InterpolatedPart) UnmarshalJSON ¶ added in v0.41.0
func (e *InterpolatedPart) UnmarshalJSON(data []byte) error
type Kind ¶
type Kind interface { TypeExpression // contains filtered or unexported methods }
Kind is a constraint in the kind domain.
type KindConstrainter ¶
type KindConstrainter interface {
KindConstraint() Kind
}
type LabelSet ¶
type LabelSet []string
LabelSet is a set of string labels.
type Literal ¶
type Literal interface { Expression // contains filtered or unexported methods }
type LogicalExpression ¶
type LogicalExpression struct { Operator ast.LogicalOperatorKind `json:"operator"` Left Expression `json:"left"` Right Expression `json:"right"` // contains filtered or unexported fields }
func (*LogicalExpression) Copy ¶
func (e *LogicalExpression) Copy() Node
func (*LogicalExpression) FromBuf ¶ added in v0.57.0
func (rcv *LogicalExpression) FromBuf(fb *fbsemantic.LogicalExpression) error
func (LogicalExpression) Location ¶
func (l LogicalExpression) Location() ast.SourceLocation
func (*LogicalExpression) MarshalJSON ¶
func (e *LogicalExpression) MarshalJSON() ([]byte, error)
func (*LogicalExpression) NodeType ¶
func (*LogicalExpression) NodeType() string
func (*LogicalExpression) TypeOf ¶ added in v0.58.0
func (e *LogicalExpression) TypeOf() *types.MonoType
func (*LogicalExpression) UnmarshalJSON ¶
func (e *LogicalExpression) UnmarshalJSON(data []byte) error
type MemberAssignment ¶ added in v0.14.0
type MemberAssignment struct { Member *MemberExpression `json:"member"` Init Expression `json:"init"` // contains filtered or unexported fields }
func (*MemberAssignment) Copy ¶ added in v0.14.0
func (s *MemberAssignment) Copy() Node
func (*MemberAssignment) FromBuf ¶ added in v0.57.0
func (rcv *MemberAssignment) FromBuf(fb *fbsemantic.MemberAssignment) error
func (MemberAssignment) Location ¶ added in v0.14.0
func (l MemberAssignment) Location() ast.SourceLocation
func (*MemberAssignment) MarshalJSON ¶ added in v0.14.0
func (s *MemberAssignment) MarshalJSON() ([]byte, error)
func (*MemberAssignment) NodeType ¶ added in v0.14.0
func (*MemberAssignment) NodeType() string
func (*MemberAssignment) UnmarshalJSON ¶ added in v0.14.0
func (s *MemberAssignment) UnmarshalJSON(data []byte) error
type MemberExpression ¶
type MemberExpression struct { Object Expression `json:"object"` Property string `json:"property"` // contains filtered or unexported fields }
func (*MemberExpression) Copy ¶
func (e *MemberExpression) Copy() Node
func (*MemberExpression) FromBuf ¶ added in v0.57.0
func (rcv *MemberExpression) FromBuf(fb *fbsemantic.MemberExpression) error
func (MemberExpression) Location ¶
func (l MemberExpression) Location() ast.SourceLocation
func (*MemberExpression) MarshalJSON ¶
func (e *MemberExpression) MarshalJSON() ([]byte, error)
func (*MemberExpression) NodeType ¶
func (*MemberExpression) NodeType() string
func (*MemberExpression) TypeOf ¶ added in v0.58.0
func (e *MemberExpression) TypeOf() *types.MonoType
func (*MemberExpression) UnmarshalJSON ¶
func (e *MemberExpression) UnmarshalJSON(data []byte) error
type NativeVariableAssignment ¶ added in v0.8.0
type NativeVariableAssignment struct { Identifier *Identifier `json:"identifier"` Init Expression `json:"init"` Typ *types.PolyType `json:"polytype,omitempty"` // contains filtered or unexported fields }
func (*NativeVariableAssignment) Copy ¶ added in v0.8.0
func (s *NativeVariableAssignment) Copy() Node
func (*NativeVariableAssignment) FromBuf ¶ added in v0.57.0
func (rcv *NativeVariableAssignment) FromBuf(fb *fbsemantic.NativeVariableAssignment) error
func (NativeVariableAssignment) Location ¶ added in v0.8.0
func (l NativeVariableAssignment) Location() ast.SourceLocation
func (*NativeVariableAssignment) MarshalJSON ¶ added in v0.8.0
func (d *NativeVariableAssignment) MarshalJSON() ([]byte, error)
func (*NativeVariableAssignment) NodeType ¶ added in v0.8.0
func (*NativeVariableAssignment) NodeType() string
func (*NativeVariableAssignment) UnmarshalJSON ¶ added in v0.8.0
func (d *NativeVariableAssignment) UnmarshalJSON(data []byte) error
type Nature ¶
type Nature int
Nature is the primitive description of a type.
func (Nature) ElementType ¶
func (Nature) FunctionSignature ¶
func (n Nature) FunctionSignature() FunctionSignature
func (Nature) Properties ¶
func (Nature) PropertyType ¶
type NestingVisitor ¶
type NestingVisitor interface { Visitor Nest() NestingVisitor }
type Node ¶
type Node interface { NodeType() string Copy() Node Location() ast.SourceLocation json.Marshaler // contains filtered or unexported methods }
func UnmarshalNode ¶
type NullableKind ¶ added in v0.33.0
type NullableKind struct {
T PolyType
}
NullableKind indicates that it is possible for this variable to be the null type if no other type is more appropriate.
func (NullableKind) MonoType ¶ added in v0.33.0
func (n NullableKind) MonoType() (Type, bool)
type NullableTvar ¶ added in v0.40.0
type NullableTvar struct {
Tvar
}
NullableTvar is a type variable that might be null. If a type variable is constrained to be nullable (via the NullableKind), in order to preserve that constraint when resolving the type, we return a NullableTvar.
TODO: This is a temporary type that will be removed once kind constraints can be expressed in the language of types. Unfortunately right now, external packages like the compiler don't have any notion of kind constraints.
func (NullableTvar) Equal ¶ added in v0.40.0
func (t NullableTvar) Equal(p PolyType) bool
func (NullableTvar) MonoType ¶ added in v0.40.0
func (NullableTvar) MonoType() (Type, bool)
func (NullableTvar) Nature ¶ added in v0.40.0
func (NullableTvar) Nature() Nature
func (NullableTvar) String ¶ added in v0.40.0
func (t NullableTvar) String() string
type ObjectExpression ¶
type ObjectExpression struct { With *IdentifierExpression `json:"with,omitempty"` Properties []*Property `json:"properties"` // contains filtered or unexported fields }
func (*ObjectExpression) Copy ¶
func (e *ObjectExpression) Copy() Node
func (*ObjectExpression) FromBuf ¶ added in v0.57.0
func (rcv *ObjectExpression) FromBuf(fb *fbsemantic.ObjectExpression) error
func (ObjectExpression) Location ¶
func (l ObjectExpression) Location() ast.SourceLocation
func (*ObjectExpression) MarshalJSON ¶
func (e *ObjectExpression) MarshalJSON() ([]byte, error)
func (*ObjectExpression) NodeType ¶
func (*ObjectExpression) NodeType() string
func (*ObjectExpression) TypeOf ¶ added in v0.58.0
func (e *ObjectExpression) TypeOf() *types.MonoType
type ObjectKind ¶ added in v0.7.1
type ObjectKind struct {
// contains filtered or unexported fields
}
func (ObjectKind) MonoType ¶ added in v0.7.1
func (k ObjectKind) MonoType() (Type, bool)
func (ObjectKind) String ¶ added in v0.7.1
func (k ObjectKind) String() string
type OptionStatement ¶
type OptionStatement struct { Assignment Assignment `json:"assignment"` // contains filtered or unexported fields }
func (*OptionStatement) Copy ¶
func (s *OptionStatement) Copy() Node
func (*OptionStatement) FromBuf ¶ added in v0.57.0
func (rcv *OptionStatement) FromBuf(fb *fbsemantic.OptionStatement) error
func (OptionStatement) Location ¶
func (l OptionStatement) Location() ast.SourceLocation
func (*OptionStatement) MarshalJSON ¶
func (s *OptionStatement) MarshalJSON() ([]byte, error)
func (*OptionStatement) NodeType ¶
func (s *OptionStatement) NodeType() string
func (*OptionStatement) UnmarshalJSON ¶
func (s *OptionStatement) UnmarshalJSON(data []byte) error
type Package ¶ added in v0.8.0
type Package struct { Package string `json:"package"` Files []*File `json:"files"` // contains filtered or unexported fields }
func DeserializeFromFlatBuffer ¶ added in v0.57.0
func (*Package) FromBuf ¶ added in v0.57.0
func (rcv *Package) FromBuf(fb *fbsemantic.Package) error
func (Package) Location ¶ added in v0.13.0
func (l Package) Location() ast.SourceLocation
func (*Package) MarshalJSON ¶ added in v0.13.0
type PackageClause ¶ added in v0.8.0
type PackageClause struct { Name *Identifier `json:"name"` // contains filtered or unexported fields }
func (*PackageClause) Copy ¶ added in v0.8.0
func (p *PackageClause) Copy() Node
func (*PackageClause) FromBuf ¶ added in v0.57.0
func (rcv *PackageClause) FromBuf(fb *fbsemantic.PackageClause) error
func (PackageClause) Location ¶ added in v0.8.0
func (l PackageClause) Location() ast.SourceLocation
func (*PackageClause) MarshalJSON ¶ added in v0.8.0
func (p *PackageClause) MarshalJSON() ([]byte, error)
func (*PackageClause) NodeType ¶ added in v0.8.0
func (*PackageClause) NodeType() string
type PackageType ¶ added in v0.13.0
PackageType represents the type and name of a package.
func CreatePackage ¶ added in v0.8.0
func CreatePackage(n Node, importer Importer) (PackageType, error)
CreatePackage constructs a Package from the node. The node must contain a Program node with a valid PackageClause
type PolyType ¶
type PolyType interface { TypeExpression // Equal reports if two types are the same. Equal(PolyType) bool // Nature reports the primitive description of the type. Nature() Nature // contains filtered or unexported methods }
PolyType represents a polymorphic type, meaning that the type may have multiple free type variables.
func NewArrayPolyType ¶
func NewEmptyObjectPolyType ¶
func NewEmptyObjectPolyType() PolyType
func NewFunctionPolyType ¶
func NewFunctionPolyType(sig FunctionPolySignature) PolyType
func NewObjectPolyType ¶
NewObjectPolyType creates a PolyType representing an object. A map of properties and their types may be provided. Lower is a set of labels that must exist on the object, and upper is a set of labels that may exist on the object. Upper must be a superset of lower. The map must contain an entry for all lables in the lower set. Use AllLabels() to represent the infinite set of all possible labels.
type Property ¶
type Property struct { Key PropertyKey `json:"key"` Value Expression `json:"value"` // contains filtered or unexported fields }
func (*Property) FromBuf ¶ added in v0.57.0
func (rcv *Property) FromBuf(fb *fbsemantic.Property) error
func (Property) Location ¶
func (l Property) Location() ast.SourceLocation
func (*Property) MarshalJSON ¶
func (*Property) UnmarshalJSON ¶
type PropertyKey ¶ added in v0.12.0
type RegexpLiteral ¶
type RegexpLiteral struct { Value *regexp.Regexp `json:"value"` // contains filtered or unexported fields }
func (*RegexpLiteral) Copy ¶
func (l *RegexpLiteral) Copy() Node
func (*RegexpLiteral) FromBuf ¶ added in v0.57.0
func (rcv *RegexpLiteral) FromBuf(fb *fbsemantic.RegexpLiteral) error
func (RegexpLiteral) Location ¶
func (l RegexpLiteral) Location() ast.SourceLocation
func (*RegexpLiteral) MarshalJSON ¶
func (l *RegexpLiteral) MarshalJSON() ([]byte, error)
func (*RegexpLiteral) NodeType ¶
func (*RegexpLiteral) NodeType() string
func (*RegexpLiteral) TypeOf ¶ added in v0.58.0
func (e *RegexpLiteral) TypeOf() *types.MonoType
func (*RegexpLiteral) UnmarshalJSON ¶
func (l *RegexpLiteral) UnmarshalJSON(data []byte) error
type ReturnStatement ¶
type ReturnStatement struct { Argument Expression `json:"argument"` // contains filtered or unexported fields }
func (*ReturnStatement) Copy ¶
func (s *ReturnStatement) Copy() Node
func (*ReturnStatement) FromBuf ¶ added in v0.57.0
func (rcv *ReturnStatement) FromBuf(fb *fbsemantic.ReturnStatement) error
func (ReturnStatement) Location ¶
func (l ReturnStatement) Location() ast.SourceLocation
func (*ReturnStatement) MarshalJSON ¶
func (s *ReturnStatement) MarshalJSON() ([]byte, error)
func (*ReturnStatement) NodeType ¶
func (*ReturnStatement) NodeType() string
func (*ReturnStatement) UnmarshalJSON ¶
func (s *ReturnStatement) UnmarshalJSON(data []byte) error
type ScopedVisitor ¶
type ScopedVisitor struct {
// contains filtered or unexported fields
}
ScopedVisitor will nest the given visitor when the scope changes.
func NewScopedVisitor ¶
func NewScopedVisitor(v NestingVisitor) ScopedVisitor
func (ScopedVisitor) Done ¶
func (v ScopedVisitor) Done(node Node)
func (ScopedVisitor) Visit ¶
func (v ScopedVisitor) Visit(node Node) Visitor
type Solution ¶
type Solution struct {
// contains filtered or unexported fields
}
Solution implement TypeSolution and solves the unification problem.
func (*Solution) AddConstraint ¶
func (*Solution) FreshSolution ¶
func (s *Solution) FreshSolution() TypeSolution
type SolutionMap ¶ added in v0.16.0
SolutionMap represents a mapping of nodes to their poly types.
func CreateSolutionMap ¶ added in v0.16.0
func CreateSolutionMap(node Node, sol TypeSolution) SolutionMap
CreateSolutionMap constructs a new solution map from the nodes and type solution. Any type errors in the type solution are ignored.
func (SolutionMap) String ¶ added in v0.16.0
func (s SolutionMap) String() string
type StringExpression ¶ added in v0.41.0
type StringExpression struct { Parts []StringExpressionPart `json:"parts"` // contains filtered or unexported fields }
func (*StringExpression) Copy ¶ added in v0.41.0
func (e *StringExpression) Copy() Node
func (*StringExpression) FromBuf ¶ added in v0.57.0
func (rcv *StringExpression) FromBuf(fb *fbsemantic.StringExpression) error
func (StringExpression) Location ¶ added in v0.41.0
func (l StringExpression) Location() ast.SourceLocation
func (*StringExpression) MarshalJSON ¶ added in v0.41.0
func (e *StringExpression) MarshalJSON() ([]byte, error)
func (*StringExpression) NodeType ¶ added in v0.41.0
func (*StringExpression) NodeType() string
func (*StringExpression) TypeOf ¶ added in v0.58.0
func (e *StringExpression) TypeOf() *types.MonoType
func (*StringExpression) UnmarshalJSON ¶ added in v0.41.0
func (e *StringExpression) UnmarshalJSON(data []byte) error
type StringExpressionPart ¶ added in v0.41.0
type StringExpressionPart interface { Node // contains filtered or unexported methods }
type StringLiteral ¶
type StringLiteral struct { Value string `json:"value"` // contains filtered or unexported fields }
func (*StringLiteral) Copy ¶
func (l *StringLiteral) Copy() Node
func (*StringLiteral) FromBuf ¶ added in v0.57.0
func (rcv *StringLiteral) FromBuf(fb *fbsemantic.StringLiteral) error
func (*StringLiteral) Key ¶ added in v0.12.0
func (n *StringLiteral) Key() string
func (StringLiteral) Location ¶
func (l StringLiteral) Location() ast.SourceLocation
func (*StringLiteral) MarshalJSON ¶
func (l *StringLiteral) MarshalJSON() ([]byte, error)
func (*StringLiteral) NodeType ¶
func (*StringLiteral) NodeType() string
func (*StringLiteral) TypeOf ¶ added in v0.58.0
func (e *StringLiteral) TypeOf() *types.MonoType
type Substitution ¶
Substitution is a mapping of type variables to a poly type.
func (Substitution) ApplyEnv ¶
func (s Substitution) ApplyEnv(env *Env) *Env
func (Substitution) ApplyKind ¶
func (s Substitution) ApplyKind(k Kind) Kind
func (Substitution) ApplyScheme ¶
func (s Substitution) ApplyScheme(ts Scheme) Scheme
func (Substitution) ApplyTvar ¶
func (s Substitution) ApplyTvar(tv Tvar) Tvar
func (Substitution) ApplyType ¶
func (s Substitution) ApplyType(t PolyType) PolyType
func (Substitution) String ¶
func (s Substitution) String() string
type TestStatement ¶ added in v0.19.0
type TestStatement struct { Assignment *NativeVariableAssignment `json:"assignment"` // contains filtered or unexported fields }
func (*TestStatement) Copy ¶ added in v0.19.0
func (s *TestStatement) Copy() Node
func (*TestStatement) FromBuf ¶ added in v0.57.0
func (rcv *TestStatement) FromBuf(fb *fbsemantic.TestStatement) error
func (TestStatement) Location ¶ added in v0.19.0
func (l TestStatement) Location() ast.SourceLocation
func (*TestStatement) MarshalJSON ¶ added in v0.19.0
func (s *TestStatement) MarshalJSON() ([]byte, error)
func (*TestStatement) NodeType ¶ added in v0.19.0
func (s *TestStatement) NodeType() string
type TextPart ¶ added in v0.41.0
type TextPart struct { Value string `json:"value"` // contains filtered or unexported fields }
func (*TextPart) FromBuf ¶ added in v0.57.0
func (l *TextPart) FromBuf(fb *fbsemantic.SourceLocation) error
func (TextPart) Location ¶ added in v0.41.0
func (l TextPart) Location() ast.SourceLocation
func (*TextPart) MarshalJSON ¶ added in v0.41.0
func (*TextPart) UnmarshalJSON ¶ added in v0.41.0
type Tvar ¶
type Tvar int
Tvar represents a type variable meaning its type could be any possible type.
type Type ¶
type Type interface { // Nature returns the specific primitive description of this type. Nature() Nature // PropertyType returns the type of a given property. // It panics if the type's Kind is not Object PropertyType(name string) Type // Properties returns a map of all property types. // It panics if the type's Kind is not Object Properties() map[string]Type // ElementType return the type of elements in the array. // It panics if the type's Kind is not Array. ElementType() Type // FunctionSignature returns the function signature of this type. // It panics if the type's Kind is not Function. FunctionSignature() FunctionSignature PolyType() PolyType // contains filtered or unexported methods }
Type is the representation of a Flux type. Type is a monomorphic, meaning that it represents a single type and is not polymorphic. See PolyType for polymorphic types.
Type values are comparable and as such can be used as map keys and directly comparison using the == operator. Two types are equal if they represent identical types.
Do NOT embed this type into other interfaces or structs as that will invalidate the comparison properties of the interface.
func NewArrayType ¶
func NewFunctionType ¶
func NewFunctionType(sig FunctionSignature) (t Type)
func NewObjectType ¶
type TypeConstraint ¶
type TypeConstraint struct {
// contains filtered or unexported fields
}
TypeConstraint states that the left and right types must be equal.
func (TypeConstraint) String ¶
func (tc TypeConstraint) String() string
type TypeExpression ¶
type TypeExpression interface { // MonoType produces a monotype of the expression. MonoType() (Type, bool) // contains filtered or unexported methods }
TypeExpression represents an expression describing a type.
type TypeSolution ¶
type TypeSolution interface { // TypeOf reports the monotype of the node or an error. TypeOf(n Node) (Type, error) // TypeOf reports the polytype of the node or an error. PolyTypeOf(n Node) (PolyType, error) // FreshSolution creates a copy of the solution with fresh type variables FreshSolution() TypeSolution // Fresh creates a new type variable within the solution. Fresh() Tvar // AddConstraint adds a new constraint and solves again reporting any errors. AddConstraint(l, r PolyType) error }
TypeSolution is a mapping of Nodes to their types.
func InferTypes ¶
func InferTypes(n Node, importer Importer) (TypeSolution, error)
InferTypes produces a solution to type inference for a given semantic graph.
func SolveConstraints ¶
func SolveConstraints(cs *Constraints) (TypeSolution, error)
SolveConstraints solves the type inference problem defined by the constraints.
type UnaryExpression ¶
type UnaryExpression struct { Operator ast.OperatorKind `json:"operator"` Argument Expression `json:"argument"` // contains filtered or unexported fields }
func (*UnaryExpression) Copy ¶
func (e *UnaryExpression) Copy() Node
func (*UnaryExpression) FromBuf ¶ added in v0.57.0
func (rcv *UnaryExpression) FromBuf(fb *fbsemantic.UnaryExpression) error
func (UnaryExpression) Location ¶
func (l UnaryExpression) Location() ast.SourceLocation
func (*UnaryExpression) MarshalJSON ¶
func (e *UnaryExpression) MarshalJSON() ([]byte, error)
func (*UnaryExpression) NodeType ¶
func (*UnaryExpression) NodeType() string
func (*UnaryExpression) TypeOf ¶ added in v0.58.0
func (e *UnaryExpression) TypeOf() *types.MonoType
func (*UnaryExpression) UnmarshalJSON ¶
func (e *UnaryExpression) UnmarshalJSON(data []byte) error
type UnsignedIntegerLiteral ¶
type UnsignedIntegerLiteral struct { Value uint64 `json:"value"` // contains filtered or unexported fields }
func (*UnsignedIntegerLiteral) Copy ¶
func (l *UnsignedIntegerLiteral) Copy() Node
func (*UnsignedIntegerLiteral) FromBuf ¶ added in v0.57.0
func (rcv *UnsignedIntegerLiteral) FromBuf(fb *fbsemantic.UnsignedIntegerLiteral) error
func (UnsignedIntegerLiteral) Location ¶
func (l UnsignedIntegerLiteral) Location() ast.SourceLocation
func (*UnsignedIntegerLiteral) MarshalJSON ¶
func (l *UnsignedIntegerLiteral) MarshalJSON() ([]byte, error)
func (*UnsignedIntegerLiteral) NodeType ¶
func (*UnsignedIntegerLiteral) NodeType() string
func (*UnsignedIntegerLiteral) TypeOf ¶ added in v0.58.0
func (e *UnsignedIntegerLiteral) TypeOf() *types.MonoType
func (*UnsignedIntegerLiteral) UnmarshalJSON ¶
func (l *UnsignedIntegerLiteral) UnmarshalJSON(data []byte) error
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
Package semantictest contains utilities for testing the semantic package.
|
Package semantictest contains utilities for testing the semantic package. |