typechecker

package
v0.0.0-...-f82d28d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrimInt        = "Int"
	PrimInt8       = "Int8"
	PrimInt16      = "Int16"
	PrimInt32      = "Int32"
	PrimInt64      = "Int64"
	PrimUint       = "Uint"
	PrimUint8      = "Uint8"
	PrimUint16     = "Uint16"
	PrimUint32     = "Uint32"
	PrimUint64     = "Uint64"
	PrimUintptr    = "Uintptr"
	PrimFloat32    = "Float32"
	PrimFloat64    = "Float64"
	PrimComplex64  = "Complex64"
	PrimComplex128 = "Complex128"
	PrimByte       = "Byte"
	PrimBool       = "Bool"
	PrimString     = "String"
	PrimRune       = "Rune"
	PrimUnit       = "Unit"
	PrimList       = "List"
	PrimSet        = "Set"
)

Variables

View Source
var PrimitiveTypes = map[string]ast.Type{
	"Byte":       tByte,
	"Int":        tInt,
	"Int8":       tInt8,
	"Int16":      tInt16,
	"Int32":      tInt32,
	"Int64":      tInt64,
	"Uint":       tUint,
	"Uint8":      tUint8,
	"Uint16":     tUint16,
	"Uint32":     tUint32,
	"Uint64":     tUint64,
	"Uintptr":    tUintptr,
	"Float32":    tFloat32,
	"Float64":    tFloat64,
	"Complex64":  tComplex64,
	"Complex128": tComplex128,
	"Bool":       tBool,
	"Rune":       tRune,
	"String":     tString,
	"Unit":       tUnit,
}

All primitive types that should be added to the environment

Functions

This section is empty.

Types

type DeclRef

type DeclRef struct {
	Type       ast.Type
	Visibility ast.Visibility
	IsInstance bool
	Comment    *lexer.Comment
}

type Env

type Env struct {
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv() *Env

func (*Env) AddPrimitiveTypes

func (e *Env) AddPrimitiveTypes()

func (*Env) Extend

func (e *Env) Extend(name string, typ ast.Type)

func (*Env) ExtendInstance

func (e *Env) ExtendInstance(name string, typ ast.Type, isLambdaVar bool)

func (*Env) ExtendType

func (e *Env) ExtendType(name string, typ ast.Type)

func (*Env) ForEachInstance

func (e *Env) ForEachInstance(action func(string, InstanceEnv))

func (*Env) Fork

func (e *Env) Fork() *Env

Returns a copy of the original env. This will reallocate all the maps.

func (*Env) Lookup

func (e *Env) Lookup(name string) (ast.Type, bool)

func (*Env) LookupType

func (e *Env) LookupType(name string) (ast.Type, bool)

func (*Env) Remove

func (e *Env) Remove(name string)

type FullModuleEnv

type FullModuleEnv struct {
	Env         ModuleEnv
	Ast         ast.Module
	Aliases     []ast.STypeAliasDecl
	TypeVarsMap map[int]string
	Comment     *lexer.Comment
	IsStdlib    bool
}

type Inference

type Inference struct {
	// contains filtered or unexported fields
}

func NewInference

func NewInference(tc *Typechecker, uni *Unification) *Inference

type InstanceEnv

type InstanceEnv struct {
	Type        ast.Type
	IsLambdaVar bool
	TypeName    string
}

type ModuleEnv

type ModuleEnv struct {
	Decls map[string]DeclRef
	Types map[string]TypeDeclRef
}

type PatternVar

type PatternVar struct {
	// contains filtered or unexported fields
}

type TypeDeclRef

type TypeDeclRef struct {
	Type       ast.Type
	Visibility ast.Visibility
	Ctors      []string
	Comment    *lexer.Comment
}

type TypeLabel

type TypeLabel = data.LabelMap[ast.Type]

type Typechecker

type Typechecker struct {
	TypeVarMap map[int]string
	// contains filtered or unexported fields
}

func NewTypechecker

func NewTypechecker() *Typechecker

func (*Typechecker) Env

func (tc *Typechecker) Env() *Env

func (*Typechecker) Errors

func (tc *Typechecker) Errors() []data.CompilerProblem

func (*Typechecker) Infer

func (tc *Typechecker) Infer(mod ast.Module) (ModuleEnv, error)

func (*Typechecker) NewGenVar

func (tc *Typechecker) NewGenVar() ast.TVar

func (*Typechecker) NewGenVarName

func (tc *Typechecker) NewGenVarName(name string) ast.TVar

func (*Typechecker) NewVar

func (tc *Typechecker) NewVar(level ast.Level) ast.Type

type TypingContext

type TypingContext struct {
	// contains filtered or unexported fields
}

type Unification

type Unification struct {
	// contains filtered or unexported fields
}

func NewUnification

func NewUnification(tc *Typechecker) *Unification

func (*Unification) MatchRowType

func (u *Unification) MatchRowType(typ ast.Type, span data.Span) (data.LabelMap[ast.Type], ast.Type, *data.CompilerProblem)

func (*Unification) Unify

func (u *Unification) Unify(t1, t2 ast.Type, span data.Span) *data.CompilerProblem

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL