ast

package
v0.0.0-...-7d08e18 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Construct

func Construct(module *Module, modules *ModuleLookup)

func EscapeString

func EscapeString(s string) string

escape for debug output only things that can't be displayed need to be escaped

func ExtractTypeVariable

func ExtractTypeVariable(pattern *TypeReference, value *TypeReference) (map[string]*TypeReference, error)

ExtractTypeVariable takes a pattern type containing one or more substitution types together with a value type, and generates a map from the substitution types to the the corresponding parts of the value type. An example would be: pattern: Pointer($T)

 value: Pointer(int)
return: {T: int}

func Infer

func Infer(submod *Submodule)

func IsPointerOrReferenceType

func IsPointerOrReferenceType(t Type) bool

func LoadRuntimeModule

func LoadRuntimeModule(mod *Module)

func Resolve

func Resolve(mod *Module, mods *ModuleLookup)

func TypeReferenceMangledName

func TypeReferenceMangledName(mangleType MangleType, typ *TypeReference, gcon *GenericContext) string

easier than making a method for all types

func TypeReferencesMangledName

func TypeReferencesMangledName(mangleType MangleType, typs []*TypeReference, gcon *GenericContext) string

Types

type ASTStringer

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

String representation util

func NewASTStringer

func NewASTStringer(name string) *ASTStringer

func (*ASTStringer) Add

func (v *ASTStringer) Add(what fmt.Stringer) *ASTStringer

func (*ASTStringer) AddAttrs

func (v *ASTStringer) AddAttrs(attrs parser.AttrGroup) *ASTStringer

func (*ASTStringer) AddGenericArguments

func (v *ASTStringer) AddGenericArguments(args []*TypeReference) *ASTStringer

func (*ASTStringer) AddString

func (v *ASTStringer) AddString(what string) *ASTStringer

func (*ASTStringer) AddStringColored

func (v *ASTStringer) AddStringColored(color string, what string) *ASTStringer

func (*ASTStringer) AddType

func (v *ASTStringer) AddType(t Type) *ASTStringer

func (*ASTStringer) AddTypeReference

func (v *ASTStringer) AddTypeReference(t *TypeReference) *ASTStringer

func (*ASTStringer) AddWithColor

func (v *ASTStringer) AddWithColor(color string, what fmt.Stringer) *ASTStringer

func (*ASTStringer) AddWithFallback

func (v *ASTStringer) AddWithFallback(color string, what fmt.Stringer, fallback string) *ASTStringer

func (*ASTStringer) Finish

func (v *ASTStringer) Finish() string

type ASTVisitor

type ASTVisitor struct {
	Visitor Visitor
}

func NewASTVisitor

func NewASTVisitor(visitor Visitor) *ASTVisitor

func (*ASTVisitor) EnterScope

func (v *ASTVisitor) EnterScope()

func (*ASTVisitor) ExitScope

func (v *ASTVisitor) ExitScope()

func (*ASTVisitor) Visit

func (v *ASTVisitor) Visit(n Node) Node

func (*ASTVisitor) VisitBlock

func (v *ASTVisitor) VisitBlock(b *Block) *Block

func (*ASTVisitor) VisitBlocks

func (v *ASTVisitor) VisitBlocks(blocks []*Block) []*Block

func (*ASTVisitor) VisitChildren

func (v *ASTVisitor) VisitChildren(n Node)

func (*ASTVisitor) VisitExpr

func (v *ASTVisitor) VisitExpr(e Expr) Expr

func (*ASTVisitor) VisitExprs

func (v *ASTVisitor) VisitExprs(exprs []Expr) []Expr

func (*ASTVisitor) VisitFunction

func (v *ASTVisitor) VisitFunction(fn *Function)

func (*ASTVisitor) VisitNodes

func (v *ASTVisitor) VisitNodes(nodes []Node) []Node

func (*ASTVisitor) VisitSubmodule

func (v *ASTVisitor) VisitSubmodule(submodule *Submodule)

type AccessExpr

type AccessExpr interface {
	Expr
	Mutable() bool
}

type AnnotatedTyped

type AnnotatedTyped struct {
	Pos   lexer.Position
	Typed Typed
	Id    int
}

type ArrayAccessExpr

type ArrayAccessExpr struct {
	Array     AccessExpr
	Subscript Expr
	// contains filtered or unexported fields
}

func (ArrayAccessExpr) GetType

func (v ArrayAccessExpr) GetType() *TypeReference

func (ArrayAccessExpr) Mutable

func (v ArrayAccessExpr) Mutable() bool

func (ArrayAccessExpr) NodeName

func (_ ArrayAccessExpr) NodeName() string

func (ArrayAccessExpr) Pos

func (v ArrayAccessExpr) Pos() lexer.Position

func (*ArrayAccessExpr) SetPos

func (v *ArrayAccessExpr) SetPos(pos lexer.Position)

func (ArrayAccessExpr) SetType

func (_ ArrayAccessExpr) SetType(t *TypeReference)

Noops

func (ArrayAccessExpr) String

func (v ArrayAccessExpr) String() string

type ArrayLenExpr

type ArrayLenExpr struct {
	Expr Expr
	Type Type
	// contains filtered or unexported fields
}

func (ArrayLenExpr) GetType

func (v ArrayLenExpr) GetType() *TypeReference

func (ArrayLenExpr) NodeName

func (_ ArrayLenExpr) NodeName() string

func (ArrayLenExpr) Pos

func (v ArrayLenExpr) Pos() lexer.Position

func (*ArrayLenExpr) SetPos

func (v *ArrayLenExpr) SetPos(pos lexer.Position)

func (ArrayLenExpr) SetType

func (_ ArrayLenExpr) SetType(t *TypeReference)

func (ArrayLenExpr) String

func (v ArrayLenExpr) String() string

type ArrayType

type ArrayType struct {
	MemberType *TypeReference

	IsFixedLength bool
	Length        int // TODO change to uint64
	// contains filtered or unexported fields
}

func ArrayOf

func ArrayOf(t *TypeReference, isFixedLength bool, length int) ArrayType

IMPORTANT: Using this function is no longer important, just make sure to use .Equals() to compare two types.

func (ArrayType) ActualType

func (v ArrayType) ActualType() Type

func (ArrayType) Attrs

func (v ArrayType) Attrs() parser.AttrGroup

func (ArrayType) CanCastTo

func (v ArrayType) CanCastTo(t Type) bool

func (ArrayType) Equals

func (v ArrayType) Equals(t Type) bool

func (ArrayType) IsFloatingType

func (v ArrayType) IsFloatingType() bool

func (ArrayType) IsIntegerType

func (v ArrayType) IsIntegerType() bool

func (ArrayType) IsSigned

func (v ArrayType) IsSigned() bool

func (ArrayType) IsVoidType

func (v ArrayType) IsVoidType() bool

func (ArrayType) LevelsOfIndirection

func (v ArrayType) LevelsOfIndirection() int

func (ArrayType) String

func (v ArrayType) String() string

func (ArrayType) TypeName

func (v ArrayType) TypeName() string

type AssignStat

type AssignStat struct {
	Access     AccessExpr
	Assignment Expr
	// contains filtered or unexported fields
}

func (AssignStat) NodeName

func (_ AssignStat) NodeName() string

func (AssignStat) Pos

func (v AssignStat) Pos() lexer.Position

func (*AssignStat) SetPos

func (v *AssignStat) SetPos(pos lexer.Position)

func (AssignStat) String

func (v AssignStat) String() string

type BinaryExpr

type BinaryExpr struct {
	Lhand, Rhand Expr
	Op           parser.BinOpType
	Type         *TypeReference
	// contains filtered or unexported fields
}

func (BinaryExpr) GetType

func (v BinaryExpr) GetType() *TypeReference

func (BinaryExpr) NodeName

func (_ BinaryExpr) NodeName() string

func (BinaryExpr) Pos

func (v BinaryExpr) Pos() lexer.Position

func (*BinaryExpr) SetPos

func (v *BinaryExpr) SetPos(pos lexer.Position)

func (*BinaryExpr) SetType

func (v *BinaryExpr) SetType(t *TypeReference)

BinaryExpr

func (BinaryExpr) String

func (v BinaryExpr) String() string

type BinopAssignStat

type BinopAssignStat struct {
	Access     AccessExpr
	Operator   parser.BinOpType
	Assignment Expr
	// contains filtered or unexported fields
}

func (BinopAssignStat) NodeName

func (_ BinopAssignStat) NodeName() string

func (BinopAssignStat) Pos

func (v BinopAssignStat) Pos() lexer.Position

func (*BinopAssignStat) SetPos

func (v *BinopAssignStat) SetPos(pos lexer.Position)

func (BinopAssignStat) String

func (v BinopAssignStat) String() string

type Block

type Block struct {
	Nodes         []Node
	IsTerminating bool
	NonScoping    bool
	// contains filtered or unexported fields
}

func (Block) LastNode

func (v Block) LastNode() Node

nil if no nodes

func (Block) NodeName

func (_ Block) NodeName() string

func (Block) Pos

func (v Block) Pos() lexer.Position

func (*Block) SetPos

func (v *Block) SetPos(pos lexer.Position)

func (Block) String

func (v Block) String() string

type BlockStat

type BlockStat struct {
	Block *Block
	// contains filtered or unexported fields
}

func (BlockStat) NodeName

func (_ BlockStat) NodeName() string

func (BlockStat) Pos

func (v BlockStat) Pos() lexer.Position

func (*BlockStat) SetPos

func (v *BlockStat) SetPos(pos lexer.Position)

func (BlockStat) String

func (v BlockStat) String() string

type BoolLiteral

type BoolLiteral struct {
	Value bool
	// contains filtered or unexported fields
}

func (BoolLiteral) GetType

func (v BoolLiteral) GetType() *TypeReference

func (BoolLiteral) NodeName

func (_ BoolLiteral) NodeName() string

func (BoolLiteral) Pos

func (v BoolLiteral) Pos() lexer.Position

func (*BoolLiteral) SetPos

func (v *BoolLiteral) SetPos(pos lexer.Position)

func (BoolLiteral) SetType

func (_ BoolLiteral) SetType(t *TypeReference)

func (BoolLiteral) String

func (v BoolLiteral) String() string

type BreakStat

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

func (BreakStat) NodeName

func (_ BreakStat) NodeName() string

func (BreakStat) Pos

func (v BreakStat) Pos() lexer.Position

func (*BreakStat) SetPos

func (v *BreakStat) SetPos(pos lexer.Position)

func (BreakStat) String

func (v BreakStat) String() string

type CallExpr

type CallExpr struct {
	Function       Expr
	Arguments      []Expr
	ReceiverAccess Expr // nil if not method or if static
	// contains filtered or unexported fields
}

func (CallExpr) GetType

func (v CallExpr) GetType() *TypeReference

func (CallExpr) NodeName

func (_ CallExpr) NodeName() string

func (CallExpr) Pos

func (v CallExpr) Pos() lexer.Position

func (*CallExpr) SetPos

func (v *CallExpr) SetPos(pos lexer.Position)

func (CallExpr) SetType

func (_ CallExpr) SetType(t *TypeReference)

func (CallExpr) String

func (v CallExpr) String() string

type CallStat

type CallStat struct {
	Call *CallExpr
	// contains filtered or unexported fields
}

func (CallStat) NodeName

func (_ CallStat) NodeName() string

func (CallStat) Pos

func (v CallStat) Pos() lexer.Position

func (*CallStat) SetPos

func (v *CallStat) SetPos(pos lexer.Position)

func (CallStat) String

func (v CallStat) String() string

type CastExpr

type CastExpr struct {
	Expr Expr
	Type *TypeReference
	// contains filtered or unexported fields
}

func (CastExpr) GetType

func (v CastExpr) GetType() *TypeReference

func (CastExpr) NodeName

func (_ CastExpr) NodeName() string

func (CastExpr) Pos

func (v CastExpr) Pos() lexer.Position

func (*CastExpr) SetPos

func (v *CastExpr) SetPos(pos lexer.Position)

func (CastExpr) SetType

func (_ CastExpr) SetType(t *TypeReference)

func (CastExpr) String

func (v CastExpr) String() string

type CompositeLiteral

type CompositeLiteral struct {
	Type   *TypeReference
	Fields []string // len(Fields) == len(Values). empty fields represented as ""
	Values []Expr
	// contains filtered or unexported fields
}

func (CompositeLiteral) GetType

func (v CompositeLiteral) GetType() *TypeReference

func (CompositeLiteral) NodeName

func (_ CompositeLiteral) NodeName() string

func (CompositeLiteral) Pos

func (v CompositeLiteral) Pos() lexer.Position

func (*CompositeLiteral) SetPos

func (v *CompositeLiteral) SetPos(pos lexer.Position)

func (*CompositeLiteral) SetType

func (v *CompositeLiteral) SetType(t *TypeReference)

ArrayLiteral

func (CompositeLiteral) String

func (v CompositeLiteral) String() string

type Constraint

type Constraint struct {
	Left, Right Side
}

Constraint represents a single constraint to be solved. It consists of two "sides", each representing a type or a type variable.

func ConstraintFromTypes

func ConstraintFromTypes(left, right *TypeReference) *Constraint

func (*Constraint) String

func (v *Constraint) String() string

func (*Constraint) Subs

func (v *Constraint) Subs(id int, side Side) *Constraint

type ConstructableExpr

type ConstructableExpr interface {
	// contains filtered or unexported methods
}

type ConstructableNode

type ConstructableNode interface {
	// contains filtered or unexported methods
}

type ConstructableType

type ConstructableType interface {
	// contains filtered or unexported methods
}

type Constructor

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

type ConstructorId

type ConstructorId int
const (
	ConstructorInvalid ConstructorId = iota
	ConstructorStructMember
	ConstructorDeref
	ConstructorArrayIndex
)

type ConstructorType

type ConstructorType struct {
	Id   ConstructorId
	Args []*TypeReference

	// Some constructors need additional data
	Data interface{}
	// contains filtered or unexported fields
}

ConstructorType is an abstraction that in principle could represent any type that is built from other types. As we can use the actual types for most of these, this type is only used to represent the type of a struct member or, until removal, the type of tuple member by index.

func (*ConstructorType) ActualType

func (v *ConstructorType) ActualType() Type

func (ConstructorType) Attrs

func (v ConstructorType) Attrs() parser.AttrGroup

func (ConstructorType) CanCastTo

func (v ConstructorType) CanCastTo(t Type) bool

func (*ConstructorType) Equals

func (v *ConstructorType) Equals(other Type) bool

func (ConstructorType) IsFloatingType

func (v ConstructorType) IsFloatingType() bool

func (ConstructorType) IsIntegerType

func (v ConstructorType) IsIntegerType() bool

func (ConstructorType) IsSigned

func (v ConstructorType) IsSigned() bool

func (ConstructorType) IsVoidType

func (v ConstructorType) IsVoidType() bool

func (ConstructorType) LevelsOfIndirection

func (v ConstructorType) LevelsOfIndirection() int

func (*ConstructorType) String

func (v *ConstructorType) String() string

func (*ConstructorType) TypeName

func (v *ConstructorType) TypeName() string

type Decl

type Decl interface {
	Node

	IsPublic() bool
	SetPublic(bool)
	// contains filtered or unexported methods
}

type DeferStat

type DeferStat struct {
	Call *CallExpr
	// contains filtered or unexported fields
}

func (DeferStat) NodeName

func (_ DeferStat) NodeName() string

func (DeferStat) Pos

func (v DeferStat) Pos() lexer.Position

func (*DeferStat) SetPos

func (v *DeferStat) SetPos(pos lexer.Position)

