compiler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package Compiler implements compilers that turn Elk source code into bytecode or Go source code

Index

Constants

View Source
const MainName = "<main>"

Variables

This section is empty.

Functions

This section is empty.

Types

type BytecodeCompiler

type BytecodeCompiler struct {
	Name string

	Errors *diagnostic.SyncDiagnosticList
	// contains filtered or unexported fields
}

Holds the state of the BytecodeCompiler.

func CreateBytecodeCompiler

func CreateBytecodeCompiler(parent *BytecodeCompiler, checker types.Checker, loc *position.Location, errors *diagnostic.SyncDiagnosticList) *BytecodeCompiler

func NewBytecodeCompiler

func NewBytecodeCompiler(name string, mode bytecodeCompilerMode, loc *position.Location, checker types.Checker) *BytecodeCompiler

Instantiate a NewBytecodeCompiler Compiler instance.

func (*BytecodeCompiler) Bytecode

func (c *BytecodeCompiler) Bytecode() *vm.BytecodeFunction

func (*BytecodeCompiler) CompileClassInheritance

func (c *BytecodeCompiler) CompileClassInheritance(class *types.Class, location *position.Location)

func (*BytecodeCompiler) CompileConstantDeclaration

func (c *BytecodeCompiler) CompileConstantDeclaration(node *ast.ConstantDeclarationNode, namespace types.Namespace, constName value.Symbol)

func (*BytecodeCompiler) CompileExpressionsInFile

func (c *BytecodeCompiler) CompileExpressionsInFile(node *ast.ProgramNode)

func (*BytecodeCompiler) CompileInclude

func (c *BytecodeCompiler) CompileInclude(target types.Namespace, mixin *types.Mixin, location *position.Location)

func (*BytecodeCompiler) CompileIvarIndices

func (c *BytecodeCompiler) CompileIvarIndices(target types.NamespaceWithIvarIndices, location *position.Location)

func (*BytecodeCompiler) CompileMacroBody

func (c *BytecodeCompiler) CompileMacroBody(node *ast.MacroDefinitionNode, name value.Symbol) *vm.BytecodeFunction

func (*BytecodeCompiler) CompileMethodBody

func (c *BytecodeCompiler) CompileMethodBody(node *ast.MethodDefinitionNode, name value.Symbol) Compiler

func (*BytecodeCompiler) CompileMethods

func (c *BytecodeCompiler) CompileMethods(location *position.Location, execOffset int)

func (*BytecodeCompiler) CreateMainCompiler

func (c *BytecodeCompiler) CreateMainCompiler(checker types.Checker, loc *position.Location, errors *diagnostic.SyncDiagnosticList, output io.Writer) Compiler

func (*BytecodeCompiler) EmitReturn

func (c *BytecodeCompiler) EmitReturn()

func (*BytecodeCompiler) FinishGlobalEnvCompiler

func (c *BytecodeCompiler) FinishGlobalEnvCompiler()

func (*BytecodeCompiler) FinishIvarIndicesCompiler

func (c *BytecodeCompiler) FinishIvarIndicesCompiler(location *position.Location, execOffset int) Compiler

func (*BytecodeCompiler) Flush

func (c *BytecodeCompiler) Flush()

func (*BytecodeCompiler) InitExpressionCompiler

func (c *BytecodeCompiler) InitExpressionCompiler(location *position.Location) Compiler

func (*BytecodeCompiler) InitGlobalEnv

func (c *BytecodeCompiler) InitGlobalEnv() Compiler

func (*BytecodeCompiler) InitIvarIndicesCompiler

func (c *BytecodeCompiler) InitIvarIndicesCompiler(location *position.Location) (Compiler, int)

func (*BytecodeCompiler) InitMainCompiler

func (c *BytecodeCompiler) InitMainCompiler()

func (*BytecodeCompiler) InitMethodCompiler

func (c *BytecodeCompiler) InitMethodCompiler(location *position.Location) (Compiler, int)

func (*BytecodeCompiler) Method

func (c *BytecodeCompiler) Method() value.Method

func (*BytecodeCompiler) Parent

func (c *BytecodeCompiler) Parent() Compiler

func (*BytecodeCompiler) SetParent

func (c *BytecodeCompiler) SetParent(parent Compiler)

type Compiler

type Compiler interface {
	Bytecode() *vm.BytecodeFunction
	Method() value.Method
	Parent() Compiler
	SetParent(Compiler)
	InitMainCompiler()
	InitGlobalEnv() Compiler
	FinishGlobalEnvCompiler()
	CreateMainCompiler(checker types.Checker, loc *position.Location, errors *diagnostic.SyncDiagnosticList, output io.Writer) Compiler
	CompileClassInheritance(*types.Class, *position.Location)
	CompileIvarIndices(target types.NamespaceWithIvarIndices, location *position.Location)
	CompileInclude(target types.Namespace, mixin *types.Mixin, location *position.Location)
	InitExpressionCompiler(location *position.Location) Compiler
	CompileExpressionsInFile(node *ast.ProgramNode)
	InitMethodCompiler(location *position.Location) (Compiler, int)
	CompileMethods(location *position.Location, execOffset int)
	InitIvarIndicesCompiler(location *position.Location) (Compiler, int)
	FinishIvarIndicesCompiler(location *position.Location, execOffset int) Compiler
	CompileConstantDeclaration(node *ast.ConstantDeclarationNode, namespace types.Namespace, constName value.Symbol)
	CompileMethodBody(node *ast.MethodDefinitionNode, name value.Symbol) Compiler
	Flush() // Outputs the compiled code to an output file
}

