binder

package
v0.0.0-...-169fbab Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoConversion       = CreateConvertion(false, false, false) // conversion impossible / not allowed
	IdentityConversion = CreateConvertion(true, true, true)    // no conversion needed
	ImplicitConversion = CreateConvertion(true, false, true)   // automatic conversion
	ExplicitConversion = CreateConvertion(true, false, false)  // conversion will need to be explicitly specified by the user
)

conversion types

View Source
var PackageUseList []symbols.PackageSymbol

Functions

func FailClassLookup

func FailClassLookup(name string, canFail bool, errorLocation print.TextSpan) (symbols.ClassSymbol, bool)

func FailPackageLookup

func FailPackageLookup(name string, canFail bool, errorLocation print.TextSpan) (symbols.PackageSymbol, bool)

func FailStructLookup

func FailStructLookup(name string, canFail bool, errorLocation print.TextSpan) (symbols.StructSymbol, bool)

func LookupClassInPackage

func LookupClassInPackage(name string, pack symbols.PackageSymbol, canFail bool, errorLocation print.TextSpan) (symbols.ClassSymbol, bool)

func LookupFunctionInPackage

func LookupFunctionInPackage(name string, pack symbols.PackageSymbol, canFail bool, errorLocation print.TextSpan) (symbols.FunctionSymbol, bool)

func LookupPrimitiveType

func LookupPrimitiveType(name string, canFail bool, errorLocation print.TextSpan) (symbols.TypeSymbol, bool)

Types

type Binder

type Binder struct {
	MemberScope    Scope
	Scopes         []Scope
	ActiveScope    *Scope
	FunctionSymbol symbols.FunctionSymbol
	ClassSymbol    symbols.ClassSymbol

	LabelCounter   int
	BreakLabels    []boundnodes.BoundLabel
	ContinueLabels []boundnodes.BoundLabel

	PreInitialTypeset []symbols.TypeSymbol
	InClass           bool
}

func CreateBinder

func CreateBinder(parent Scope, functionSymbol symbols.FunctionSymbol) *Binder

constructor

func (*Binder) BindArrayAccessExpression

