compiler

package
Version: v0.0.0-...-b9149cc Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOptimizer

func AddOptimizer(o Optimization)

Types

type Code

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

func NewCode

func NewCode(code []byte) *Code

func (*Code) NextInstruction

func (c *Code) NextInstruction() *Instruction

type CodeBlock

type CodeBlock struct {
	Name         string
	Filename     string
	LocalCount   int
	MaxStackSize int
	MaxBlockSize int
	Constants    []object.Object // Created at compile time
	Locals       []string        // Created by compile time
	Names        []string        // Created at compile time
	Code         []byte
	Native       bool
	ClassMethod  bool
	LineOffsets  []uint16
}

func Compile

func Compile(tree *ast.Program, name string) *CodeBlock

func (*CodeBlock) Dup

func (cb *CodeBlock) Dup() object.Object

func (*CodeBlock) Inspect

func (cb *CodeBlock) Inspect() string

func (*CodeBlock) Print

func (cb *CodeBlock) Print(indent string)

func (*CodeBlock) Type

func (cb *CodeBlock) Type() object.ObjectType

type InstSet

type InstSet struct {
	Head *Instruction
	Tail *Instruction
}

func NewInstSet

func NewInstSet() *InstSet

func (*InstSet) Assemble

func (i *InstSet) Assemble(ccb *codeBlockCompiler) ([]byte, []uint16)

func (*InstSet) Len

func (i *InstSet) Len() uint16
func (i *InstSet) Link()

type Instruction

type Instruction struct {
	Instr     opcode.Opcode
	Args      []uint16 // len = 1 or 2
	ArgLabels []string // len = 1 or 2, name of label for corresponding argument, prefix "~" means relative
	Label     string   // Label names this instruction for linking later
	Next      *Instruction
	Line      uint
}

func (*Instruction) Is

func (i *Instruction) Is(code opcode.Opcode) bool

func (*Instruction) IsLoad

func (i *Instruction) IsLoad() bool

func (*Instruction) Size

func (i *Instruction) Size() uint16

func (*Instruction) String

func (i *Instruction) String() string

type Optimization

type Optimization func(*InstSet, *codeBlockCompiler)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL