Documentation
¶
Overview ¶
Package checker implements the Elk type checker
Package checker implements the Elk type checker ¶
Package checker implements the Elk type checker
Index ¶
- Constants
- func CheckAST(sourceName string, ast *ast.ProgramNode, globalEnv *types.GlobalEnvironment, ...) (*vm.BytecodeFunction, diagnostic.DiagnosticList)
- func CheckFile(fileName string, globalEnv *types.GlobalEnvironment, headerMode bool) (*vm.BytecodeFunction, diagnostic.DiagnosticList)
- func CheckSource(sourceName string, source string, globalEnv *types.GlobalEnvironment, ...) (*vm.BytecodeFunction, diagnostic.DiagnosticList)
- func I(typ types.Type) string
- type CheckExpressionFunc
- type Checker
- func (c *Checker) CanBeFalsy(typ types.Type) bool
- func (c *Checker) CanBeTruthy(typ types.Type) bool
- func (c *Checker) CheckSource(sourceName string, source string) (*vm.BytecodeFunction, diagnostic.DiagnosticList)
- func (c *Checker) ClearErrors()
- func (c *Checker) Env() *types.GlobalEnvironment
- func (c *Checker) GetIteratorElementType(typ types.Type) (types.Type, types.Type)
- func (c *Checker) GetIteratorType(typ types.Type) types.Type
- func (c *Checker) IsFalsy(typ types.Type) bool
- func (c *Checker) IsHeader() bool
- func (c *Checker) IsNil(typ types.Type) bool
- func (c *Checker) IsNilable(typ types.Type) bool
- func (c *Checker) IsNotNilable(typ types.Type) bool
- func (c *Checker) IsSubtype(a, b types.Type) bool
- func (c *Checker) IsTheSameNamespace(a, b types.Namespace) bool
- func (c *Checker) IsTheSameType(a, b types.Type) bool
- func (c *Checker) IsTruthy(typ types.Type) bool
- func (c *Checker) NewNormalisedIntersection(elements ...types.Type) types.Type
- func (c *Checker) NewNormalisedUnion(elements ...types.Type) types.Type
- func (c *Checker) NormaliseType(typ types.Type) types.Type
- func (c *Checker) SetHeader(val bool)
- func (c *Checker) Std(name value.Symbol) types.Type
- func (c *Checker) StdAST() *types.Module
- func (c *Checker) StdAnyInt() types.Type
- func (c *Checker) StdArrayList() *types.Class
- func (c *Checker) StdArrayTuple() *types.Class
- func (c *Checker) StdBigFloat() *types.Class
- func (c *Checker) StdBool() *types.Class
- func (c *Checker) StdClass() *types.Class
- func (c *Checker) StdElk() *types.Module
- func (c *Checker) StdExpressionNode() *types.Mixin
- func (c *Checker) StdExpressionNodeConvertible() *types.Interface
- func (c *Checker) StdFalse() *types.Class
- func (c *Checker) StdFloat() *types.Class
- func (c *Checker) StdHashMap() *types.Class
- func (c *Checker) StdHashRecord() *types.Class
- func (c *Checker) StdHashSet() *types.Class
- func (c *Checker) StdInspectable() types.Type
- func (c *Checker) StdInt() *types.Class
- func (c *Checker) StdList() *types.Mixin
- func (c *Checker) StdMap() *types.Mixin
- func (c *Checker) StdNil() *types.Class
- func (c *Checker) StdNode() *types.Mixin
- func (c *Checker) StdNodeConvertible() *types.Interface
- func (c *Checker) StdPrimitiveIterable() *types.Interface
- func (c *Checker) StdRange() *types.Mixin
- func (c *Checker) StdRecord() *types.Mixin
- func (c *Checker) StdSet() *types.Mixin
- func (c *Checker) StdString() *types.Class
- func (c *Checker) StdStringConvertible() types.Type
- func (c *Checker) StdTrue() *types.Class
- func (c *Checker) StdTuple() *types.Mixin
- func (c *Checker) ToNilable(typ types.Type) types.Type
- func (c *Checker) ToNonFalsy(typ types.Type) types.Type
- func (c *Checker) ToNonLiteral(typ types.Type, widenSingletonTypes bool) types.Type
- func (c *Checker) ToNonNilable(typ types.Type) types.Type
- func (c *Checker) ToNonTruthy(typ types.Type) types.Type
- func (c *Checker) TypeOf(node ast.Node) types.Type
- func (c *Checker) TypesIntersect(a, b types.Type) bool
Constants ¶
View Source
const ( NEW_CONST constState = iota CHECKING_CONST CHECKED_CONST )
View Source
const ( NEW_TYPEDEF typedefState = iota CHECKING_TYPEDEF CHECKED_TYPEDEF )
Variables ¶
This section is empty.
Functions ¶
func CheckAST ¶
func CheckAST(sourceName string, ast *ast.ProgramNode, globalEnv *types.GlobalEnvironment, headerMode bool) (*vm.BytecodeFunction, diagnostic.DiagnosticList)
Check the types of an Elk AST.
func CheckFile ¶
func CheckFile(fileName string, globalEnv *types.GlobalEnvironment, headerMode bool) (*vm.BytecodeFunction, diagnostic.DiagnosticList)
Check the types of an Elk file.
func CheckSource ¶
func CheckSource(sourceName string, source string, globalEnv *types.GlobalEnvironment, headerMode bool) (*vm.BytecodeFunction, diagnostic.DiagnosticList)
Check the types of Elk source code.
Types ¶
type CheckExpressionFunc ¶
type CheckExpressionFunc func(ast.ExpressionNode) ast.ExpressionNode
type Checker ¶
type Checker struct { Filename string // name of the current source file Errors *diagnostic.SyncDiagnosticList // list of typechecking errors // contains filtered or unexported fields }
Holds the state of the type checking process
func NewWithEnv ¶
func NewWithEnv(env *types.GlobalEnvironment) *Checker
Instantiate a new Checker instance.
func (*Checker) CheckSource ¶
func (c *Checker) CheckSource(sourceName string, source string) (*vm.BytecodeFunction, diagnostic.DiagnosticList)
Used in the REPL to typecheck and compile the input
func (*Checker) ClearErrors ¶
func (c *Checker) ClearErrors()
func (*Checker) Env ¶
func (c *Checker) Env() *types.GlobalEnvironment
func (*Checker) GetIteratorElementType ¶
func (*Checker) IsNotNilable ¶
Type cannot be `nil`
func (*Checker) IsTheSameNamespace ¶
Check whether the two given types represent the same type. Return true if they do, otherwise false.
func (*Checker) NewNormalisedIntersection ¶
func (*Checker) NewNormalisedUnion ¶
func (*Checker) StdArrayList ¶
func (*Checker) StdArrayTuple ¶
func (*Checker) StdBigFloat ¶
func (*Checker) StdExpressionNode ¶
func (*Checker) StdExpressionNodeConvertible ¶
func (*Checker) StdHashMap ¶
func (*Checker) StdHashRecord ¶
func (*Checker) StdHashSet ¶
func (*Checker) StdInspectable ¶
func (*Checker) StdNodeConvertible ¶
func (*Checker) StdPrimitiveIterable ¶
func (*Checker) StdStringConvertible ¶
func (*Checker) ToNonLiteral ¶
Click to show internal directories.
Click to hide internal directories.