bytecode

package
v0.0.0-...-2c802aa Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package bytecode provides the bytecode structure and some utilities for convenient use of bytecodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BC

type BC struct {
	N    int // size
	Code []*instruction.Inst
}

BC represents a line of instructions.

func NewByteCode

func NewByteCode() *BC

NewByteCode returns a new BC.

func (*BC) AddCode

func (bc *BC) AddCode(bc2 BC, i int)

AddCode inserts the argument bytecode into BC. The argument integer i is the index where will insert into.

func (*BC) AddInst

func (bc *BC) AddInst(inst *instruction.Inst, i int)

AddInst adds the argument instruction to BC. The argument integer i is the index where will insert to.

func (BC) IndexOf

func (bc BC) IndexOf(sinst *instruction.Inst) int

IndexOf returns the position of argument instruction in BC. If can't find, then return -1.

func (*BC) Optimize

func (bc *BC) Optimize()

Optimize optimizes (or minimize) the bytecode.

func (*BC) PushCode

func (bc *BC) PushCode(bc2 BC)

PushCode inserts the argument bytecode into the top of BC.

func (*BC) PushInst

func (bc *BC) PushInst(inst *instruction.Inst)

PushInst adds the argument instruction to the top of BC.

func (BC) String

func (bc BC) String() string

Jump to

Keyboard shortcuts

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