func (DeferStat) String

func (v DeferStat) String() string

type Dependency

type Dependency struct{ Src, Dst *DependencyNode }

type DependencyGraph

type DependencyGraph struct {
	Nodes       NodeSet
	NodeIndices map[string]int
	EdgesFrom   map[string][]Dependency
	// contains filtered or unexported fields
}

func NewDependencyGraph

func NewDependencyGraph() *DependencyGraph

func (*DependencyGraph) AddDependency

func (v *DependencyGraph) AddDependency(source, dependency *ModuleName)

func (*DependencyGraph) DetectCycles

func (d *DependencyGraph) DetectCycles() []string

type DependencyNode

type DependencyNode struct {
	Module *ModuleName
	// contains filtered or unexported fields
}

type DerefAccessExpr

type DerefAccessExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

func (DerefAccessExpr) GetType

func (v DerefAccessExpr) GetType() *TypeReference

func (DerefAccessExpr) Mutable

func (v DerefAccessExpr) Mutable() bool

func (DerefAccessExpr) NodeName

func (_ DerefAccessExpr) NodeName() string

func (DerefAccessExpr) Pos

func (v DerefAccessExpr) Pos() lexer.Position

func (*DerefAccessExpr) SetPos

func (v *DerefAccessExpr) SetPos(pos lexer.Position)

func (DerefAccessExpr) SetType

func (_ DerefAccessExpr) SetType(t *TypeReference)

func (DerefAccessExpr) String

func (v DerefAccessExpr) String() string

type DestructAssignStat

type DestructAssignStat struct {
	Accesses   []AccessExpr
	Assignment Expr
	// contains filtered or unexported fields
}

func (DestructAssignStat) NodeName

func (_ DestructAssignStat) NodeName() string

func (DestructAssignStat) Pos

func (v DestructAssignStat) Pos() lexer.Position

func (*DestructAssignStat) SetPos

func (v *DestructAssignStat) SetPos(pos lexer.Position)

func (DestructAssignStat) String

func (v DestructAssignStat) String() string

type DestructBinopAssignStat

type DestructBinopAssignStat struct {
	Accesses   []AccessExpr
	Operator   parser.BinOpType
	Assignment Expr
	// contains filtered or unexported fields
}

func (DestructBinopAssignStat) NodeName

func (_ DestructBinopAssignStat) NodeName() string

func (DestructBinopAssignStat) Pos

func (v DestructBinopAssignStat) Pos() lexer.Position

func (*DestructBinopAssignStat) SetPos

func (v *DestructBinopAssignStat) SetPos(pos lexer.Position)

func (DestructBinopAssignStat) String

func (v DestructBinopAssignStat) String() string

type DestructVarDecl

type DestructVarDecl struct {
	PublicHandler
	Variables     []*Variable
	ShouldDiscard []bool
	Assignment    Expr
	// contains filtered or unexported fields
}

DestructVarDecl

func (DestructVarDecl) DocComments

func (v DestructVarDecl) DocComments() []*parser.DocComment

func (DestructVarDecl) NodeName

func (_ DestructVarDecl) NodeName() string

func (DestructVarDecl) Pos

func (v DestructVarDecl) Pos() lexer.Position

func (*DestructVarDecl) SetPos

func (v *DestructVarDecl) SetPos(pos lexer.Position)

func (DestructVarDecl) String

func (v DestructVarDecl) String() string

type DiscardAccessExpr

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

func (DiscardAccessExpr) GetType

func (v DiscardAccessExpr) GetType() *TypeReference

func (DiscardAccessExpr) Mutable

func (v DiscardAccessExpr) Mutable() bool

func (DiscardAccessExpr) NodeName

func (_ DiscardAccessExpr) NodeName() string

func (DiscardAccessExpr) Pos

func (v DiscardAccessExpr) Pos() lexer.Position

func (*DiscardAccessExpr) SetPos

func (v *DiscardAccessExpr) SetPos(pos lexer.Position)

func (DiscardAccessExpr) SetType

func (_ DiscardAccessExpr) SetType(t *TypeReference)

func (DiscardAccessExpr) String

func (v DiscardAccessExpr) String() string

type EnumLiteral

type EnumLiteral struct {
	Type   *TypeReference
	Member string

	TupleLiteral     *TupleLiteral
	CompositeLiteral *CompositeLiteral
	// contains filtered or unexported fields
}

func (EnumLiteral) GetType

func (v EnumLiteral) GetType() *TypeReference

func (EnumLiteral) NodeName

func (_ EnumLiteral) NodeName() string

func (EnumLiteral) Pos

func (v EnumLiteral) Pos() lexer.Position

func (*EnumLiteral) SetPos

func (v *EnumLiteral) SetPos(pos lexer.Position)

func (*EnumLiteral) SetType

func (v *EnumLiteral) SetType(t *TypeReference)

func (EnumLiteral) String

func (v EnumLiteral) String() string

type EnumPatternExpr

type EnumPatternExpr struct {
	MemberName UnresolvedName
	Variables  []*Variable

	EnumType *TypeReference
	// contains filtered or unexported fields
}

func (EnumPatternExpr) GetType

func (v EnumPatternExpr) GetType() *TypeReference

func (EnumPatternExpr) NodeName

func (_ EnumPatternExpr) NodeName() string

func (EnumPatternExpr) Pos

func (v EnumPatternExpr) Pos() lexer.Position

func (*EnumPatternExpr) SetPos

func (v *EnumPatternExpr) SetPos(pos lexer.Position)

func (*EnumPatternExpr) SetType

func (v *EnumPatternExpr) SetType(t *TypeReference)

func (EnumPatternExpr) String

func (v EnumPatternExpr) String() string

type EnumType

type EnumType struct {
	Simple            bool
	GenericParameters GenericSigil
	Members           []EnumTypeMember
	// contains filtered or unexported fields
}

EnumType

func (EnumType) ActualType

func (v EnumType) ActualType() Type

func (EnumType) Attrs

func (v EnumType) Attrs() parser.AttrGroup

func (EnumType) CanCastTo

func (v EnumType) CanCastTo(t Type) bool

func (EnumType) Equals

func (v EnumType) Equals(t Type) bool

func (EnumType) GetMember

func (v EnumType) GetMember(name string) (EnumTypeMember, bool)

func (EnumType) IsFloatingType

func (v EnumType) IsFloatingType() bool

func (EnumType) IsIntegerType

func (v EnumType) IsIntegerType() bool

func (EnumType) IsSigned

func (v EnumType) IsSigned() bool

func (EnumType) IsVoidType

func (v EnumType) IsVoidType() bool

func (EnumType) LevelsOfIndirection

func (v EnumType) LevelsOfIndirection() int

func (EnumType) MemberIndex

func (v EnumType) MemberIndex(name string) int

func (EnumType) String

func (v EnumType) String() string

func (EnumType) TypeName

func (v EnumType) TypeName() string

type EnumTypeMember

type EnumTypeMember struct {
	Name string
	Type Type
	Tag  int
}

type Expr

type Expr interface {
	Node
	Typed
	// contains filtered or unexported methods
}

type Function

type Function struct {
	Name       string
	Type       FunctionType
	Parameters []*VariableDecl
	Body       *Block
	Accesses   []*FunctionAccessExpr

	ParentModule *Module

	Receiver *VariableDecl // non-nil if non-static method

	StaticReceiverType Type // non-nil if static

	Anonymous bool
}

Note that for static methods, “

func GetMethod

func GetMethod(typ Type, name string) *Function

func (Function) MangledName

func (v Function) MangledName(typ MangleType, gcon *GenericContext) string

func (Function) String

func (v Function) String() string

type FunctionAccessExpr

type FunctionAccessExpr struct {
	Function       *Function
	ReceiverAccess Expr // should be same as on the callexpr

	GenericArguments    []*TypeReference
	ExtraGenericContext *GenericContext // used when we're calling on a substitution type wth generic interface constraints

	ParentFunction *Function // the function this access expression is located in
	// contains filtered or unexported fields
}