func CreateCompiler

func CreateCompiler(parent Compiler, checker types.Checker, loc *position.Location, errors *diagnostic.SyncDiagnosticList) Compiler

type GoCompiler

type GoCompiler struct {
	Errors   *diagnostic.SyncDiagnosticList
	FuncName string
	// contains filtered or unexported fields
}

Compiles Elk source code to Go source code.

func CreateGoCompiler

func CreateGoCompiler(parent *GoCompiler, checker types.Checker, loc *position.Location, errors *diagnostic.SyncDiagnosticList, output io.Writer) *GoCompiler

func NewGoCompiler

func NewGoCompiler(name string, mode goMode, loc *position.Location, checker types.Checker, bigIntCache *concurrent.Map[string, *nativeBigInt], symbolCache *concurrent.Map[string, *nativeSymbol], output io.Writer) *GoCompiler

func (*GoCompiler) Bytecode

func (c *GoCompiler) Bytecode() *vm.BytecodeFunction

func (*GoCompiler) CompileClassInheritance

func (c *GoCompiler) CompileClassInheritance(class *types.Class, location *position.Location)

func (*GoCompiler) CompileConstantDeclaration

func (c *GoCompiler) CompileConstantDeclaration(node *ast.ConstantDeclarationNode, namespace types.Namespace, constName value.Symbol)

func (*GoCompiler) CompileExpressionsInFile

func (c *GoCompiler) CompileExpressionsInFile(node *ast.ProgramNode)

func (*GoCompiler) CompileInclude

func (c *GoCompiler) CompileInclude(target types.Namespace, mixin *types.Mixin, location *position.Location)

func (*GoCompiler) CompileIvarIndices

func (c *GoCompiler) CompileIvarIndices(target types.NamespaceWithIvarIndices, location *position.Location)

func (*GoCompiler) CompileMethodBody

func (c *GoCompiler) CompileMethodBody(node *ast.MethodDefinitionNode, name value.Symbol) Compiler

func (*GoCompiler) CompileMethods

func (c *GoCompiler) CompileMethods(location *position.Location, execOffset int)

func (*GoCompiler) CreateMainCompiler

func (c *GoCompiler) CreateMainCompiler(checker types.Checker, loc *position.Location, errors *diagnostic.SyncDiagnosticList, output io.Writer) Compiler

func (*GoCompiler) FinishGlobalEnvCompiler

func (c *GoCompiler) FinishGlobalEnvCompiler()

func (*GoCompiler) FinishIvarIndicesCompiler

func (c *GoCompiler) FinishIvarIndicesCompiler(location *position.Location, execOffset int) Compiler

func (*GoCompiler) Flush

func (c *GoCompiler) Flush()

func (*GoCompiler) InitExpressionCompiler

func (c *GoCompiler) InitExpressionCompiler(location *position.Location) Compiler

func (*GoCompiler) InitGlobalEnv

func (c *GoCompiler) InitGlobalEnv() Compiler

func (*GoCompiler) InitIvarIndicesCompiler

func (c *GoCompiler) InitIvarIndicesCompiler(location *position.Location) (Compiler, int)

func (*GoCompiler) InitMainCompiler

func (c *GoCompiler) InitMainCompiler()

func (*GoCompiler) InitMethodCompiler

func (c *GoCompiler) InitMethodCompiler(location *position.Location) (Compiler, int)

func (*GoCompiler) Method

func (c *GoCompiler) Method() value.Method

func (*GoCompiler) Parent

func (c *GoCompiler) Parent() Compiler

func (*GoCompiler) SetParent

func (c *GoCompiler) SetParent(parent Compiler)

type GoSourceMethod

type GoSourceMethod GoCompiler

func (*GoSourceMethod) Class

func (*GoSourceMethod) Class() *value.Class

func (*GoSourceMethod) Copy

func (*GoSourceMethod) Copy() value.Reference

func (*GoSourceMethod) DirectClass

func (*GoSourceMethod) DirectClass() *value.Class

func (*GoSourceMethod) Error

func (*GoSourceMethod) Error() string

func (*GoSourceMethod) Inspect

func (*GoSourceMethod) Inspect() string

func (*GoSourceMethod) InstanceVariables

func (*GoSourceMethod) InstanceVariables() *value.InstanceVariables

func (*GoSourceMethod) Name

func (c *GoSourceMethod) Name() value.Symbol

func (*GoSourceMethod) OptionalParameterCount

func (*GoSourceMethod) OptionalParameterCount() int

func (*GoSourceMethod) ParameterCount

func (*GoSourceMethod) ParameterCount() int

func (*GoSourceMethod) SingletonClass

func (*GoSourceMethod) SingletonClass() *value.Class

Jump to

Keyboard shortcuts

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