symbols

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: 5 Imported by: 0

README

ReCT Symbols

This package contains all of ReCTs symbols. These are things like type-symbols function-symbols and variable-symbols.
They are used by the Binder to string the syntax tree together into a concrete program, making sure that variables and functions being called exist, and that datatypes match up.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLambdaName

func GetLambdaName() string

func GetTempName

func GetTempName() string

Types

type ClassSymbol

type ClassSymbol struct {
	Symbol

	Exists bool

	Type   TypeSymbol
	IRType types.Type

	Package PackageSymbol

	Name        string
	Declaration nodes.ClassDeclarationMember
	Functions   []FunctionSymbol
	Fields      []VariableSymbol
}

func CreateClassSymbol

func CreateClassSymbol(name string, declration nodes.ClassDeclarationMember, functions []FunctionSymbol, fields []VariableSymbol, pck PackageSymbol) ClassSymbol

constructor

func (ClassSymbol) Fingerprint

func (s ClassSymbol) Fingerprint() string

func (ClassSymbol) Print

func (sym ClassSymbol) Print(indent string)

func (ClassSymbol) SymbolName

func (s ClassSymbol) SymbolName() string

func (ClassSymbol) SymbolType

func (ClassSymbol) SymbolType() SymbolType

implement the symbol interface

type EnumSymbol

type EnumSymbol struct {
	Symbol

	Exists bool

	Type TypeSymbol

	Name        string
	Declaration nodes.EnumDeclarationMember
	Fields      map[string]int
}

func CreateEnumSymbol

func CreateEnumSymbol(name string, declaration nodes.EnumDeclarationMember, fields map[string]int) EnumSymbol

constructor

func (EnumSymbol) Fingerprint

func (s EnumSymbol) Fingerprint() string

func (EnumSymbol) Print

func (sym EnumSymbol) Print(indent string)

func (EnumSymbol) SymbolName

func (s EnumSymbol) SymbolName() string

func (EnumSymbol) SymbolType

func (EnumSymbol) SymbolType() SymbolType

implement the symbol interface

type FunctionSymbol

type FunctionSymbol struct {
	Symbol

	Exists   bool
	BuiltIn  bool
	Public   bool
	External bool
	Variadic bool
	Adapted  bool

	IRFunction *ir.Func

	Name        string
	Parameters  []ParameterSymbol
	Type        TypeSymbol
	Declaration nodes.FunctionDeclarationMember
}

func CreateBuiltInFunctionSymbol

func CreateBuiltInFunctionSymbol(name string, params []ParameterSymbol, typeSymbol TypeSymbol, declaration nodes.FunctionDeclarationMember) FunctionSymbol

func CreateExternalFunctionSymbol

func CreateExternalFunctionSymbol(name string, declaration nodes.FunctionDeclarationMember, params []ParameterSymbol, typeSymbol TypeSymbol, variadic bool, adapted bool) FunctionSymbol

func CreateFunctionSymbol

func CreateFunctionSymbol(name string, params []ParameterSymbol, typeSymbol TypeSymbol, declaration nodes.FunctionDeclarationMember, public bool) FunctionSymbol

constructor

func (FunctionSymbol) Fingerprint

func (s FunctionSymbol) Fingerprint() string

func (FunctionSymbol) Print

func (sym FunctionSymbol) Print(indent string)

func (FunctionSymbol) SymbolName

func (s FunctionSymbol) SymbolName() string

func (FunctionSymbol) SymbolType

func (FunctionSymbol) SymbolType() SymbolType

implement the symbol interface

type GlobalVariableSymbol

type GlobalVariableSymbol struct {
	VariableSymbol

	Name     string
	ReadOnly bool
	Type     TypeSymbol
	UniqueID int
}

func CreateGlobalVariableSymbol

func CreateGlobalVariableSymbol(name string, readonly bool, typeSymbol TypeSymbol) GlobalVariableSymbol

constructor

func (GlobalVariableSymbol) Fingerprint