func (bin *Binder) BindArrayAccessExpression(expr nodes.ArrayAccessExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindArrayAssignmentExpression

func (bin *Binder) BindArrayAssignmentExpression(expr nodes.ArrayAssignmentExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindBinaryExpression

func (bin *Binder) BindBinaryExpression(expr nodes.BinaryExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindBlockStatement

func (bin *Binder) BindBlockStatement(stmt nodes.BlockStatementNode) boundnodes.BoundBlockStatementNode

func (*Binder) BindBreakStatement

func (bin *Binder) BindBreakStatement(stmt nodes.BreakStatementNode) boundnodes.BoundStatementNode

func (*Binder) BindCallExpression

func (bin *Binder) BindCallExpression(expr nodes.CallExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindClassCallExpression

func (bin *Binder) BindClassCallExpression(expr nodes.TypeCallExpressionNode, baseExpression boundnodes.BoundExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindClassDeclaration

func (bin *Binder) BindClassDeclaration(mem nodes.ClassDeclarationMember, preInitialTypeset []symbols.TypeSymbol)

func (*Binder) BindClassFieldAccessExpression

func (bin *Binder) BindClassFieldAccessExpression(expr nodes.ClassFieldAccessExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindClassFieldAssignmentExpression

func (bin *Binder) BindClassFieldAssignmentExpression(expr nodes.ClassFieldAssignmentExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindContinueStatement

func (bin *Binder) BindContinueStatement(stmt nodes.ContinueStatementNode) boundnodes.BoundStatementNode

func (*Binder) BindConversion

func (bin *Binder) BindConversion(expr boundnodes.BoundExpressionNode, to symbols.TypeSymbol, allowExplicit bool, errorLocation print.TextSpan) boundnodes.BoundExpressionNode

func (*Binder) BindDereferenceExpression

func (bin *Binder) BindDereferenceExpression(expr nodes.DereferenceExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindElseClause

func (bin *Binder) BindElseClause(clause nodes.ElseClauseNode) boundnodes.BoundStatementNode

func (*Binder) BindEnumDeclaration

func (bin *Binder) BindEnumDeclaration(mem nodes.EnumDeclarationMember)

func (*Binder) BindExpression

func (bin *Binder) BindExpression(expr nodes.ExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindExpressionStatement

func (bin *Binder) BindExpressionStatement(stmt nodes.ExpressionStatementNode) boundnodes.BoundExpressionStatementNode

func (*Binder) BindExternalFunctionDeclaration

func (bin *Binder) BindExternalFunctionDeclaration(mem nodes.ExternalFunctionDeclarationMember, inClass bool)

func (*Binder) BindForStatement

func (bin *Binder) BindForStatement(stmt nodes.ForStatementNode) boundnodes.BoundStatementNode

func (*Binder) BindFromToStatement

func (bin *Binder) BindFromToStatement(stmt nodes.FromToStatementNode) boundnodes.BoundStatementNode

func (*Binder) BindFunctionDeclaration

func (bin *Binder) BindFunctionDeclaration(mem nodes.FunctionDeclarationMember, inClass bool)

func (*Binder) BindIfStatement

func (bin *Binder) BindIfStatement(stmt nodes.IfStatementNode) boundnodes.BoundIfStatementNode

func (*Binder) BindLambdaExpression

func (bin *Binder) BindLambdaExpression(expr nodes.LambdaExpressionNode) boundnodes.BoundLambdaExpressionNode

func (*Binder) BindLiteralExpression

func (bin *Binder) BindLiteralExpression(expr nodes.LiteralExpressionNode) boundnodes.BoundLiteralExpressionNode

func (*Binder) BindMakeArrayExpression

func (bin *Binder) BindMakeArrayExpression(expr nodes.MakeArrayExpressionNode) boundnodes.BoundMakeArrayExpressionNode

func (*Binder) BindMakeExpression

func (bin *Binder) BindMakeExpression(expr nodes.MakeExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindMakeStructExpression

func (bin *Binder) BindMakeStructExpression(expr nodes.MakeStructExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindNameExpression

func (bin *Binder) BindNameExpression(expr nodes.NameExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindPackageAlias

func (bin *Binder) BindPackageAlias(mem nodes.PackageAliasMember)

func (*Binder) BindPackageCallExpression

func (bin *Binder) BindPackageCallExpression(expr nodes.PackageCallExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindPackageReference

func (bin *Binder) BindPackageReference(mem nodes.PackageReferenceMember)

func (*Binder) BindPackageUse

func (bin *Binder) BindPackageUse(mem nodes.PackageUseMember)

func (*Binder) BindParenthesisedExpression

func (bin *Binder) BindParenthesisedExpression(expr nodes.ParenthesisedExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindReferenceExpression

func (bin *Binder) BindReferenceExpression(expr nodes.ReferenceExpressionNode) boundnodes.BoundReferenceExpressionNode

func (*Binder) BindReturnStatement

func (bin *Binder) BindReturnStatement(stmt nodes.ReturnStatementNode) boundnodes.BoundStatementNode

func (*Binder) BindStatement

func (bin *Binder) BindStatement(stmt nodes.StatementNode) boundnodes.BoundStatementNode

</MEMBERS> ---------------------------------------------------------------- <STATEMENTS> ---------------------------------------------------------------

func (*Binder) BindStatementInternal

func (bin *Binder) BindStatementInternal(stmt nodes.StatementNode) boundnodes.BoundStatementNode

func (*Binder) BindStructDeclaration

func (bin *Binder) BindStructDeclaration(mem nodes.StructDeclarationMember, preInitialTypeset []symbols.TypeSymbol)

func (*Binder) BindTernaryExpression

func (bin *Binder) BindTernaryExpression(expr nodes.TernaryExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindThisExpression

func (bin *Binder) BindThisExpression(expr nodes.ThisExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindTypeCallExpression

func (bin *Binder) BindTypeCallExpression(expr nodes.TypeCallExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindTypeClause

func (bin *Binder) BindTypeClause(tc nodes.TypeClauseNode) (symbols.TypeSymbol, bool)

func (*Binder) BindUnaryExpression

func (bin *Binder) BindUnaryExpression(expr nodes.UnaryExpressionNode) boundnodes.BoundExpressionNode

func (*Binder) BindVariableCreation

func (bin *Binder) BindVariableCreation(id lexer.Token, isReadOnly bool, isGlobal bool, varType symbols.TypeSymbol) symbols.VariableSymbol

func (*Binder) BindVariableDeclaration

func (bin *Binder) BindVariableDeclaration(stmt nodes.VariableDeclarationStatementNode) boundnodes.BoundStatementNode

func (*Binder) BindVariableReference

func (bin *Binder) BindVariableReference(name string, errorLocation print.TextSpan, inMain bool) symbols.VariableSymbol

func (*Binder) BindWhileStatement

func (bin *Binder) BindWhileStatement(stmt nodes.WhileStatementNode) boundnodes.BoundWhileStatementNode

func (*Binder) GetLabels

func (bin *Binder) GetLabels() (boundnodes.BoundLabel, boundnodes.BoundLabel)

func (Binder) LookupClass

func (bin Binder) LookupClass(name string, canFail bool, errorLocaton print.TextSpan) (symbols.ClassSymbol, bool)

func (*Binder) LookupClassField

func (bin *Binder) LookupClassField(name string, baseType symbols.TypeSymbol, errorLocation print.TextSpan) symbols.VariableSymbol

func (*Binder) LookupClassFunction

func (bin *Binder) LookupClassFunction(name string, baseType symbols.TypeSymbol, errorLocation print.TextSpan) symbols.FunctionSymbol

func (Binder) LookupEnum

func (bin Binder) LookupEnum(name string) (symbols.EnumSymbol, bool)

func (Binder) LookupPackage

func (bin Binder) LookupPackage(name string, canFail bool, errorLocaton print.TextSpan) (symbols.PackageSymbol, bool)

func (Binder) LookupStruct

func (bin Binder) LookupStruct(name string, canFail bool, errorLocaton print.TextSpan) (symbols.StructSymbol, bool)

func (*Binder) LookupStructField

func (bin *Binder) LookupStructField(name string, baseType symbols.TypeSymbol, errorLocation print.TextSpan) symbols.VariableSymbol

func (Binder) LookupType

func (bin Binder) LookupType(typeClause nodes.TypeClauseNode, canFail bool) (symbols.TypeSymbol, bool)

func (*Binder) LookupTypeFunction

func (bin *Binder) LookupTypeFunction(name string, baseType symbols.TypeSymbol, errorLocation print.TextSpan) symbols.TypeFunctionSymbol

func (*Binder) PopLabels

func (bin *Binder) PopLabels()

func (*Binder) PopScope

func (bin *Binder) PopScope()

func (*Binder) PushLabels

func (bin *Binder) PushLabels(breakLabel boundnodes.BoundLabel, continueLabel boundnodes.BoundLabel)

helpers for the label stacks

func (*Binder) PushScope

func (bin *Binder) PushScope(s Scope)

helpers for the scope list

type BoundClass

type BoundClass struct {
	Symbol    symbols.ClassSymbol
	Functions []BoundFunction
}

type BoundFunction

type BoundFunction struct {
	Symbol symbols.FunctionSymbol
	Body   boundnodes.BoundBlockStatementNode
}

type BoundProgram

type BoundProgram struct {
	GlobalScope       *GlobalScope
	MainFunction      symbols.FunctionSymbol
	Functions         []BoundFunction
	ExternalFunctions []symbols.FunctionSymbol
	Classes           []BoundClass
	Structs           []symbols.StructSymbol
	Packages          []symbols.PackageSymbol
}

func BindProgram

func BindProgram(members []nodes.MemberNode) BoundProgram

func (*BoundProgram) Print

func (b *BoundProgram) Print()

func (*BoundProgram) PrintStatements

func (b *BoundProgram) PrintStatements()

type Conversion

type Conversion struct {
	Exists     bool
	IsIdentity bool
	IsImplicit bool
	IsExplicit bool
}

func ClassifyConversion

func ClassifyConversion(from symbols.TypeSymbol, to symbols.TypeSymbol) Conversion

func CreateConvertion

func CreateConvertion(exists bool, isIdentity bool, isImplicit bool) Conversion

constructor

type GlobalScope

type GlobalScope struct {
	MainFunction symbols.FunctionSymbol

	Functions  []symbols.FunctionSymbol
	Variables  []symbols.VariableSymbol
	Classes    []symbols.ClassSymbol
	Structs    []symbols.StructSymbol
	Packages   []symbols.PackageSymbol
	Statements []boundnodes.BoundStatementNode
}

func BindGlobalScope

func BindGlobalScope(members []nodes.MemberNode) GlobalScope

func (GlobalScope) Print

func (g GlobalScope) Print()

type Scope

type Scope struct {
	Parent  *Scope
	Symbols map[string]symbols.Symbol
}
var MainScope Scope

func BindParentScope

func BindParentScope(globalScope GlobalScope) Scope

func BindRootScope

func BindRootScope() Scope

func CreateScope

func CreateScope(parent *Scope) Scope

constructor

func (Scope) GetAllClasses

func (s Scope) GetAllClasses() []symbols.ClassSymbol

func (Scope) GetAllFunctions

func (s Scope) GetAllFunctions() []symbols.FunctionSymbol

func (Scope) GetAllPackages

func (s Scope) GetAllPackages() []symbols.PackageSymbol

func (Scope) GetAllStructs

func (s Scope) GetAllStructs() []symbols.StructSymbol

func (Scope) GetAllVariables

func (s Scope) GetAllVariables() []symbols.VariableSymbol

func (Scope) InsertFunctionSymbols

func (s Scope) InsertFunctionSymbols(symbols []symbols.FunctionSymbol)

func (Scope) InsertVariableSymbols

func (s Scope) InsertVariableSymbols(symbols []symbols.VariableSymbol)

func (*Scope) TryDeclareSymbol

func (s *Scope) TryDeclareSymbol(sym symbols.Symbol) bool

func (Scope) TryLookupSymbol

func (s Scope) TryLookupSymbol(name string) symbols.Symbol

Jump to

Keyboard shortcuts

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