FunctionAccessExpr

func (FunctionAccessExpr) GetType

func (v FunctionAccessExpr) GetType() *TypeReference

func (FunctionAccessExpr) NodeName

func (_ FunctionAccessExpr) NodeName() string

func (FunctionAccessExpr) Pos

func (v FunctionAccessExpr) Pos() lexer.Position

func (*FunctionAccessExpr) SetPos

func (v *FunctionAccessExpr) SetPos(pos lexer.Position)

func (*FunctionAccessExpr) SetType

func (v *FunctionAccessExpr) SetType(t *TypeReference)

func (FunctionAccessExpr) String

func (v FunctionAccessExpr) String() string

type FunctionDecl

type FunctionDecl struct {
	PublicHandler
	Function  *Function
	Prototype bool
	// contains filtered or unexported fields
}

func (FunctionDecl) DocComments

func (v FunctionDecl) DocComments() []*parser.DocComment

func (FunctionDecl) NodeName

func (_ FunctionDecl) NodeName() string

func (FunctionDecl) Pos

func (v FunctionDecl) Pos() lexer.Position

func (*FunctionDecl) SetPos

func (v *FunctionDecl) SetPos(pos lexer.Position)

func (FunctionDecl) String

func (v FunctionDecl) String() string

type FunctionType

type FunctionType struct {
	GenericParameters GenericSigil
	Parameters        []*TypeReference
	Return            *TypeReference
	IsVariadic        bool

	Receiver *TypeReference // non-nil if non-static method
	// contains filtered or unexported fields
}

FunctionType

func (FunctionType) ActualType

func (v FunctionType) ActualType() Type

func (FunctionType) Attrs

func (v FunctionType) Attrs() parser.AttrGroup

func (FunctionType) CanCastTo

func (v FunctionType) CanCastTo(t Type) bool

func (FunctionType) Equals

func (v FunctionType) Equals(t Type) bool

func (FunctionType) IsFloatingType

func (v FunctionType) IsFloatingType() bool

func (FunctionType) IsIntegerType

func (v FunctionType) IsIntegerType() bool

func (FunctionType) IsSigned

func (v FunctionType) IsSigned() bool

func (FunctionType) IsVoidType

func (v FunctionType) IsVoidType() bool

func (FunctionType) LevelsOfIndirection

func (v FunctionType) LevelsOfIndirection() int

func (FunctionType) String

func (v FunctionType) String() string

func (FunctionType) TypeName

func (v FunctionType) TypeName() string

type GenericContext

type GenericContext struct {
	Outer *GenericContext
	// contains filtered or unexported fields
}

GenericInstance Substition GenericContext to real type mappings override parameters to self mappings.

func NewGenericContext

func NewGenericContext(parameters GenericSigil, arguments []*TypeReference) *GenericContext

func NewGenericContextFromTypeReference

func NewGenericContextFromTypeReference(typref *TypeReference) *GenericContext

func (*GenericContext) Get

If the key is a substitution type and is not found in this generic instance, Get() checks GenericContext.Outer if not nil.

func (*GenericContext) GetSubstitutionType

func (v *GenericContext) GetSubstitutionType(t *SubstitutionType) *TypeReference

Like Get, but only gets value where key is substitution type. Returns nil if no value for key.

func (*GenericContext) Replace

func (v *GenericContext) Replace(t *TypeReference) *TypeReference

Replace goes through the *TypeReference and returns a new one with all the SubstitutionTypes that are mapped in this GenericContext.

type GenericSigil

type GenericSigil []*SubstitutionType

func (GenericSigil) String

func (v GenericSigil) String() string

type Ident

type Ident struct {
	Type   IdentType
	Value  interface{}
	Public bool
	Scope  *Scope
}

type IdentType

type IdentType int
const (
	IDENT_VARIABLE IdentType = iota
	IDENT_TYPE
	IDENT_FUNCTION
	IDENT_MODULE
)

func (IdentType) String

func (v IdentType) String() string

type IfStat

type IfStat struct {
	Exprs  []Expr
	Bodies []*Block
	Else   *Block // can be nil
	// contains filtered or unexported fields
}

func (IfStat) NodeName

func (_ IfStat) NodeName() string

func (IfStat) Pos

func (v IfStat) Pos() lexer.Position

func (*IfStat) SetPos

func (v *IfStat) SetPos(pos lexer.Position)

func (IfStat) String

func (v IfStat) String() string

type Inferrer

type Inferrer struct {
	Submodule         *Submodule
	Functions         []*Function
	Typeds            map[int]*AnnotatedTyped
	TypedLookup       map[Typed]*AnnotatedTyped
	SimpleConstraints []*Constraint
	Constraints       []*Constraint
	IdCount           int
}

func (*Inferrer) AddConstraint

func (v *Inferrer) AddConstraint(c *Constraint)

func (*Inferrer) AddEqualsConstraint

func (v *Inferrer) AddEqualsConstraint(a, b int)

AddEqualsConstraint creates a constraint that indicates that the two given ids are equal to one-another and add it to the list of constraints.

func (*Inferrer) AddIsConstraint

func (v *Inferrer) AddIsConstraint(id int, typref *TypeReference)

AddIsConstraint creates a constraing that indicates that the given id is of the given type and add it to the list of constraints.

func (*Inferrer) AddSimpleIsConstraint

func (v *Inferrer) AddSimpleIsConstraint(id int, typref *TypeReference)

AddSimpleIsConstraint creates and adds a constraint to the inferrer, where the type given is guaranteed not to contain a type variable.

func (*Inferrer) EnterScope

func (v *Inferrer) EnterScope()

func (*Inferrer) ExitScope

func (v *Inferrer) ExitScope()

func (*Inferrer) Finalize

func (v *Inferrer) Finalize()

Finalize runs the actual unification, sets default types in cases where these are needed, and sets the inferred types on the expressions.

func (*Inferrer) Function

func (v *Inferrer) Function() *Function

func (*Inferrer) GetDiscardingId

func (v *Inferrer) GetDiscardingId() int

func (*Inferrer) HandleExpr

func (v *Inferrer) HandleExpr(expr Expr) int

func (*Inferrer) HandleTyped

func (v *Inferrer) HandleTyped(pos lexer.Position, typed Typed) int

func (*Inferrer) PostVisit

func (v *Inferrer) PostVisit(node *Node)

func (*Inferrer) Solve

func (v *Inferrer) Solve() []*Constraint

Solve solves the constraints using the unification algorithm.

func (*Inferrer) SolveStep

func (v *Inferrer) SolveStep(stackIn []*Constraint, subsIn []*Constraint, addSubs bool, element *Constraint) (stack []*Constraint, substitutions []*Constraint)

func (*Inferrer) Visit

func (v *Inferrer) Visit(node *Node) bool

type InterfaceType

type InterfaceType struct {
	Functions         []*Function
	GenericParameters GenericSigil
	// contains filtered or unexported fields
}

func (InterfaceType) ActualType

func (v InterfaceType) ActualType() Type

func (InterfaceType) Attrs

func (v InterfaceType) Attrs() parser.AttrGroup

func (InterfaceType) CanCastTo

func (v InterfaceType) CanCastTo(t Type) bool

func (InterfaceType) Equals

func (v InterfaceType) Equals(t Type) bool

func (InterfaceType) GetFunction

func (v InterfaceType) GetFunction(name string) *Function

func (InterfaceType) IsFloatingType

func (v InterfaceType) IsFloatingType() bool

func (InterfaceType) IsIntegerType

func (v InterfaceType) IsIntegerType() bool

func (InterfaceType) IsSigned

func (v InterfaceType) IsSigned() bool

func (InterfaceType) IsVoidType

func (v InterfaceType) IsVoidType() bool

func (InterfaceType) LevelsOfIndirection

func (v InterfaceType) LevelsOfIndirection() int

