ir

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RX = "$RX"
	RA = "$RA"
	RB = "$RB"

	RET  = "$RET"  // Function return value
	RETF = "$RETF" // Early return flag
	CALL = "$CALL"

	VarPath    = "vars"
	ArgPath    = "args"
	StructPath = "structs"

	MaxCallCounter = 65536
)
View Source
const (
	Set        = "set"        // `set <storage> <path> <value>`
	Copy       = "copy"       // `copy <storage from> <path from> <storage to> <path to>`
	Remove     = "remove"     // `remove <storage> <path>`
	Math       = "math"       // `math <operation>`
	Load       = "load"       // `load <path> <score>`
	Store      = "store"      // `store <score> <path>`
	Score      = "score"      // `score <target> <score>`
	AppendSet  = "appendSet"  // `appendSet <listPath> <value>`
	AppendCopy = "appendCopy" // `appendCopy <listPath> <valuePath>`
	Size       = "size"       // `size <source> <res>`
	Cmp        = "cmp"        // `cmp <score> <condition> <score>`
	If         = "if"         // `if <score> <instruction>`
	Unless     = "unless"     // `unless <score> <instruction>`
	Ret        = "ret"        // `ret`
	Func       = "func"       // `func <name>\n\t<code>`
	Call       = "call"       // `call <name>
	Branch     = "branch"     // `branch <name>`
	Raw        = "raw"        // `raw <command>`
	Trace      = "trace"      // `trace <storage> <path>`
)
View Source
const (
	TraceStorage = "storage"
	TraceScore   = "score"
)

Variables

This section is empty.

Functions

func NewCode

func NewCode(namespace, storage string) interfaces.IRCode

func NewFunction

func NewFunction(name string, code interfaces.IRCode) interfaces.Function

func OptimizeFunctionBody

func OptimizeFunctionBody(f interfaces.Function) interfaces.Function

Types

type Code

type Code struct {
	interfaces.IRCode

	Instructions []interfaces.Instruction
	Namespace    string
	// contains filtered or unexported fields
}

func (*Code) AddInstruction

func (c *Code) AddInstruction(inst interfaces.Instruction) interfaces.IRCode

func (*Code) AppendCopy

func (c *Code) AppendCopy(listPath, valuePath string) interfaces.IRCode

func (*Code) AppendSet

func (c *Code) AppendSet(listPath string, value nbt.Value) interfaces.IRCode

func (*Code) Branch

func (c *Code) Branch(branchName, funcName string) interfaces.IRCode

func (*Code) Call

func (c *Code) Call(funcName string) interfaces.IRCode

func (*Code) CallWithArgs added in v0.1.1

func (c *Code) CallWithArgs(funcName, argPath string) interfaces.IRCode

func (*Code) Copy

func (c *Code) Copy(from, to string) interfaces.IRCode

func (*Code) CopyArg

func (c *Code) CopyArg(varName, funcName, argName string) interfaces.IRCode

func (*Code) CopyVar

func (c *Code) CopyVar(from, to string) interfaces.IRCode

func (*Code) DoubleAcos

func (c *Code) DoubleAcos(x, to string) interfaces.IRCode

func (*Code) DoubleAdd

func (c *Code) DoubleAdd(x, y, to string) interfaces.IRCode

func (*Code) DoubleAsin

func (c *Code) DoubleAsin(x, to string) interfaces.IRCode

func (*Code) DoubleAtan

func (c *Code) DoubleAtan(x, to string) interfaces.IRCode

func (*Code) DoubleAtan2

func (c *Code) DoubleAtan2(x, y, to string) interfaces.IRCode

func (*Code) DoubleCeil

func (c *Code) DoubleCeil(x, to string) interfaces.IRCode

func (*Code) DoubleCompare

func (c *Code) DoubleCompare(regRa, regRb string, operator interfaces.TokenType, res string) interfaces.IRCode

func (*Code) DoubleCos

func (c *Code) DoubleCos(x, to string) interfaces.IRCode

func (*Code) DoubleDiv

func (c *Code) DoubleDiv(x, y, to string) interfaces.IRCode

func (*Code) DoubleFloor

func (c *Code) DoubleFloor(x, to string) interfaces.IRCode

func (*Code) DoubleMod

func (c *Code) DoubleMod(x, y, to string) interfaces.IRCode

func (*Code) DoubleMul

func (c *Code) DoubleMul(x, y, to string) interfaces.IRCode

func (*Code) DoubleRound

func (c *Code) DoubleRound(x, to string) interfaces.IRCode

func (*Code) DoubleSin

func (c *Code) DoubleSin(x, to string) interfaces.IRCode

func (*Code) DoubleSqrt

func (c *Code) DoubleSqrt(x, to string) interfaces.IRCode

func (*Code) DoubleSub

func (c *Code) DoubleSub(x, y, to string) interfaces.IRCode

func (*Code) DoubleTan

func (c *Code) DoubleTan(x, to string) interfaces.IRCode

func (*Code) ExceptionFormat added in v0.2.0

func (c *Code) ExceptionFormat(messageParts ...nbt.Value) interfaces.IRCode

func (*Code) ExceptionString added in v0.2.0

func (c *Code) ExceptionString(message string) interfaces.IRCode

func (*Code) Exec

func (c *Code) Exec(mcCommand string) interfaces.IRCode

func (*Code) ExecReg added in v0.2.0

func (c *Code) ExecReg(varName string) interfaces.IRCode

func (*Code) Extend

func (c *Code) Extend(code interfaces.IRCode) interfaces.IRCode

func (*Code) Func

func (c *Code) Func(name string) interfaces.IRCode

func (*Code) GetInstructions

func (c *Code) GetInstructions() []interfaces.Instruction

func (*Code) GetNamespace

func (c *Code) GetNamespace() string

func (*Code) GetStorage

func (c *Code) GetStorage() string

func (*Code) If

func (c *Code) If(condVar string, code interfaces.IRCode) interfaces.IRCode

func (*Code) IntAdd

func (c *Code) IntAdd(x, y, to string) interfaces.IRCode

func (*Code) IntCompare

func (c *Code) IntCompare(regRa, regRb string, operator interfaces.TokenType, res string) interfaces.IRCode

func (*Code) IntDiv

func (c *Code) IntDiv(x, y, to string) interfaces.IRCode

func (*Code) IntMod

func (c *Code) IntMod(x, y, to string) interfaces.IRCode

func (*Code) IntMul

func (c *Code) IntMul(x, y, to string) interfaces.IRCode

func (*Code) IntSub

func (c *Code) IntSub(x, y, to string) interfaces.IRCode

func (*Code) Len

func (c *Code) Len() int

func (*Code) Load

func (c *Code) Load(path, score string) interfaces.IRCode

func (*Code) MakeIndex

func (c *Code) MakeIndex(valuePath, res string) interfaces.IRCode

func (*Code) MathOp

func (c *Code) MathOp(operator string) interfaces.IRCode

func (*Code) PathDelete

func (c *Code) PathDelete(obj, path string) interfaces.IRCode

func (*Code) PathGet

func (c *Code) PathGet(obj, path, to string) interfaces.IRCode

func (*Code) PathSet

func (c *Code) PathSet(obj, path, valuePath string) interfaces.IRCode

func (*Code) Raw

func (c *Code) Raw(mcCommand string) interfaces.IRCode

func (*Code) Remove

func (c *Code) Remove(path string) interfaces.IRCode

func (*Code) RemoveArg

func (c *Code) RemoveArg(funcName, argName string) interfaces.IRCode

func (*Code) RemoveVar

func (c *Code) RemoveVar(name string) interfaces.IRCode

func (*Code) Ret

func (c *Code) Ret() interfaces.IRCode

func (*Code) Score

func (c *Code) Score(target string, score *nbt.Int) interfaces.IRCode

func (*Code) Set

func (c *Code) Set(path string, value nbt.Value) interfaces.IRCode

func (*Code) SetArg

func (c *Code) SetArg(funcName, argName string, value nbt.Value) interfaces.IRCode

func (*Code) SetArgs

func (c *Code) SetArgs(funcName string, value nbt.Compound) interfaces.IRCode

func (*Code) SetInstructions

func (c *Code) SetInstructions(instructions []interfaces.Instruction)

func (*Code) SetVar

func (c *Code) SetVar(name string, value nbt.Value) interfaces.IRCode

func (*Code) Size

func (c *Code) Size(source, res string) interfaces.IRCode

func (*Code) Store

func (c *Code) Store(score, path string) interfaces.IRCode

func (*Code) StringCompare

func (c *Code) StringCompare(a, b, res string) interfaces.IRCode

func (*Code) StringConcat

func (c *Code) StringConcat(a, b, res string) interfaces.IRCode

func (*Code) StringSlice

func (c *Code) StringSlice(stringVar, startIndex, endIndex, res string) interfaces.IRCode

func (*Code) StructGet

func (c *Code) StructGet(structPath, field, dataPath string) interfaces.IRCode

func (*Code) StructSet

func (c *Code) StructSet(dataPath, field, structPath string) interfaces.IRCode

func (*Code) ToMCCode

func (c *Code) ToMCCode() string

func (*Code) ToString

func (c *Code) ToString() string

func (*Code) Trace

func (c *Code) Trace(name, path string) interfaces.IRCode

func (*Code) TraceArg

func (c *Code) TraceArg(name, funcName, argName string) interfaces.IRCode

func (*Code) TraceScore

func (c *Code) TraceScore(name, score string) interfaces.IRCode

func (*Code) TraceVar

func (c *Code) TraceVar(name, varName string) interfaces.IRCode

func (*Code) Unless

func (c *Code) Unless(condVar string, code interfaces.IRCode) interfaces.IRCode

func (*Code) XCopy

func (c *Code) XCopy(storageFrom, from, storageTo, to string) interfaces.IRCode

func (*Code) XLoad

func (c *Code) XLoad(path, score string) interfaces.IRCode

func (*Code) XRemove

func (c *Code) XRemove(storage, path string) interfaces.IRCode

func (*Code) XSet

func (c *Code) XSet(storage, path string, value nbt.Value) interfaces.IRCode

func (*Code) XTrace

func (c *Code) XTrace(name, storage, path string) interfaces.IRCode

type Function

type Function struct {
	interfaces.Function
	Name string
	Code interfaces.IRCode
}

func (*Function) GetCode

func (f *Function) GetCode() interfaces.IRCode

func (*Function) GetName

func (f *Function) GetName() string

func (*Function) ToMCFunction

func (f *Function) ToMCFunction() string

func (*Function) ToString

func (f *Function) ToString() string

type Instruction

type Instruction struct {
	interfaces.Instruction

	Type        interfaces.InstructionType
	DPNamespace string
	Storage     string
	Args        []string
}

func (Instruction) GetArgs

func (i Instruction) GetArgs() []string

func (Instruction) GetType

func (Instruction) ToMCCommand

func (i Instruction) ToMCCommand() string

func (Instruction) ToString

func (i Instruction) ToString() string

type OptFunc

type OptFunc func(instrs []interfaces.Instruction, i int) (matched bool, consumed int, replacement []interfaces.Instruction)

Jump to

Keyboard shortcuts

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