func (s GlobalVariableSymbol) Fingerprint() string

func (GlobalVariableSymbol) IsGlobal

func (GlobalVariableSymbol) IsGlobal() bool

implement the var interface

func (GlobalVariableSymbol) IsReadOnly

func (s GlobalVariableSymbol) IsReadOnly() bool

func (GlobalVariableSymbol) Print

func (sym GlobalVariableSymbol) Print(indent string)

func (GlobalVariableSymbol) SymbolName

func (s GlobalVariableSymbol) SymbolName() string

func (GlobalVariableSymbol) SymbolType

func (GlobalVariableSymbol) SymbolType() SymbolType

implement the symbol interface

func (GlobalVariableSymbol) VarType

func (s GlobalVariableSymbol) VarType() TypeSymbol

type LocalVariableSymbol

type LocalVariableSymbol struct {
	VariableSymbol

	Name     string
	ReadOnly bool
	Type     TypeSymbol
	UniqueID int
}

func CreateLocalVariableSymbol

func CreateLocalVariableSymbol(name string, readonly bool, typeSymbol TypeSymbol) LocalVariableSymbol

constructor

func (LocalVariableSymbol) Fingerprint

func (s LocalVariableSymbol) Fingerprint() string

func (LocalVariableSymbol) IsGlobal

func (LocalVariableSymbol) IsGlobal() bool

implement the var interface

func (LocalVariableSymbol) IsReadOnly

func (s LocalVariableSymbol) IsReadOnly() bool

func (LocalVariableSymbol) Print

func (sym LocalVariableSymbol) Print(indent string)

func (LocalVariableSymbol) SymbolName

func (s LocalVariableSymbol) SymbolName() string

func (LocalVariableSymbol) SymbolType

func (LocalVariableSymbol) SymbolType() SymbolType

implement the symbol interface

func (LocalVariableSymbol) VarType

func (s LocalVariableSymbol) VarType() TypeSymbol

type PackageSymbol

type PackageSymbol struct {
	Symbol

	Exists   bool
	IsAlias  bool
	Original *PackageSymbol

	Name      string
	Functions []FunctionSymbol
	Classes   []ClassSymbol

	Module        *ir.Module
	ErrorLocation print.TextSpan
}

func CreatePackageSymbol

func CreatePackageSymbol(name string, functions []FunctionSymbol, classes []ClassSymbol, module *ir.Module, errorLocation print.TextSpan) PackageSymbol

constructor

func (PackageSymbol) Fingerprint

func (s PackageSymbol) Fingerprint() string

func (PackageSymbol) Print

func (sym PackageSymbol) Print(indent string)

func (PackageSymbol) SymbolName

func (s PackageSymbol) SymbolName() string

func (PackageSymbol) SymbolType

func (PackageSymbol) SymbolType() SymbolType

implement the symbol interface

type ParameterSymbol

type ParameterSymbol struct {
	VariableSymbol

	Name     string
	Ordinal  int
	Type     TypeSymbol
	UniqueID int
}

func CreateParameterSymbol

func CreateParameterSymbol(name string, ordinal int, typeSymbol TypeSymbol) ParameterSymbol

constructor

func (ParameterSymbol) Fingerprint

func (s ParameterSymbol) Fingerprint() string

func (ParameterSymbol) IsGlobal

func (ParameterSymbol) IsGlobal() bool

implement the var interface

func (ParameterSymbol) IsReadOnly

func (s ParameterSymbol) IsReadOnly() bool

func (ParameterSymbol) Print

func (sym ParameterSymbol) Print(indent string)

func (ParameterSymbol) SymbolName

func (s ParameterSymbol) SymbolName() string

func (ParameterSymbol) SymbolType

func (ParameterSymbol) SymbolType() SymbolType

implement the symbol interface

func (ParameterSymbol) VarType

func (s ParameterSymbol) VarType() TypeSymbol

type StructSymbol