func (InterfaceType) MatchesMethods

func (v InterfaceType) MatchesMethods(methods []*Function) bool

func (InterfaceType) MatchesType

func (v InterfaceType) MatchesType(t Type) bool

func (InterfaceType) String

func (v InterfaceType) String() string

func (InterfaceType) TypeName

func (v InterfaceType) TypeName() string

type LambdaExpr

type LambdaExpr struct {
	Function *Function
	// contains filtered or unexported fields
}

func (LambdaExpr) GetType

func (v LambdaExpr) GetType() *TypeReference

func (LambdaExpr) NodeName

func (v LambdaExpr) NodeName() string

func (LambdaExpr) Pos

func (v LambdaExpr) Pos() lexer.Position

func (*LambdaExpr) SetPos

func (v *LambdaExpr) SetPos(pos lexer.Position)

func (LambdaExpr) SetType

func (_ LambdaExpr) SetType(t *TypeReference)

func (LambdaExpr) String

func (v LambdaExpr) String() string

type Locatable

type Locatable interface {
	Pos() lexer.Position
	SetPos(pos lexer.Position)
}

type LoopStat

type LoopStat struct {
	LoopType LoopStatType

	Body *Block

	// LOOP_TYPE_CONDITIONAL
	Condition Expr
	// contains filtered or unexported fields
}

func (LoopStat) NodeName

func (_ LoopStat) NodeName() string

func (LoopStat) Pos

func (v LoopStat) Pos() lexer.Position

func (*LoopStat) SetPos

func (v *LoopStat) SetPos(pos lexer.Position)

func (LoopStat) String

func (v LoopStat) String() string

type LoopStatType

type LoopStatType int
const (
	LOOP_TYPE_UNSET LoopStatType = iota
	LOOP_TYPE_INFINITE
	LOOP_TYPE_CONDITIONAL
)

type MangleType

type MangleType int

In case we support multiple name mangling schemes

const (
	MANGLE_ARK_UNSTABLE MangleType = iota
)

type MatchStat

type MatchStat struct {
	Target Expr

	Branches map[Expr]Node
	// contains filtered or unexported fields
}

func (MatchStat) NodeName

func (_ MatchStat) NodeName() string

func (MatchStat) Pos

func (v MatchStat) Pos() lexer.Position

func (*MatchStat) SetPos

func (v *MatchStat) SetPos(pos lexer.Position)

func (MatchStat) String

func (v MatchStat) String() string

type Module

type Module struct {
	Name            *ModuleName
	ModScope        *Scope
	Dirpath         string
	Trees           []*parser.ParseTree
	Parts           map[string]*Submodule
	LinkedLibraries []string
	// contains filtered or unexported fields
}

func (Module) MangledName

func (v Module) MangledName(typ MangleType) string

type ModuleLookup

type ModuleLookup struct {
	Name     string
	Module   *Module
	Children map[string]*ModuleLookup
}

func NewModuleLookup

func NewModuleLookup(name string) *ModuleLookup

func (*ModuleLookup) Create

func (v *ModuleLookup) Create(name *ModuleName) *ModuleLookup

func (*ModuleLookup) Dump

func (v *ModuleLookup) Dump(i int)

func (*ModuleLookup) Get

func (v *ModuleLookup) Get(name *ModuleName) (*ModuleLookup, error)

type ModuleName

type ModuleName struct {
	Parts []string
}

func JoinModuleName

func JoinModuleName(modName *ModuleName, part string) *ModuleName

func ModuleNameFromUnresolvedName

func ModuleNameFromUnresolvedName(unresName UnresolvedName) *ModuleName

func NewModuleName

func NewModuleName(node *parser.NameNode) *ModuleName

func (*ModuleName) Last

func (v *ModuleName) Last() string

func (*ModuleName) String

func (v *ModuleName) String() string

func (*ModuleName) ToPath

func (v *ModuleName) ToPath() string

type NamedType

type NamedType struct {
	Name          string
	Type          Type
	ParentModule  *Module
	Methods       []*Function
	StaticMethods []*Function
}

func (*NamedType) ActualType

func (v *NamedType) ActualType() Type

func (*NamedType) Attrs

func (v *NamedType) Attrs() parser.AttrGroup

func (*NamedType) CanCastTo

func (v *NamedType) CanCastTo(t Type) bool

func (*NamedType) Equals

func (v *NamedType) Equals(t Type) bool

func (*NamedType) GetMethod

func (v *NamedType) GetMethod(name string) *Function

func (*NamedType) GetStaticMethod

func (v *NamedType) GetStaticMethod(name string) *Function

func (*NamedType) IsFloatingType

func (v *NamedType) IsFloatingType() bool

func (*NamedType) IsIntegerType

func (v *NamedType) IsIntegerType() bool

func (*NamedType) IsSigned

func (v *NamedType) IsSigned() bool

func (*NamedType) IsVoidType

func (v *NamedType) IsVoidType() bool

func (*NamedType) LevelsOfIndirection

func (v *NamedType) LevelsOfIndirection() int

func (*NamedType) String

func (v *NamedType) String() string

func (*NamedType) TypeName

func (v *NamedType) TypeName() string

type NextStat

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

func (NextStat) NodeName

func (_ NextStat) NodeName() string

func (NextStat) Pos

func (v NextStat) Pos() lexer.Position

func (*NextStat) SetPos

func (v *NextStat) SetPos(pos lexer.Position)

func (NextStat) String

func (v NextStat) String() string

type Node

type Node interface {
	String() string
	NodeName() string
	Locatable
}

type NodeSet

type NodeSet []*DependencyNode

type NumericLiteral

type NumericLiteral struct {
	IntValue   *big.Int
	FloatValue float64
	IsFloat    bool
	Type       *TypeReference
	// contains filtered or unexported fields
}

NumericLiteral

func (NumericLiteral) AsFloat

func (v NumericLiteral) AsFloat() float64

func (NumericLiteral) AsInt

func (v NumericLiteral) AsInt() uint64

func (NumericLiteral) GetType

func (v NumericLiteral) GetType() *TypeReference

func (NumericLiteral) NodeName

func (_ NumericLiteral) NodeName() string

func (NumericLiteral) Pos

func (v NumericLiteral) Pos() lexer.Position

func (*NumericLiteral) SetPos

func (v *NumericLiteral) SetPos(pos lexer.Position)

func (*NumericLiteral) SetType

func (v *NumericLiteral) SetType(t *TypeReference)

NumericLiteral

func (NumericLiteral) String

func (v NumericLiteral) String() string

type PointerToExpr

type PointerToExpr struct {
	IsMutable bool
	Access    Expr
	// contains filtered or unexported fields
}

func (PointerToExpr) GetType

func (v PointerToExpr) GetType() *TypeReference

func (PointerToExpr) NodeName

func (_ PointerToExpr) NodeName() string

func (PointerToExpr) Pos

func (v PointerToExpr) Pos() lexer.Position

func (*PointerToExpr) SetPos

func (v *PointerToExpr) SetPos(pos lexer.Position)

func (PointerToExpr) SetType

func (_ PointerToExpr) SetType(t *TypeReference)

func (PointerToExpr) String

func (v PointerToExpr) String() string

type PointerType

type PointerType struct {
	Addressee *TypeReference
	IsMutable bool
}

func PointerTo

func PointerTo(t *TypeReference, mutable bool) PointerType

IMPORTANT: Using this function is no longer important, just make sure to use .Equals() to compare two types.

func (PointerType) ActualType

func (v PointerType) ActualType() Type

func (PointerType) Attrs

func (v PointerType) Attrs() parser.AttrGroup

func (PointerType) CanCastTo

func (v PointerType) CanCastTo(t Type) bool

func (PointerType) Equals

func (v PointerType) Equals(t Type) bool

func (PointerType) IsFloatingType

func (v PointerType) IsFloatingType() bool

func (PointerType) IsIntegerType

func (v PointerType) IsIntegerType() bool

