Documentation ¶
Overview ¶
Negotiate and validate types in an AST.
Index ¶
- Constants
- Variables
- func AreComparable(tc *TypesContext, e1, e2 TypedExpr) bool
- func AreOrdered(t1, t2 Type) bool
- func CheckCondition(tc *TypesContext, expr TypedExpr) error
- func CheckTypeAssert(tc *TypesContext, src TypedExpr, target Type) error
- func Implements(iface, value Type) bool
- func IsAssignable(to, what Type) bool
- func IsBlank(e TypedExpr) bool
- func IsBoolAssignable(t Type) bool
- func IsConvertable(tc *TypesContext, what TypedExpr, to Type) bool
- func IsIdentincal(to, what Type) bool
- func IsInterface(t Type) bool
- func IsNamed(t Type) bool
- func IsPackage(e TypedExpr) bool
- func IsTypeBool(t Type) bool
- func IsTypeComplexType(t Type) bool
- func IsTypeFloatKind(t Type) bool
- func IsTypeInt(t Type) bool
- func IsTypeIntKind(t Type) bool
- func IsTypeNumeric(t Type) bool
- func IsTypeSimple(t Type, simpleType SimpleTypeID) bool
- func IsTypeString(t Type) bool
- func IsUnnamed(t Type) bool
- func NegotiateExprType(tc *TypesContext, varType *Type, value TypedExpr) error
- func NegotiateTupleUnpackAssign(tc *TypesContext, onlyFuncCalls bool, lhsTypes []*Type, rhs TypedExpr) error
- type ArrayExpr
- func (ex *ArrayExpr) ApplyType(tc *TypesContext, typ Type) error
- func (ae *ArrayExpr) Generate(tc *TypesContext, current *CodeChunk)
- func (ex *ArrayExpr) GuessType(tc *TypesContext) (ok bool, typ Type)
- func (e *ArrayExpr) Pos() gotoken.Pos
- func (ex *ArrayExpr) ReferedObject() Object
- func (ex *ArrayExpr) Type(tc *TypesContext) (Type, error)
- type ArrayType
- type AssignStmt
- type BasicLit
- type BinaryOp
- type BlankExpr
- type BranchStmt
- type BranchStmtsMap
- func (b BranchStmtsMap) Add(bs *BranchStmt)
- func (b BranchStmtsMap) FindAll(label string) []*BranchStmt
- func (b BranchStmtsMap) MatchBranchableStmt(branchable Stmt, lblName string, allowedBranchStmts ...TokenType)
- func (b BranchStmtsMap) MatchGotoLabels(labels map[string]*LabelStmt)
- func (b BranchStmtsMap) Remove(bs *BranchStmt)
- type BranchStmtsTree
- func (b *BranchStmtsTree) CountBranchStmts() int
- func (b *BranchStmtsTree) FindAll(label string) []*BranchStmt
- func (b *BranchStmtsTree) MatchBranchableStmt(branchable Stmt, lblName string, allowedBranchStmts ...TokenType)
- func (b *BranchStmtsTree) MatchGotoLabels(labels map[string]*LabelStmt)
- func (b *BranchStmtsTree) NewChild() *BranchStmtsTree
- type BranchTreesStack
- type ChanDir
- type ChanType
- type CodeBlock
- type CodeChunk
- func (cc *CodeChunk) AddChprintf(tc *TypesContext, format string, a ...interface{})
- func (cc *CodeChunk) AddChunks(chunks ...*CodeChunk)
- func (cc *CodeChunk) AddString(s string)
- func (cc *CodeChunk) NewBlockChunk() *CodeChunk
- func (cc *CodeChunk) NewChunk() *CodeChunk
- func (cc *CodeChunk) NewStrChunk(s string) *CodeChunk
- func (cc *CodeChunk) ReadAll() string
- type CompileError
- type CompoundLit
- func (ex *CompoundLit) ApplyType(tc *TypesContext, typ Type) error
- func (lit *CompoundLit) Generate(tc *TypesContext, current *CodeChunk)
- func (ex *CompoundLit) GuessType(tc *TypesContext) (ok bool, typ Type)
- func (e *CompoundLit) Pos() gotoken.Pos
- func (ex *CompoundLit) Type(tc *TypesContext) (Type, error)
- type CompoundLitKind
- type CustomType
- func (t *CustomType) Kind() Kind
- func (t *CustomType) Known() bool
- func (t *CustomType) MapSubtypes(callback func(t Type) bool)
- func (t *CustomType) NamePtr() *string
- func (t *CustomType) PackagePtr() *ImportStmt
- func (t *CustomType) RootType() Type
- func (t *CustomType) String() string
- func (t *CustomType) ZeroValue() string
- type DeclChain
- type DeclaredType
- type DotSelector
- func (ex *DotSelector) ApplyType(tc *TypesContext, typ Type) error
- func (ds *DotSelector) Generate(tc *TypesContext, current *CodeChunk)
- func (ex *DotSelector) GuessType(tc *TypesContext) (ok bool, typ Type)
- func (e *DotSelector) Pos() gotoken.Pos
- func (ex *DotSelector) ReferedObject() Object
- func (ex *DotSelector) Type(tc *TypesContext) (Type, error)
- type EmptyGenerable
- type Expr
- type ExprStmt
- type ExprToProcess
- type File
- type ForRangeStmt
- type ForStmt
- type FuncCallExpr
- func (ex *FuncCallExpr) ApplyType(tc *TypesContext, typ Type) error
- func (fc *FuncCallExpr) Generate(tc *TypesContext, current *CodeChunk)
- func (ex *FuncCallExpr) GuessType(tc *TypesContext) (ok bool, typ Type)
- func (ex *FuncCallExpr) IsNullResult(tc *TypesContext) bool
- func (e *FuncCallExpr) Pos() gotoken.Pos
- func (ex *FuncCallExpr) Type(tc *TypesContext) (Type, error)
- type FuncDecl
- func (ex *FuncDecl) ApplyType(tc *TypesContext, typ Type) error
- func (fd *FuncDecl) Generate(tc *TypesContext, current *CodeChunk)
- func (ex *FuncDecl) GuessType(tc *TypesContext) (ok bool, typ Type)
- func (fd *FuncDecl) InlineGenerate(tc *TypesContext, current *CodeChunk, noParenth bool)
- func (e *FuncDecl) Pos() gotoken.Pos
- func (ex *FuncDecl) Type(tc *TypesContext) (Type, error)
- type FuncType
- type Generable
- type Generic
- type GenericFunc
- func (gf *GenericFunc) Code() []rune
- func (gf *GenericFunc) Generate(tc *TypesContext, current *CodeChunk)
- func (gf *GenericFunc) Imports() Imports
- func (gf *GenericFunc) Instantiate(tc *TypesContext, params ...Type) (Object, string, []error)
- func (s *GenericFunc) Label() *Object
- func (gf *GenericFunc) Location() (*gotoken.File, int)
- func (gf *GenericFunc) Name() string
- func (ls *GenericFunc) NegotiateTypes(tc *TypesContext) error
- func (gf *GenericFunc) ObjectType() ObjectType
- func (gf *GenericFunc) Signature() (string, []string)
- type GenericParamType
- type GenericParamTypeDecl
- type GenericStruct
- func (gs *GenericStruct) Code() []rune
- func (gs *GenericStruct) Generate(tc *TypesContext, current *CodeChunk)
- func (gs *GenericStruct) Imports() Imports
- func (gs *GenericStruct) Instantiate(tc *TypesContext, params ...Type) (Object, string, []error)
- func (s *GenericStruct) Label() *Object
- func (gs *GenericStruct) Location() (*gotoken.File, int)
- func (gs *GenericStruct) Name() string
- func (ls *GenericStruct) NegotiateTypes(tc *TypesContext) error
- func (gs *GenericStruct) ObjectType() ObjectType
- func (gs *GenericStruct) Signature() (string, []string)
- type GenericType
- func (t *GenericType) Kind() Kind
- func (t *GenericType) Known() bool
- func (t *GenericType) MapSubtypes(callback func(t Type) bool)
- func (t *GenericType) NamePtr() *string
- func (t *GenericType) PackagePtr() *ImportStmt
- func (t *GenericType) RootType() Type
- func (t *GenericType) String() string
- func (t *GenericType) ZeroValue() string
- type Ident
- func (ex *Ident) ApplyType(tc *TypesContext, typ Type) error
- func (id *Ident) Generate(tc *TypesContext, current *CodeChunk)
- func (ex *Ident) GuessType(tc *TypesContext) (ok bool, typ Type)
- func (e *Ident) Pos() gotoken.Pos
- func (ex *Ident) ReferedObject() Object
- func (ex *Ident) Type(tc *TypesContext) (Type, error)
- type IdentStack
- type IfBranch
- type IfStmt
- type IfaceStmt
- type IfaceType
- type ImportStmt
- type Imports
- type InlineGenerable
- type InstKey
- type Instantiation
- type Kind
- type LabelStmt
- type Lexer
- type MapType
- type NilExpr
- type Object
- type ObjectExpr
- type ObjectType
- type Package
- type Parser
- type PassStmt
- type PkgLocator
- type PkgManager
- type PointerType
- type PrimaryExpr
- type ReturnStmt
- type SendStmt
- type SimpleStmt
- type SimpleType
- type SimpleTypeID
- type SliceExpr
- type SliceType
- type Stmt
- type StructStmt
- type StructType
- type SwitchBranch
- type SwitchStmt
- type Token
- type TokenType
- type TopLevelStmt
- type TupleType
- type Type
- type TypeAssertion
- func (ex *TypeAssertion) ApplyType(tc *TypesContext, typ Type) error
- func (ta *TypeAssertion) Generate(tc *TypesContext, current *CodeChunk)
- func (ex *TypeAssertion) GuessType(tc *TypesContext) (ok bool, typ Type)
- func (e *TypeAssertion) Pos() gotoken.Pos
- func (ex *TypeAssertion) Type(tc *TypesContext) (Type, error)
- type TypeDecl
- type TypeExpr
- type TypedExpr
- type TypesContext
- type UnaryOp
- type UnknownType
- type VarDecl
- type VarStmt
- type Variable
- type WhenBranch
- type WhenPredicate
- type WhenPredicateKind
- type WhenStmt
Constants ¶
const ( OBJECT_VAR = ObjectType(iota + 1) OBJECT_TYPE OBJECT_PACKAGE OBJECT_LABEL OBJECT_GENERIC OBJECT_GENERIC_TYPE )
const ( WHEN_KIND_IS = WhenPredicateKind(iota + 1) WHEN_KIND_IMPLEMENTS WHEN_KIND_DEFAULT )
const ( KIND_SIMPLE = Kind(iota + 1) KIND_ARRAY KIND_SLICE KIND_MAP KIND_POINTER KIND_CUSTOM KIND_STRUCT KIND_INTERFACE KIND_TUPLE KIND_FUNC KIND_CHAN // Type checker code doesn't have to bother with KIND_GENERIC_PARAM, all types of the generic kind // are substituted with actual types before they end up in type checker. KIND_GENERIC_PARAM KIND_GENERIC_INST KIND_UNKNOWN )
const ( SIMPLE_TYPE_BOOL = SimpleTypeID(iota + 1) SIMPLE_TYPE_BYTE SIMPLE_TYPE_COMPLEX128 SIMPLE_TYPE_COMPLEX64 SIMPLE_TYPE_ERROR SIMPLE_TYPE_FLOAT32 SIMPLE_TYPE_FLOAT64 SIMPLE_TYPE_INT SIMPLE_TYPE_INT16 SIMPLE_TYPE_INT32 SIMPLE_TYPE_INT64 SIMPLE_TYPE_INT8 SIMPLE_TYPE_RUNE SIMPLE_TYPE_STRING SIMPLE_TYPE_UINT SIMPLE_TYPE_UINT16 SIMPLE_TYPE_UINT32 SIMPLE_TYPE_UINT64 SIMPLE_TYPE_UINT8 SIMPLE_TYPE_UINTPTR )
const ( CHAN_DIR_BI = ChanDir(iota) CHAN_DIR_RECEIVE CHAN_DIR_SEND )
const Blank = "_"
const BuiltinsFileName = "_builtin.hav"
const LocalPkg = "."
Variables ¶
var ForcedIndent = &forcedIndent{}
Functions ¶
func AreComparable ¶
func AreComparable(tc *TypesContext, e1, e2 TypedExpr) bool
Implements the definition of comparable operands from the Go spec. Panic if e1's or e2's methods return errors - their types need to be negotiated earlier.
func AreOrdered ¶
Implements the definition of ordered operands from the Go spec.
func CheckCondition ¶
func CheckCondition(tc *TypesContext, expr TypedExpr) error
func CheckTypeAssert ¶
func CheckTypeAssert(tc *TypesContext, src TypedExpr, target Type) error
Check if type assertion is sane.
func Implements ¶
Tells whether value's methods are a subset of iface's methods.
func IsAssignable ¶
Implements the definition of assignability from the Go spec.
func IsBoolAssignable ¶
func IsConvertable ¶
func IsConvertable(tc *TypesContext, what TypedExpr, to Type) bool
Implements convertability definition from Go spec https://golang.ir/ref/spec#Conversions
func IsIdentincal ¶
func IsInterface ¶
Can be used to check if a type is an interface. Works with interfaces aliased by named types.
func IsTypeBool ¶
func IsTypeComplexType ¶
func IsTypeFloatKind ¶
func IsTypeIntKind ¶
func IsTypeNumeric ¶
func IsTypeSimple ¶
func IsTypeSimple(t Type, simpleType SimpleTypeID) bool
func IsTypeString ¶
func NegotiateExprType ¶
func NegotiateExprType(tc *TypesContext, varType *Type, value TypedExpr) error
This will overwrite the type pointer by varType.
func NegotiateTupleUnpackAssign ¶
func NegotiateTupleUnpackAssign(tc *TypesContext, onlyFuncCalls bool, lhsTypes []*Type, rhs TypedExpr) error
Helper function useful for situations where an expression returning more than one result is assigned to multiple variables. In some situations only func calls unpacking works. Type assertions or map inclusion testing doesn't work in non-assignment situtations, examples:
func x() int, bool:
return someMap[7] // Doesn't work (in Golang as well)
func x(int, bool):
pass
x(someMap[7]) // Doesn't work (in Golang as well)
UseonlyFuncCalls argument to control this.
Types ¶
type ArrayExpr ¶
implements PrimaryExpr
func (*ArrayExpr) Generate ¶
func (ae *ArrayExpr) Generate(tc *TypesContext, current *CodeChunk)
func (*ArrayExpr) ReferedObject ¶
type ArrayType ¶
func (*ArrayType) MapSubtypes ¶
type AssignStmt ¶
implements SimpleStmt
func (*AssignStmt) Generate ¶
func (as *AssignStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*AssignStmt) InlineGenerate ¶
func (as *AssignStmt) InlineGenerate(tc *TypesContext, current *CodeChunk, noParenth bool)
func (*AssignStmt) NegotiateTypes ¶
func (as *AssignStmt) NegotiateTypes(tc *TypesContext) error
type BasicLit ¶
type BasicLit struct {
// contains filtered or unexported fields
}
implements Expr
func (*BasicLit) Generate ¶
func (lit *BasicLit) Generate(tc *TypesContext, current *CodeChunk)
type BinaryOp ¶
type BinaryOp struct {
Left, Right Expr
// contains filtered or unexported fields
}
implements Expr
func (*BinaryOp) Generate ¶
func (op *BinaryOp) Generate(tc *TypesContext, current *CodeChunk)
type BlankExpr ¶
type BlankExpr struct {
// contains filtered or unexported fields
}
Blank expression, represents no expression. Sometimes useful. implements Expr
func NewBlankExpr ¶
func NewBlankExpr() *BlankExpr
type BranchStmt ¶
type BranchStmt struct { Token *Token Right *Ident // Is nil for breaks/continues in unnamed loops/switches. GotoLabel *LabelStmt // Is nil for goto statements. Otherwise it is the statement // that the continue/break refers to. Branchable Stmt // contains filtered or unexported fields }
Break, continue, goto
func (*BranchStmt) Generate ¶
func (bs *BranchStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*BranchStmt) NegotiateTypes ¶
func (bs *BranchStmt) NegotiateTypes(tc *TypesContext) error
type BranchStmtsMap ¶
type BranchStmtsMap map[string][]*BranchStmt
BranchStmtsMap is used to store branch statements (break, continue, goto) that haven't been paired with their labels/statements yet. When parser finishes parsing blocks of code/branchable statments, it looks into this structure to see if there were any matches.
func (BranchStmtsMap) Add ¶
func (b BranchStmtsMap) Add(bs *BranchStmt)
func (BranchStmtsMap) FindAll ¶
func (b BranchStmtsMap) FindAll(label string) []*BranchStmt
func (BranchStmtsMap) MatchBranchableStmt ¶
func (b BranchStmtsMap) MatchBranchableStmt(branchable Stmt, lblName string, allowedBranchStmts ...TokenType)
func (BranchStmtsMap) MatchGotoLabels ¶
func (b BranchStmtsMap) MatchGotoLabels(labels map[string]*LabelStmt)
func (BranchStmtsMap) Remove ¶
func (b BranchStmtsMap) Remove(bs *BranchStmt)
type BranchStmtsTree ¶
type BranchStmtsTree struct { Members BranchStmtsMap Children []*BranchStmtsTree }
BranchStmtsTree stores a hierarchy of BranchStmtsMaps. Each nested block of code has its own BranchStmtsMap. This tree is needed to detect situations where gotos jump into blocks of code (only jumping outside/within blocks is possible).
func NewBranchStmtsTree ¶
func NewBranchStmtsTree() *BranchStmtsTree
func (*BranchStmtsTree) CountBranchStmts ¶
func (b *BranchStmtsTree) CountBranchStmts() int
func (*BranchStmtsTree) FindAll ¶
func (b *BranchStmtsTree) FindAll(label string) []*BranchStmt
func (*BranchStmtsTree) MatchBranchableStmt ¶
func (b *BranchStmtsTree) MatchBranchableStmt(branchable Stmt, lblName string, allowedBranchStmts ...TokenType)
Call MatchBranchableStmt on every BranchStmtsMap in the tree.
func (*BranchStmtsTree) MatchGotoLabels ¶
func (b *BranchStmtsTree) MatchGotoLabels(labels map[string]*LabelStmt)
Call MatchGotoLabels on every BranchStmtsMap in the tree.
func (*BranchStmtsTree) NewChild ¶
func (b *BranchStmtsTree) NewChild() *BranchStmtsTree
type BranchTreesStack ¶
type BranchTreesStack []*BranchStmtsTree
type ChanType ¶
func (*ChanType) MapSubtypes ¶
type CodeBlock ¶
func (*CodeBlock) CheckTypes ¶
func (cb *CodeBlock) CheckTypes(tc *TypesContext) error
func (*CodeBlock) Generate ¶
func (bl *CodeBlock) Generate(tc *TypesContext, current *CodeChunk)
type CodeChunk ¶
type CodeChunk struct {
// contains filtered or unexported fields
}
CodeChunk can either be a slice of smaller CodeChunks or its value can be a string. Think of it as of a union type. Every statement should have a separate CodeChunk. Statements that (directly) contain a block of code should be flagged (it will be used to insert code that "spills" beyond the current block of code).
func (*CodeChunk) AddChprintf ¶
func (cc *CodeChunk) AddChprintf(tc *TypesContext, format string, a ...interface{})
Format using fmt.Sprintf, but with one addition: "%C" can be used to add Generables. Use "%iC" variant for InlineGenerables. Indents are inserted automatically, but for multi-line statements that need extra indents in the middle, use the ForcedIndent generable.
func (*CodeChunk) NewBlockChunk ¶
func (*CodeChunk) NewStrChunk ¶
type CompileError ¶
func CompileErrorf ¶
func CompileErrorf(token *Token, message string, args ...interface{}) *CompileError
func ExprErrorf ¶
func ExprErrorf(expr Expr, message string, args ...interface{}) *CompileError
func (*CompileError) Error ¶
func (ce *CompileError) Error() string
func (*CompileError) PrettyString ¶
func (ce *CompileError) PrettyString(fset *gotoken.FileSet) string
type CompoundLit ¶
type CompoundLit struct { Left Expr // contains filtered or unexported fields }
implements Expr
func (*CompoundLit) ApplyType ¶
func (ex *CompoundLit) ApplyType(tc *TypesContext, typ Type) error
func (*CompoundLit) Generate ¶
func (lit *CompoundLit) Generate(tc *TypesContext, current *CodeChunk)
func (*CompoundLit) GuessType ¶
func (ex *CompoundLit) GuessType(tc *TypesContext) (ok bool, typ Type)
func (*CompoundLit) Type ¶
func (ex *CompoundLit) Type(tc *TypesContext) (Type, error)
type CompoundLitKind ¶
type CompoundLitKind int
const ( COMPOUND_UNKNOWN CompoundLitKind = iota COMPOUND_EMPTY COMPOUND_LISTLIKE COMPOUND_MAPLIKE )
type CustomType ¶
type CustomType struct { // Base name of the type. Doesn't include package name for external types. Name string // nil means local Package *ImportStmt Decl *TypeDecl }
func (*CustomType) Kind ¶
func (t *CustomType) Kind() Kind
func (*CustomType) Known ¶
func (t *CustomType) Known() bool
func (*CustomType) MapSubtypes ¶
func (t *CustomType) MapSubtypes(callback func(t Type) bool)
func (*CustomType) NamePtr ¶
func (t *CustomType) NamePtr() *string
func (*CustomType) PackagePtr ¶
func (t *CustomType) PackagePtr() *ImportStmt
func (*CustomType) RootType ¶
func (t *CustomType) RootType() Type
func (*CustomType) String ¶
func (t *CustomType) String() string
func (*CustomType) ZeroValue ¶
func (t *CustomType) ZeroValue() string
type DeclChain ¶
type DeclChain []*VarDecl
Chain of variable declarations. Sample uses:
- multi-element variable declaration
- function arguments definition
- function results definition
func (DeclChain) Generate ¶
func (dc DeclChain) Generate(tc *TypesContext, current *CodeChunk)
type DeclaredType ¶
type DeclaredType interface { Type NamePtr() *string RootType() Type PackagePtr() *ImportStmt }
type DotSelector ¶
implements Expr
func (*DotSelector) ApplyType ¶
func (ex *DotSelector) ApplyType(tc *TypesContext, typ Type) error
func (*DotSelector) Generate ¶
func (ds *DotSelector) Generate(tc *TypesContext, current *CodeChunk)
func (*DotSelector) GuessType ¶
func (ex *DotSelector) GuessType(tc *TypesContext) (ok bool, typ Type)
func (*DotSelector) ReferedObject ¶
func (ex *DotSelector) ReferedObject() Object
func (*DotSelector) Type ¶
func (ex *DotSelector) Type(tc *TypesContext) (Type, error)
type EmptyGenerable ¶
type EmptyGenerable struct{}
func (EmptyGenerable) Generate ¶
func (eg EmptyGenerable) Generate(tc *TypesContext, current *CodeChunk)
func (EmptyGenerable) InlineGenerate ¶
func (vs EmptyGenerable) InlineGenerate(tc *TypesContext, current *CodeChunk, noParenth bool)
type ExprStmt ¶
type ExprStmt struct { Expression Expr // contains filtered or unexported fields }
implements Stmt Statement wrapper for expressions.
func (*ExprStmt) Generate ¶
func (es *ExprStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*ExprStmt) InlineGenerate ¶
func (es *ExprStmt) InlineGenerate(tc *TypesContext, current *CodeChunk, noParenth bool)
func (*ExprStmt) NegotiateTypes ¶
func (es *ExprStmt) NegotiateTypes(tc *TypesContext) error
type ExprToProcess ¶
type ExprToProcess interface { Expr NegotiateTypes(tc *TypesContext) error }
Provides a type checking context to typed expressions.
type File ¶
type File struct {
Name, Code, Pkg string
// contains filtered or unexported fields
}
func (*File) Generate ¶
func (f *File) Generate(tc *TypesContext, current *CodeChunk)
func (*File) GenerateCode ¶
func (*File) ParseAndCheck ¶
type ForRangeStmt ¶
type ForRangeStmt struct { // Either ScopedVars or OutsideVars is nil ScopedVars *VarDecl OutsideVars []Expr Series Expr Code *CodeBlock // contains filtered or unexported fields }
func (*ForRangeStmt) Generate ¶
func (fs *ForRangeStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*ForRangeStmt) NegotiateTypes ¶
func (fs *ForRangeStmt) NegotiateTypes(tc *TypesContext) error
type ForStmt ¶
type ForStmt struct { ScopedVar Stmt Condition Expr RepeatStmt SimpleStmt Code *CodeBlock // contains filtered or unexported fields }
implements Stmt
func (*ForStmt) Generate ¶
func (fs *ForStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*ForStmt) NegotiateTypes ¶
func (fs *ForStmt) NegotiateTypes(tc *TypesContext) error
type FuncCallExpr ¶
type FuncCallExpr struct { Left Expr Args []Expr // Ellipsis is true if the last argument is variadic. Ellipsis bool // contains filtered or unexported fields }
implements PrimaryExpr
func (*FuncCallExpr) ApplyType ¶
func (ex *FuncCallExpr) ApplyType(tc *TypesContext, typ Type) error
func (*FuncCallExpr) Generate ¶
func (fc *FuncCallExpr) Generate(tc *TypesContext, current *CodeChunk)
func (*FuncCallExpr) GuessType ¶
func (ex *FuncCallExpr) GuessType(tc *TypesContext) (ok bool, typ Type)
func (*FuncCallExpr) IsNullResult ¶
func (ex *FuncCallExpr) IsNullResult(tc *TypesContext) bool
True if this function call doesn't return any value. Needs to operate on function call that has been already typechecked.
func (*FuncCallExpr) Type ¶
func (ex *FuncCallExpr) Type(tc *TypesContext) (Type, error)
type FuncDecl ¶
type FuncDecl struct {
Args, Results DeclChain
// Ellipsis is true if the last argument is variadic.
Ellipsis bool
Code *CodeBlock
// Is nil for non-method functions
Receiver *Variable
// Indicates whether the receiver is a pointer.
// It is redundant for structs, but is useful for interfaces
// (where Receiver is nil).
PtrReceiver bool
// Names of generic type paramaters. Nil for standard functions.
GenericParams []string
// Values of generic parameters. Nil for standard functions.
GenericParamVals []Type
// contains filtered or unexported fields
}
implements PrimaryExpr
func (*FuncDecl) Generate ¶
func (fd *FuncDecl) Generate(tc *TypesContext, current *CodeChunk)
func (*FuncDecl) InlineGenerate ¶
func (fd *FuncDecl) InlineGenerate(tc *TypesContext, current *CodeChunk, noParenth bool)
type FuncType ¶
type FuncType struct {
Args, Results []Type
// Ellipsis is true if the last argument is variadic.
Ellipsis bool
}
func (*FuncType) MapSubtypes ¶
type Generable ¶
type Generable interface { // Generate the full version of the output code. Generate(tc *TypesContext, current *CodeChunk) }
type Generic ¶
type Generic interface { Object // Name of the generic + names of the params. Signature() (name string, params []string) Instantiate(tc *TypesContext, params ...Type) (Object, string, []error) Code() []rune // Imports that should be used when parsing instantiation of the generic. // Usually they are inherited from the source file where the generic was declared. Imports() Imports // Token file containing the definition of the generic and offset where // the definition starts in the file. Location() (tfile *gotoken.File, offset int) }
func ExprToGeneric ¶
Just like ExprToTypeName, but for generics.
type GenericFunc ¶
type GenericFunc struct { Func *FuncDecl // contains filtered or unexported fields }
Implements Stmt, Object
func (*GenericFunc) Code ¶
func (gf *GenericFunc) Code() []rune
func (*GenericFunc) Generate ¶
func (gf *GenericFunc) Generate(tc *TypesContext, current *CodeChunk)
func (*GenericFunc) Imports ¶
func (gf *GenericFunc) Imports() Imports
func (*GenericFunc) Instantiate ¶
func (gf *GenericFunc) Instantiate(tc *TypesContext, params ...Type) (Object, string, []error)
func (*GenericFunc) Name ¶
func (gf *GenericFunc) Name() string
func (*GenericFunc) NegotiateTypes ¶
func (ls *GenericFunc) NegotiateTypes(tc *TypesContext) error
func (*GenericFunc) ObjectType ¶
func (gf *GenericFunc) ObjectType() ObjectType
func (*GenericFunc) Signature ¶
func (gf *GenericFunc) Signature() (string, []string)
type GenericParamType ¶
Implements Type
func (*GenericParamType) Kind ¶
func (t *GenericParamType) Kind() Kind
func (t *GenericType) Kind() Kind { return t.Concrete.Kind() }
func (*GenericParamType) Known ¶
func (t *GenericParamType) Known() bool
func (*GenericParamType) MapSubtypes ¶
func (t *GenericParamType) MapSubtypes(callback func(t Type) bool)
func (*GenericParamType) String ¶
func (t *GenericParamType) String() string
func (*GenericParamType) ZeroValue ¶
func (t *GenericParamType) ZeroValue() string
type GenericParamTypeDecl ¶
type GenericParamTypeDecl struct {
// contains filtered or unexported fields
}
Represents an argument to a generic statment (in early stages of compilation they can't be treated as type declarations - they are just placeholders for future types). Implements Object and Stmt
func (*GenericParamTypeDecl) Name ¶
func (g *GenericParamTypeDecl) Name() string
func (*GenericParamTypeDecl) ObjectType ¶
func (g *GenericParamTypeDecl) ObjectType() ObjectType
type GenericStruct ¶
type GenericStruct struct {
// contains filtered or unexported fields
}
Implements Stmt and Type. It is a pseudo-type, can't be directly used in a program.
func (*GenericStruct) Code ¶
func (gs *GenericStruct) Code() []rune
func (*GenericStruct) Generate ¶
func (gs *GenericStruct) Generate(tc *TypesContext, current *CodeChunk)
func (*GenericStruct) Imports ¶
func (gs *GenericStruct) Imports() Imports
func (*GenericStruct) Instantiate ¶
func (gs *GenericStruct) Instantiate(tc *TypesContext, params ...Type) (Object, string, []error)
func (*GenericStruct) Name ¶
func (gs *GenericStruct) Name() string
func (*GenericStruct) NegotiateTypes ¶
func (ls *GenericStruct) NegotiateTypes(tc *TypesContext) error
func (*GenericStruct) ObjectType ¶
func (gs *GenericStruct) ObjectType() ObjectType
func (*GenericStruct) Signature ¶
func (gs *GenericStruct) Signature() (string, []string)
type GenericType ¶
type GenericType struct { // Base name of the type. Doesn't include package name for external types. Name string // nil means local Package *ImportStmt Params []Type // This is filled by type checker, it's empty right after parsing. Generic *GenericStruct // This is filled by type checker, it's empty right after parsing. Struct *StructType }
func (*GenericType) Kind ¶
func (t *GenericType) Kind() Kind
func (*GenericType) Known ¶
func (t *GenericType) Known() bool
func (*GenericType) MapSubtypes ¶
func (t *GenericType) MapSubtypes(callback func(t Type) bool)
func (*GenericType) NamePtr ¶
func (t *GenericType) NamePtr() *string
func (*GenericType) PackagePtr ¶
func (t *GenericType) PackagePtr() *ImportStmt
func (*GenericType) RootType ¶
func (t *GenericType) RootType() Type
func (*GenericType) String ¶
func (t *GenericType) String() string
func (*GenericType) ZeroValue ¶
func (t *GenericType) ZeroValue() string
type Ident ¶
type Ident struct {
// contains filtered or unexported fields
}
implements PrimaryExpr
func (*Ident) Generate ¶
func (id *Ident) Generate(tc *TypesContext, current *CodeChunk)
func (*Ident) ReferedObject ¶
type IdentStack ¶
Stack of scopes available to the piece of code that is currently being parsed. It is a living stack, scopes are pushed to and popped from it as new blocks of code start and end. It is used for initial bonding of names and objects (packages, variables, types), which later helps the type checker.
type IfBranch ¶
type IfBranch struct { ScopedVar Stmt Condition Expr Code *CodeBlock // contains filtered or unexported fields }
implements Stmt
type IfStmt ¶
type IfStmt struct { Branches []*IfBranch // contains filtered or unexported fields }
implements Stmt
func (*IfStmt) Generate ¶
func (fs *IfStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*IfStmt) NegotiateTypes ¶
func (is *IfStmt) NegotiateTypes(tc *TypesContext) error
type IfaceStmt ¶
type IfaceStmt struct { Iface *IfaceType // contains filtered or unexported fields }
implements Stmt
func (*IfaceStmt) Generate ¶
func (is *IfaceStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*IfaceStmt) NegotiateTypes ¶
func (is *IfaceStmt) NegotiateTypes(tc *TypesContext) error
type IfaceType ¶
type IfaceType struct { // Keys in the order of declaration Keys []string Methods map[string]*FuncDecl // contains filtered or unexported fields }
func (*IfaceType) MapSubtypes ¶
type ImportStmt ¶
type ImportStmt struct {
// contains filtered or unexported fields
}
func (*ImportStmt) Generate ¶
func (i *ImportStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*ImportStmt) Name ¶
func (i *ImportStmt) Name() string
func (*ImportStmt) NegotiateTypes ¶
func (td *ImportStmt) NegotiateTypes(tc *TypesContext) error
func (*ImportStmt) ObjectType ¶
func (i *ImportStmt) ObjectType() ObjectType
type Imports ¶
type Imports map[string]*ImportStmt
type InlineGenerable ¶
type InlineGenerable interface { Generable // Generate a shorter version of the code that e.g. fits into for-loop header. InlineGenerate(tc *TypesContext, current *CodeChunk, noParenth bool) }
type Instantiation ¶
type Instantiation struct { FullName string Params []Type Generic Generic Object Object Init Expr // Nil for generics generating types // contains filtered or unexported fields }
func (*Instantiation) ParseAndCheck ¶
func (r *Instantiation) ParseAndCheck() []error
type LabelStmt ¶
type LabelStmt struct { Branchable Stmt // Either nil or branchable statement (for, switch, etc) // contains filtered or unexported fields }
implements Object and Stmt
func (*LabelStmt) Generate ¶
func (ls *LabelStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*LabelStmt) NegotiateTypes ¶
func (ls *LabelStmt) NegotiateTypes(tc *TypesContext) error
func (*LabelStmt) ObjectType ¶
func (l *LabelStmt) ObjectType() ObjectType
type NilExpr ¶
type NilExpr struct {
// contains filtered or unexported fields
}
func (*NilExpr) Generate ¶
func (n *NilExpr) Generate(tc *TypesContext, current *CodeChunk)
type Object ¶
type Object interface { Name() string ObjectType() ObjectType }
This serves a similar purpose to Go's types.Object
type ObjectExpr ¶
Some expressions refer to an object (e.g. variable, constant, instantiation). If so, they should implement this (not all do at the time of writing). ReferedObject() works only after type checking is done (some expressions can return correct values before that, but that's not guaranteed). Expressions that sometimes refer to an object and sometimes don't (e.g. array expression can refer to a generic instantiation or can just mean the n-th element in a slice (not an object)) - if so, they should implement it but return nils appropriately.
type ObjectType ¶
type ObjectType int
type Package ¶
type Package struct { Files []*File Fset *gotoken.FileSet // contains filtered or unexported fields }
func NewPackage ¶
func (*Package) ParseAndCheck ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Parse ¶
func (p *Parser) Parse() ([]*TopLevelStmt, error)
type PassStmt ¶
type PassStmt struct {
// contains filtered or unexported fields
}
implements Stmt
func (*PassStmt) Generate ¶
func (n *PassStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*PassStmt) NegotiateTypes ¶
func (p *PassStmt) NegotiateTypes(tc *TypesContext) error
type PkgLocator ¶
type PkgManager ¶
Provides access to packages, makes sure that no package is loaded more than once, etc.
func NewPkgManager ¶
func NewPkgManager(locator PkgLocator) *PkgManager
type PointerType ¶
type PointerType struct {
To Type
}
func (*PointerType) Kind ¶
func (t *PointerType) Kind() Kind
func (*PointerType) Known ¶
func (t *PointerType) Known() bool
func (*PointerType) MapSubtypes ¶
func (t *PointerType) MapSubtypes(callback func(t Type) bool)
func (*PointerType) String ¶
func (t *PointerType) String() string
func (*PointerType) ZeroValue ¶
func (t *PointerType) ZeroValue() string
type PrimaryExpr ¶
type PrimaryExpr interface { Expr }
type ReturnStmt ¶
func (*ReturnStmt) Generate ¶
func (rs *ReturnStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*ReturnStmt) NegotiateTypes ¶
func (rs *ReturnStmt) NegotiateTypes(tc *TypesContext) error
type SendStmt ¶
type SendStmt struct {
Lhs, Rhs Expr
// contains filtered or unexported fields
}
implements Stmt
func (*SendStmt) NegotiateTypes ¶
func (ls *SendStmt) NegotiateTypes(tc *TypesContext) error
type SimpleStmt ¶
type SimpleStmt interface { Stmt }
Simple statements are those that can be used in the 3rd clause of the `for` loop.
type SimpleType ¶
type SimpleType struct {
ID SimpleTypeID
}
func (*SimpleType) Kind ¶
func (t *SimpleType) Kind() Kind
func (*SimpleType) Known ¶
func (t *SimpleType) Known() bool
func (*SimpleType) MapSubtypes ¶
func (t *SimpleType) MapSubtypes(callback func(t Type) bool)
func (*SimpleType) String ¶
func (t *SimpleType) String() string
func (*SimpleType) ZeroValue ¶
func (t *SimpleType) ZeroValue() string
type SimpleTypeID ¶
type SimpleTypeID int
type SliceExpr ¶
type SliceExpr struct {
From, To Expr
// contains filtered or unexported fields
}
Represents subslice extraction - for x[a:b], it represents a:b. Implements Expr.
func (*SliceExpr) Generate ¶
func (se *SliceExpr) Generate(tc *TypesContext, current *CodeChunk)
type StructStmt ¶
type StructStmt struct { Struct *StructType Decl *TypeDecl // contains filtered or unexported fields }
implements Stmt
func (*StructStmt) Generate ¶
func (ss *StructStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*StructStmt) NegotiateTypes ¶
func (ss *StructStmt) NegotiateTypes(tc *TypesContext) error
type StructType ¶
type StructType struct { Members map[string]Type // Keys of the Members map in the order of declaration Keys []string Methods map[string]*FuncDecl Name string // Names of generic type paramaters. Nil for standard structs. GenericParams []string // Values of generic parameters. Nil for standard structs. GenericParamVals []Type // contains filtered or unexported fields }
func (*StructType) GetTypeN ¶
func (t *StructType) GetTypeN(n int) Type
func (*StructType) Kind ¶
func (t *StructType) Kind() Kind
func (*StructType) Known ¶
func (t *StructType) Known() bool
func (*StructType) MapSubtypes ¶
func (t *StructType) MapSubtypes(callback func(t Type) bool)
func (*StructType) String ¶
func (t *StructType) String() string
func (*StructType) ZeroValue ¶
func (t *StructType) ZeroValue() string
type SwitchBranch ¶
type SwitchBranch struct { // This can carry different kinds of expression depending on the switch variant: // - usually it can be any expressions comparable to the switch expression // - for free-form switches this has to be one expression assignable to bool // - for type switches this is a TypeExpr // - `nil` for `default` Values []Expr Code *CodeBlock // Type switches can declare a variable that has different type in each switch // branch. To keep things independent and invariant (and make the generator code less // fragile), we actually declare a separate variable internally for each branch // (all with the same name). // For non-type-switches this is nil. TypeSwitchVar *Variable // contains filtered or unexported fields }
implements Stmt
type SwitchStmt ¶
type SwitchStmt struct { // Either AssignStmt or VarStmt ScopedVar Stmt // For free-form switch statements it is nil, for type switches it is either // `a.(someType)` or `var b = a.(someType)`, and for the rest it is ExprStmt. Value Stmt Branches []*SwitchBranch // contains filtered or unexported fields }
implements Stmt
func (*SwitchStmt) Generate ¶
func (ss *SwitchStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*SwitchStmt) NegotiateTypes ¶
func (ss *SwitchStmt) NegotiateTypes(tc *TypesContext) error
type Token ¶
func (*Token) IsLogicalOp ¶
Tells if operator's operands can only be boolean.
type TokenType ¶
type TokenType int
const ( TOKEN_EOF TokenType = iota + 1 TOKEN_INDENT // indent - []rune of whitespace characters TOKEN_FOR // the "for" keyword TOKEN_WORD // alphanumeric word, starts witn a letter TOKEN_ASSIGN // = TOKEN_EQUALS // == TOKEN_NEQUALS // != TOKEN_GT // > TOKEN_LT // < TOKEN_EQ_LT // <= TOKEN_EQ_GT // >= TOKEN_NEGATE // ! TOKEN_INT // Integer number literal TOKEN_FLOAT // Float number literal TOKEN_IMAG // Imaginary part literal TOKEN_STR // string literal TOKEN_RUNE // rune literal TOKEN_DOT // . TOKEN_ELLIPSIS // ... TOKEN_LPARENTH // ( TOKEN_RPARENTH // ) TOKEN_LBRACKET // [ TOKEN_RBRACKET // ] TOKEN_LBRACE // { TOKEN_RBRACE // } TOKEN_PLUS // + TOKEN_PLUS_ASSIGN // += TOKEN_INCREMENT // ++ TOKEN_MINUS // - TOKEN_MINUS_ASSIGN // -= TOKEN_DECREMENT // -- TOKEN_VAR // the "var" keyword TOKEN_IF // the "if" keyword TOKEN_ELSE // the "else" keyword TOKEN_ELIF // the "elif" keyword TOKEN_SWITCH // the "switch" keyword TOKEN_CASE // the "case" keyword TOKEN_DEFAULT // the "default" keyword TOKEN_RETURN // the "return" keyword TOKEN_TRUE // the "true" keyword TOKEN_FALSE // the "false" keyword TOKEN_STRUCT // the "struct" keyword TOKEN_MAP // the "map" keyword TOKEN_FUNC // the "func" keyword TOKEN_IMPORT // the "import" keyword TOKEN_AS // the "as" keyword TOKEN_TYPE // the "type" keyword TOKEN_IN // the "in" keyword TOKEN_PASS // the "pass" keyword TOKEN_PACKAGE // the "package" keyword TOKEN_BREAK // the "break" keyword TOKEN_CONTINUE // the "continue" keyword TOKEN_FALLTHROUGH // the "fallthrough" keyword TOKEN_GOTO // the "goto" keyword TOKEN_INTERFACE // the "interface" keyword TOKEN_NIL // the "nil" keyword TOKEN_CHAN // the "chan" keyword TOKEN_RANGE // the "range" keyword TOKEN_WHEN // the "when" keyword TOKEN_IMPLEMENTS // the "implements" keyword TOKEN_IS // the "is" keyword TOKEN_MUL // * TOKEN_DIV // / TOKEN_MUL_ASSIGN // *= TOKEN_DIV_ASSIGN // /= TOKEN_SHL // << TOKEN_SHR // >> TOKEN_SEND // <- TOKEN_COMMA // , TOKEN_COLON // : TOKEN_SEMICOLON // ; TOKEN_AMP // & TOKEN_PIPE // | TOKEN_PERCENT // % TOKEN_AND // && TOKEN_OR // || TOKEN_SHARP // # TOKEN_UNEXP_CHAR // For error reporting )
type TopLevelStmt ¶
type TopLevelStmt struct { Stmt // contains filtered or unexported fields }
func (*TopLevelStmt) Decls ¶
func (s *TopLevelStmt) Decls() []string
List of top-level symbols declared within this statement.
func (*TopLevelStmt) Deps ¶
func (s *TopLevelStmt) Deps() []string
List of top-level symbols used within this statement.
type Type ¶
type Type interface { // True means no underscores beneath, no type inference needed. Known() bool String() string Kind() Kind ZeroValue() string MapSubtypes(callback func(t Type) bool) }
func ExprToTypeName ¶
func ExprToTypeName(tc *TypesContext, e Expr) (t Type, err error)
Sometimes it is not immediately obvious if a piece of code is an actual expression or a name of a type. That can happen during during type conversions, for example in the line below we don't know whether 'blah' is a type name or a function during parsing:
blah(123)
This function tells if an expression is really a type name, and returns that type if the answer was yes (nil otherwise). Additionaly, if it encounters an error it returns it, usually they are non-recoverable and can be printed out as compilation errors.
func UnderlyingType ¶
Implements the definition of underlying types from the Go spec.
type TypeAssertion ¶
type TypeAssertion struct { // When true, no concrete type was given in the parentheses, just // the "type" keyword. ForSwitch bool Left Expr Right *TypeExpr // contains filtered or unexported fields }
implements Expr
func (*TypeAssertion) ApplyType ¶
func (ex *TypeAssertion) ApplyType(tc *TypesContext, typ Type) error
func (*TypeAssertion) Generate ¶
func (ta *TypeAssertion) Generate(tc *TypesContext, current *CodeChunk)
func (*TypeAssertion) GuessType ¶
func (ex *TypeAssertion) GuessType(tc *TypesContext) (ok bool, typ Type)
func (*TypeAssertion) Type ¶
func (ex *TypeAssertion) Type(tc *TypesContext) (Type, error)
type TypeDecl ¶
type TypeDecl struct { AliasedType Type Methods map[string]*FuncDecl // contains filtered or unexported fields }
Implements Object and Stmt
func GetBuiltinType ¶
func (*TypeDecl) Generate ¶
func (td *TypeDecl) Generate(tc *TypesContext, current *CodeChunk)
func (*TypeDecl) NegotiateTypes ¶
func (td *TypeDecl) NegotiateTypes(tc *TypesContext) error
func (*TypeDecl) ObjectType ¶
func (o *TypeDecl) ObjectType() ObjectType
type TypedExpr ¶
type TypedExpr interface { Expr // Infers type of the expression based on facts that are certain - no guessing should // happen at this point. // Errors returned from Type() are reported as compilation errors. // Type() MUSTN'T return GenericType in any case, but the underlying type instead. Type(tc *TypesContext) (Type, error) // Called by the type checker when it wants this expression to be of a particular type. // If all goes well, this should affect the result of further calls to Type(). // If applying the given type is impossible, appropriate error should be returned (it // doesn't always mean the end of negotiation - further calls to Type/ApplyType/GuessType can // be expected). ApplyType(tc *TypesContext, typ Type) error // Tries to guess the most appropriate type for this expression. // GuessType(tc *TypesContext) MUSTN'T return GenericType in any case, but the underlying type instead. GuessType(tc *TypesContext) (ok bool, typ Type) }
type TypesContext ¶
type TypesContext struct {
// contains filtered or unexported fields
}
func NewTypesContext ¶
func NewTypesContext() *TypesContext
func (*TypesContext) GetType ¶
func (tc *TypesContext) GetType(e Expr) Type
func (*TypesContext) IsTypeSet ¶
func (tc *TypesContext) IsTypeSet(e Expr) bool
func (*TypesContext) SetType ¶
func (tc *TypesContext) SetType(e Expr, typ Type)
type UnaryOp ¶
type UnaryOp struct { Right Expr // contains filtered or unexported fields }
implements Expr
func (*UnaryOp) Generate ¶
func (op *UnaryOp) Generate(tc *TypesContext, current *CodeChunk)
type UnknownType ¶
type UnknownType struct{}
func (*UnknownType) Kind ¶
func (t *UnknownType) Kind() Kind
func (*UnknownType) Known ¶
func (t *UnknownType) Known() bool
func (*UnknownType) MapSubtypes ¶
func (t *UnknownType) MapSubtypes(callback func(t Type) bool)
func (*UnknownType) String ¶
func (t *UnknownType) String() string
func (*UnknownType) ZeroValue ¶
func (t *UnknownType) ZeroValue() string
type VarDecl ¶
func (*VarDecl) Generate ¶
func (vd *VarDecl) Generate(tc *TypesContext, current *CodeChunk)
func (*VarDecl) NegotiateTypes ¶
func (vd *VarDecl) NegotiateTypes(tc *TypesContext) error
type VarStmt ¶
implements Stmt
func (*VarStmt) Generate ¶
func (vs *VarStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*VarStmt) InlineGenerate ¶
func (vs *VarStmt) InlineGenerate(tc *TypesContext, current *CodeChunk, noParenth bool)
func (*VarStmt) NegotiateTypes ¶
func (vs *VarStmt) NegotiateTypes(tc *TypesContext) error
type Variable ¶
type Variable struct { Type Type // contains filtered or unexported fields }
Implements Object
func (*Variable) ObjectType ¶
func (o *Variable) ObjectType() ObjectType
type WhenBranch ¶
type WhenBranch struct { Predicates []*WhenPredicate Code *CodeBlock True bool // contains filtered or unexported fields }
type WhenPredicate ¶
type WhenPredicate struct { Kind WhenPredicateKind Target Type }
type WhenPredicateKind ¶
type WhenPredicateKind int
func TokenToWhenPred ¶
func TokenToWhenPred(t *Token) WhenPredicateKind
type WhenStmt ¶
type WhenStmt struct { Args []Type Branches []*WhenBranch // contains filtered or unexported fields }
func (*WhenStmt) Generate ¶
func (ws *WhenStmt) Generate(tc *TypesContext, current *CodeChunk)
func (*WhenStmt) NegotiateTypes ¶
func (ws *WhenStmt) NegotiateTypes(tc *TypesContext) error