type StructSymbol struct {
	Symbol

	Exists bool

	Type   TypeSymbol
	IRType types.Type

	Name        string
	Declaration nodes.StructDeclarationMember
	Fields      []VariableSymbol
}

func CreateStructSymbol

func CreateStructSymbol(name string, declaration nodes.StructDeclarationMember, fields []VariableSymbol) StructSymbol

constructor

func (StructSymbol) Fingerprint

func (s StructSymbol) Fingerprint() string

func (StructSymbol) Print

func (sym StructSymbol) Print(indent string)

func (StructSymbol) SymbolName

func (s StructSymbol) SymbolName() string

func (StructSymbol) SymbolType

func (StructSymbol) SymbolType() SymbolType

implement the symbol interface

type Symbol

type Symbol interface {
	SymbolType() SymbolType
	SymbolName() string
	Print(indent string)
	Fingerprint() string
}

type SymbolType

type SymbolType string

types of symbols

const (
	Function       SymbolType = "FunctionSymbol"
	Class          SymbolType = "ClassSymbol"
	Struct         SymbolType = "StructSymbol"
	Enum           SymbolType = "EnumSymbol"
	GlobalVariable SymbolType = "GlobalVariableSymbol"
	LocalVariable  SymbolType = "LocalVariableSymbol"
	Parameter      SymbolType = "ParameterSymbol"
	Type           SymbolType = "TypeSymbol"
	Package        SymbolType = "PackageSymbol"
)

type TypeFunctionSymbol

type TypeFunctionSymbol struct {
	Symbol

	Exists  bool
	BuiltIn bool

	Name        string
	Parameters  []ParameterSymbol
	Type        TypeSymbol
	Declaration nodes.FunctionDeclarationMember
	OriginType  TypeSymbol // This is the data type of function access call like string->Split()
}

func CreateBuiltInTypeFunctionSymbol

func CreateBuiltInTypeFunctionSymbol(
	name string,
	params []ParameterSymbol,
	typeSymbol TypeSymbol,
	declaration nodes.FunctionDeclarationMember,
	origin TypeSymbol,
) TypeFunctionSymbol

func CreateTypeFunctionSymbol

func CreateTypeFunctionSymbol(
	name string,
	params []ParameterSymbol,
	typeSymbol TypeSymbol,
	declaration nodes.FunctionDeclarationMember,
	origin TypeSymbol,
) TypeFunctionSymbol

constructor

func (TypeFunctionSymbol) Fingerprint

func (sym TypeFunctionSymbol) Fingerprint() string

func (TypeFunctionSymbol) Print

func (sym TypeFunctionSymbol) Print(indent string)

func (TypeFunctionSymbol) SymbolName

func (sym TypeFunctionSymbol) SymbolName() string

func (TypeFunctionSymbol) SymbolType

func (TypeFunctionSymbol) SymbolType() SymbolType

implement the symbol interface

type TypeSymbol

type TypeSymbol struct {
	Symbol

	Name          string
	SubTypes      []TypeSymbol
	IsObject      bool
	IsUserDefined bool
	IsEnum        bool

	SourceSymbol Symbol
	Package      PackageSymbol
}

func CreateTypeSymbol

func CreateTypeSymbol(name string, subTypes []TypeSymbol, isObject bool, isUserDefined bool, isEnum bool, pck PackageSymbol, src Symbol) TypeSymbol

constructor

func (TypeSymbol) Fingerprint

func (sym TypeSymbol) Fingerprint() string

a unique identifier for each type

func (TypeSymbol) Print

func (sym TypeSymbol) Print(indent string)

func (TypeSymbol) SymbolName

func (s TypeSymbol) SymbolName() string

func (TypeSymbol) SymbolType

func (TypeSymbol) SymbolType() SymbolType

implement the interface

type VariableSymbol

type VariableSymbol interface {
	Symbol

	IsReadOnly() bool
	IsGlobal() bool
	VarType() TypeSymbol
	Declaration() print2.TextSpan
}

Jump to

Keyboard shortcuts

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