func (PointerType) IsSigned

func (v PointerType) IsSigned() bool

func (PointerType) IsVoidType

func (v PointerType) IsVoidType() bool

func (PointerType) LevelsOfIndirection

func (v PointerType) LevelsOfIndirection() int

func (PointerType) TypeName

func (v PointerType) TypeName() string

type PrimitiveType

type PrimitiveType int
const (
	PRIMITIVE_s8 PrimitiveType = iota
	PRIMITIVE_s16
	PRIMITIVE_s32
	PRIMITIVE_s64
	PRIMITIVE_s128

	PRIMITIVE_u8
	PRIMITIVE_u16
	PRIMITIVE_u32
	PRIMITIVE_u64
	PRIMITIVE_u128

	PRIMITIVE_f32
	PRIMITIVE_f64
	PRIMITIVE_f128

	PRIMITIVE_int
	PRIMITIVE_uint
	PRIMITIVE_uintptr

	PRIMITIVE_bool
	PRIMITIVE_void
)

func (PrimitiveType) ActualType

func (v PrimitiveType) ActualType() Type

func (PrimitiveType) Attrs

func (v PrimitiveType) Attrs() parser.AttrGroup

func (PrimitiveType) CanCastTo

func (v PrimitiveType) CanCastTo(t Type) bool

func (PrimitiveType) Equals

func (v PrimitiveType) Equals(t Type) bool

func (PrimitiveType) IsFloatingType

func (v PrimitiveType) IsFloatingType() bool

func (PrimitiveType) IsIntegerType

func (v PrimitiveType) IsIntegerType() bool

func (PrimitiveType) IsSigned

func (v PrimitiveType) IsSigned() bool

func (PrimitiveType) IsVoidType

func (v PrimitiveType) IsVoidType() bool

func (PrimitiveType) LevelsOfIndirection

func (v PrimitiveType) LevelsOfIndirection() int

func (PrimitiveType) String

func (i PrimitiveType) String() string

func (PrimitiveType) TypeName

func (v PrimitiveType) TypeName() string

type PublicHandler

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

func (PublicHandler) IsPublic

func (v PublicHandler) IsPublic() bool

func (*PublicHandler) SetPublic

func (v *PublicHandler) SetPublic(b bool)

type ReferenceToExpr

type ReferenceToExpr struct {
	IsMutable bool
	Access    Expr
	// contains filtered or unexported fields
}

func (ReferenceToExpr) GetType

func (v ReferenceToExpr) GetType() *TypeReference

func (ReferenceToExpr) NodeName

func (_ ReferenceToExpr) NodeName() string

func (ReferenceToExpr) Pos

func (v ReferenceToExpr) Pos() lexer.Position

func (*ReferenceToExpr) SetPos

func (v *ReferenceToExpr) SetPos(pos lexer.Position)

func (ReferenceToExpr) SetType

func (_ ReferenceToExpr) SetType(t *TypeReference)

func (ReferenceToExpr) String

func (v ReferenceToExpr) String() string

type ReferenceType

type ReferenceType struct {
	Referrer  *TypeReference // TODO rename to Element
	IsMutable bool
}

func ReferenceTo

func ReferenceTo(t *TypeReference, mutable bool) ReferenceType

func (ReferenceType) ActualType

func (v ReferenceType) ActualType() Type

func (ReferenceType) Attrs

func (v ReferenceType) Attrs() parser.AttrGroup

func (ReferenceType) CanCastTo

func (v ReferenceType) CanCastTo(t Type) bool

func (ReferenceType) Equals

func (v ReferenceType) Equals(t Type) bool

func (ReferenceType) IsFloatingType

func (v ReferenceType) IsFloatingType() bool

func (ReferenceType) IsIntegerType

func (v ReferenceType) IsIntegerType() bool

func (ReferenceType) IsSigned

func (v ReferenceType) IsSigned() bool

func (ReferenceType) IsVoidType

func (v ReferenceType) IsVoidType() bool

func (ReferenceType) LevelsOfIndirection

func (v ReferenceType) LevelsOfIndirection() int

func (ReferenceType) TypeName

func (v ReferenceType) TypeName() string

type Resolver

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

func (*Resolver) EnterScope

func (v *Resolver) EnterScope()

func (*Resolver) ExitScope

func (v *Resolver) ExitScope()

func (*Resolver) PostVisit

func (v *Resolver) PostVisit(node *Node)

func (*Resolver) ResolveDescent

func (v *Resolver) ResolveDescent()

func (*Resolver) ResolveNode

func (v *Resolver) ResolveNode(node *Node)

func (*Resolver) ResolveTopLevelDecls

func (v *Resolver) ResolveTopLevelDecls()

func (*Resolver) ResolveType

func (v *Resolver) ResolveType(src Locatable, t Type) Type

func (*Resolver) ResolveTypeReference

func (v *Resolver) ResolveTypeReference(src Locatable, t *TypeReference) *TypeReference

func (*Resolver) ResolveTypeReferences

func (v *Resolver) ResolveTypeReferences(src Locatable, ts []*TypeReference) []*TypeReference

func (*Resolver) ResolveTypes

func (v *Resolver) ResolveTypes(src Locatable, ts []Type) []Type

func (*Resolver) ResolveUsedModules

func (v *Resolver) ResolveUsedModules()

func (*Resolver) Visit

func (v *Resolver) Visit(n *Node) bool

type ReturnStat

type ReturnStat struct {
	Value Expr
	// contains filtered or unexported fields
}

func (ReturnStat) NodeName

func (_ ReturnStat) NodeName() string

func (ReturnStat) Pos

func (v ReturnStat) Pos() lexer.Position

func (*ReturnStat) SetPos

func (v *ReturnStat) SetPos(pos lexer.Position)

func (ReturnStat) String

func (v ReturnStat) String() string

type RuneLiteral

type RuneLiteral struct {
	Value rune
	// contains filtered or unexported fields
}

func (RuneLiteral) GetType

func (v RuneLiteral) GetType() *TypeReference

func (RuneLiteral) NodeName

func (_ RuneLiteral) NodeName() string

func (RuneLiteral) Pos

func (v RuneLiteral) Pos() lexer.Position

func (*RuneLiteral) SetPos

func (v *RuneLiteral) SetPos(pos lexer.Position)

func (RuneLiteral) SetType

func (_ RuneLiteral) SetType(t *TypeReference)

func (RuneLiteral) String

func (v RuneLiteral) String() string

type Scope

type Scope struct {
	Outer       *Scope
	Idents      map[string]*Ident
	Module      *Module   // module this scope belongs to, nil if builtin
	Function    *Function // function this scope is inside, nil if global/builtin/etc
	UsedModules map[string]*Module
}

func NewCScope

func NewCScope(mod *Module) *Scope

func NewGlobalScope

func NewGlobalScope(mod *Module) *Scope

func (*Scope) Dump

func (v *Scope) Dump(depth int)

func (*Scope) GetIdent

func (v *Scope) GetIdent(name UnresolvedName) *Ident

func (*Scope) InsertFunction

func (v *Scope) InsertFunction(t *Function, public bool) *Ident

func (*Scope) InsertIdent

func (v *Scope) InsertIdent(value interface{}, name string, typ IdentType, public bool) *Ident

func (*Scope) InsertType

func (v *Scope) InsertType(t Type, public bool) *Ident

func (*Scope) InsertVariable

func (v *Scope) InsertVariable(t *Variable, public bool) *Ident

func (*Scope) UseModule

func (v *Scope) UseModule(t *Module)

func (*Scope) UseModuleAs

func (v *Scope) UseModuleAs(t *Module, name string)

type Side

type Side struct {
	SideType SideType
	Id       int
	Type     *TypeReference
}

Side represents a single side of a constraint. It represents either a type (TypeSide) or a type variable (IdentSide)

func SideFromType

func SideFromType(t *TypeReference) Side

SideFromType creates a new Side from the given type. If the given type is a TypeVariable an IdentSide will be created, otherwise a TypeSide will be created.

func (Side) String

func (v Side) String() string

func (Side) Subs

func (v Side) Subs(id int, what Side) Side

Subs descends through the given Side, and replaces all occurenes of the given id with the contents of the Side `what`.

type SideType

type SideType int
const (
	IdentSide SideType = iota
	TypeSide
)

type SizeofExpr

type SizeofExpr struct {
	Expr Expr

	Type *TypeReference
	// contains filtered or unexported fields
}

func (SizeofExpr) GetType

func (v SizeofExpr) GetType() *TypeReference

func (SizeofExpr) NodeName

func (_ SizeofExpr) NodeName() string

func (SizeofExpr) Pos

func (v SizeofExpr) Pos() lexer.Position

func (*SizeofExpr) SetPos

func (v *SizeofExpr) SetPos(pos lexer.Position)

func (SizeofExpr) SetType

func (_ SizeofExpr) SetType(t *TypeReference)

func (SizeofExpr) String

func (v SizeofExpr) String() string

type Stat

type Stat interface {
	Node
	// contains filtered or unexported methods
}

type StringLiteral

type StringLiteral struct {
	Value     string
	IsCString bool
	Type      *TypeReference
	// contains filtered or unexported fields
}

func (StringLiteral) GetType

func (v StringLiteral) GetType() *TypeReference

func (StringLiteral) NodeName

func (_ StringLiteral) NodeName() string

func (StringLiteral) Pos

func (v StringLiteral) Pos() lexer.Position

func (*StringLiteral) SetPos

func (v *StringLiteral) SetPos(pos lexer.Position)

func (*StringLiteral) SetType

func (v *StringLiteral) SetType(t *TypeReference)

StringLiteral

func (StringLiteral) String

func (v StringLiteral) String() string

type StructAccessExpr

type StructAccessExpr struct {
	Struct AccessExpr
	Member string

	GenericArguments []*TypeReference // TODO check no gen args if variable, not function

	// Needed for when we convert an struct access to function access
	ParentFunction *Function
	// contains filtered or unexported fields
}

StructAccessExpr

func (StructAccessExpr) GetType

func (v StructAccessExpr) GetType() *TypeReference

func (StructAccessExpr) Mutable

func (v StructAccessExpr) Mutable() bool

func (StructAccessExpr) NodeName

func (_ StructAccessExpr) NodeName() string

func (StructAccessExpr) Pos

func (v StructAccessExpr) Pos() lexer.Position

func (*StructAccessExpr) SetPos

func (v *StructAccessExpr) SetPos(pos lexer.Position)

func (StructAccessExpr) SetType

func (_ StructAccessExpr) SetType(t *TypeReference)

func (StructAccessExpr) String

func (v StructAccessExpr) String() string

type StructMember

type StructMember struct {
	Name   string
	Public bool
	Type   *TypeReference
	// contains filtered or unexported fields
}

type StructType

type StructType struct {
	Module  *Module
	Members []*StructMember

	GenericParameters GenericSigil
	// contains filtered or unexported fields
}

func (StructType) ActualType

func (v StructType) ActualType() Type

func (StructType) Attrs

func (v StructType) Attrs() parser.AttrGroup

func (StructType) CanCastTo

func (v StructType) CanCastTo(t Type) bool

func (StructType) Equals

func (v StructType) Equals(t Type) bool

func (StructType) GetMember

func (v StructType) GetMember(name string) *StructMember

func (StructType) IsFloatingType

func (v StructType) IsFloatingType() bool

func (StructType) IsIntegerType

func (v StructType) IsIntegerType() bool

func (StructType) IsSigned

func (v StructType) IsSigned() bool

func (StructType) IsVoidType

func (v StructType) IsVoidType() bool

func (StructType) LevelsOfIndirection

func (v StructType) LevelsOfIndirection() int

func (StructType) MemberIndex

func (v StructType) MemberIndex(name string) int

func (StructType) String

func (v StructType) String() string

func (StructType) TypeName

func (v StructType) TypeName() string

type Submodule

type Submodule struct {
	Parent   *Module
	UseScope *Scope
	File     *lexer.Sourcefile
	Nodes    []Node
	// contains filtered or unexported fields
}

func (*Submodule) IterNodes

func (v *Submodule) IterNodes() chan Node

IterNodes allows for looping over all nodes using a for range loop

type SubstitutionType

type SubstitutionType struct {
	Name        string
	Constraints []*TypeReference // should be all interface type references
	// contains filtered or unexported fields
}

SubstitutionType

func NewSubstitutionType

func NewSubstitutionType(name string, constraints []*TypeReference) *SubstitutionType

func (*SubstitutionType) ActualType

func (v *SubstitutionType) ActualType() Type

func (*SubstitutionType) Attrs

func (v *SubstitutionType) Attrs() parser.AttrGroup

func (*SubstitutionType) CanCastTo

func (v *SubstitutionType) CanCastTo(t Type) bool

func (*SubstitutionType) Equals

func (v *SubstitutionType) Equals(t Type) bool

func (*SubstitutionType) IsFloatingType

func (v *SubstitutionType) IsFloatingType() bool

func (*SubstitutionType) IsIntegerType

func (v *SubstitutionType) IsIntegerType() bool

func (*SubstitutionType) IsSigned

func (v *SubstitutionType) IsSigned() bool

func (*SubstitutionType) IsVoidType

func (v *SubstitutionType) IsVoidType() bool

func (*SubstitutionType) LevelsOfIndirection

func (v *SubstitutionType) LevelsOfIndirection() int

func (*SubstitutionType) String

func (v *SubstitutionType) String() string

func (*SubstitutionType) TypeName

func (v *SubstitutionType) TypeName() string

type TupleLiteral

type TupleLiteral struct {
	Members           []Expr
	Type              *TypeReference
	ParentEnumLiteral *EnumLiteral // only non-nil if this part of an enum literal
	// contains filtered or unexported fields
}

func (TupleLiteral) GetType

func (v TupleLiteral) GetType() *TypeReference

func (TupleLiteral) NodeName

func (_ TupleLiteral) NodeName() string

func (TupleLiteral) Pos

func (v TupleLiteral) Pos() lexer.Position

func (*TupleLiteral) SetPos

func (v *TupleLiteral) SetPos(pos lexer.Position)

func (*TupleLiteral) SetType

func (v *TupleLiteral) SetType(t *TypeReference)

TupleLiteral

func (TupleLiteral) String

func (v TupleLiteral) String() string

type TupleType

type TupleType struct {
	Members []*TypeReference
}

func (TupleType) ActualType

func (v TupleType) ActualType() Type

func (TupleType) Attrs

func (v TupleType) Attrs() parser.AttrGroup

func (TupleType) CanCastTo

func (v TupleType) CanCastTo(t Type) bool

func (TupleType) Equals

func (v TupleType) Equals(t Type) bool

func (TupleType) IsFloatingType

func (v TupleType) IsFloatingType() bool

func (TupleType) IsIntegerType

func (v TupleType) IsIntegerType() bool

func (TupleType) IsSigned

func (v TupleType) IsSigned() bool

func (TupleType) IsVoidType

func (v TupleType) IsVoidType() bool

func (TupleType) LevelsOfIndirection

func (v TupleType) LevelsOfIndirection() int

func (TupleType) String

func (v TupleType) String() string

func (TupleType) TypeName

func (v TupleType) TypeName() string

type Type

type Type interface {
	TypeName() string
	LevelsOfIndirection() int // number of pointers you have to go through to get to the actual type
	IsIntegerType() bool      // true for all int types
	IsFloatingType() bool     // true for all floating-point types
	IsSigned() bool           // true for all signed integer types
	CanCastTo(Type) bool      // true if the receiver can be typecast to the parameter
	Attrs() parser.AttrGroup  // fetches the attributes associated with the type
	Equals(Type) bool         // compares whether two types are equal
	ActualType() Type         // returns the actual type disregarding named types
	IsVoidType() bool
}

func TypeWithoutPointers

func TypeWithoutPointers(t Type) Type

type TypeDecl

type TypeDecl struct {
	PublicHandler
	NamedType *NamedType
	// contains filtered or unexported fields
}

func (TypeDecl) DocComments

func (v TypeDecl) DocComments() []*parser.DocComment

func (TypeDecl) NodeName

func (_ TypeDecl) NodeName() string

func (TypeDecl) Pos

func (v TypeDecl) Pos() lexer.Position

func (*TypeDecl) SetPos

func (v *TypeDecl) SetPos(pos lexer.Position)

func (TypeDecl) String

func (v TypeDecl) String() string

type TypeReference

type TypeReference struct {
	BaseType         Type
	GenericArguments []*TypeReference
}

TODO fix up all the incorrect &TypeReference{...}

func AddChildren

func AddChildren(typ *TypeReference, dest []*TypeReference) []*TypeReference

AddChildren adds the children of a type to the passed list

func NewTypeReference

func NewTypeReference(typ Type, gargs []*TypeReference) *TypeReference

func SubsType

func SubsType(typ *TypeReference, id int, what *TypeReference) *TypeReference

SubsType descends through a type and replaces all occurences of the given type variable by `what`

func TypeReferenceWithoutPointers

func TypeReferenceWithoutPointers(t *TypeReference) *TypeReference

func (*TypeReference) ActualTypesEqual

func (v *TypeReference) ActualTypesEqual(t *TypeReference) bool

func (*TypeReference) CanCastTo

func (v *TypeReference) CanCastTo(t *TypeReference) bool

func (*TypeReference) Equals

func (v *TypeReference) Equals(t *TypeReference) bool

func (TypeReference) String

func (v TypeReference) String() string

type TypeVariable

type TypeVariable struct {
	Id int
	// contains filtered or unexported fields
}

TypeVariable is a type that abstracts the notion of a type variable such that we can use our existing types as part of constraints.

func (TypeVariable) ActualType

func (v TypeVariable) ActualType() Type

func (TypeVariable) Attrs

func (v TypeVariable) Attrs() parser.AttrGroup

func (TypeVariable) CanCastTo

func (v TypeVariable) CanCastTo(t Type) bool

func (TypeVariable) Equals

func (v TypeVariable) Equals(other Type) bool

func (TypeVariable) IsFloatingType

func (v TypeVariable) IsFloatingType() bool

func (TypeVariable) IsIntegerType

func (v TypeVariable) IsIntegerType() bool

func (TypeVariable) IsSigned

func (v TypeVariable) IsSigned() bool

func (TypeVariable) IsVoidType

func (v TypeVariable) IsVoidType() bool

func (TypeVariable) LevelsOfIndirection

func (v TypeVariable) LevelsOfIndirection() int

func (TypeVariable) String

func (v TypeVariable) String() string

func (TypeVariable) TypeName

func (v TypeVariable) TypeName() string

type Typed

type Typed interface {
	GetType() *TypeReference
	SetType(*TypeReference)
}

type UnaryExpr

type UnaryExpr struct {
	Expr Expr
	Op   parser.UnOpType
	Type *TypeReference
	// contains filtered or unexported fields
}

func (UnaryExpr) GetType

func (v UnaryExpr) GetType() *TypeReference

func (UnaryExpr) NodeName

func (_ UnaryExpr) NodeName() string

func (UnaryExpr) Pos

func (v UnaryExpr) Pos() lexer.Position

func (*UnaryExpr) SetPos

func (v *UnaryExpr) SetPos(pos lexer.Position)

func (*UnaryExpr) SetType

func (v *UnaryExpr) SetType(t *TypeReference)

UnaryExpr

func (UnaryExpr) String

func (v UnaryExpr) String() string

type UnresolvedName

type UnresolvedName struct {
	ModuleNames []string
	Name        string
}

func (UnresolvedName) Split

func (v UnresolvedName) Split() (UnresolvedName, string)

func (UnresolvedName) String

func (v UnresolvedName) String() string

type UnresolvedType

type UnresolvedType struct {
	Name UnresolvedName
	// contains filtered or unexported fields
}

UnresolvedType

func (UnresolvedType) ActualType

func (v UnresolvedType) ActualType() Type

func (UnresolvedType) Attrs

func (v UnresolvedType) Attrs() parser.AttrGroup

func (UnresolvedType) CanCastTo

func (v UnresolvedType) CanCastTo(t Type) bool

func (UnresolvedType) Equals

func (v UnresolvedType) Equals(t Type) bool

func (UnresolvedType) IsFloatingType

func (v UnresolvedType) IsFloatingType() bool

func (UnresolvedType) IsIntegerType

func (v UnresolvedType) IsIntegerType() bool

func (UnresolvedType) IsSigned

func (v UnresolvedType) IsSigned() bool

func (UnresolvedType) IsVoidType

func (v UnresolvedType) IsVoidType() bool

func (UnresolvedType) LevelsOfIndirection

func (v UnresolvedType) LevelsOfIndirection() int

func (UnresolvedType) String

func (v UnresolvedType) String() string

func (UnresolvedType) TypeName

func (v UnresolvedType) TypeName() string

type UseDirective

type UseDirective struct {
	ModuleName UnresolvedName
	// contains filtered or unexported fields
}

func (UseDirective) NodeName

func (_ UseDirective) NodeName() string

func (UseDirective) Pos

func (v UseDirective) Pos() lexer.Position

func (*UseDirective) SetPos

func (v *UseDirective) SetPos(pos lexer.Position)

func (UseDirective) String

func (v UseDirective) String() string

type Variable

type Variable struct {
	Type         *TypeReference
	Name         string
	Mutable      bool
	Attrs        parser.AttrGroup
	ParentStruct StructType
	ParentModule *Module

	// Is the variable not from an variable decl
	IsImplicit bool
}

func (Variable) GetType

func (v Variable) GetType() *TypeReference

func (Variable) MangledName

func (v Variable) MangledName(typ MangleType) string

func (*Variable) SetType

func (v *Variable) SetType(t *TypeReference)

Variable

func (Variable) String

func (v Variable) String() string

type VariableAccessExpr

type VariableAccessExpr struct {
	Name UnresolvedName

	Variable *Variable

	GenericArguments []*TypeReference // TODO check no gen args if variable, not function
	// contains filtered or unexported fields
}

VariableAccessExpr

func (VariableAccessExpr) GetType

func (v VariableAccessExpr) GetType() *TypeReference

func (VariableAccessExpr) Mutable

func (v VariableAccessExpr) Mutable() bool

func (VariableAccessExpr) NodeName

func (_ VariableAccessExpr) NodeName() string

func (VariableAccessExpr) Pos

func (v VariableAccessExpr) Pos() lexer.Position

func (*VariableAccessExpr) SetPos

func (v *VariableAccessExpr) SetPos(pos lexer.Position)

func (VariableAccessExpr) SetType

func (_ VariableAccessExpr) SetType(t *TypeReference)

func (VariableAccessExpr) String

func (v VariableAccessExpr) String() string

type VariableDecl

type VariableDecl struct {
	PublicHandler
	Variable   *Variable
	Assignment Expr
	// contains filtered or unexported fields
}

func (VariableDecl) DocComments

func (v VariableDecl) DocComments() []*parser.DocComment

func (VariableDecl) NodeName

func (_ VariableDecl) NodeName() string

func (VariableDecl) Pos

func (v VariableDecl) Pos() lexer.Position

func (*VariableDecl) SetPos

func (v *VariableDecl) SetPos(pos lexer.Position)

func (VariableDecl) String

func (v VariableDecl) String() string

type Visitor

type Visitor interface {
	EnterScope()
	ExitScope()

	Visit(*Node) bool
	PostVisit(*Node)
}

Jump to

Keyboard shortcuts

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