base

package
v0.0.0-...-0de04ed Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Branch

func Branch(frame *rtda.Frame, offset int)

Branch 指令跳转方法 获取当前线程的程序计数器 设置下一条指令的地址 基地址+offset

func InitClass

func InitClass(thread *rtda.Thread, class *heap.Class)

func InvokeMethod

func InvokeMethod(invokerFrame *rtda.Frame, method *heap.Method)

Types

type BranchInstruction

type BranchInstruction struct {
	Offset int
}

BranchInstruction 跳转指令 offset 代表指令偏移量

func (*BranchInstruction) FetchOperands

func (self *BranchInstruction) FetchOperands(reader *BytecodeReader)

type BytecodeReader

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

BytecodeReader 对Code属性里面的字节码内容进行进一步的定义,存放字节码进行字节码的解释执行 * code 用来存放字节码 pc 记录当前字节码索引

func (*BytecodeReader) PC

func (self *BytecodeReader) PC() int

func (*BytecodeReader) ReadInt16

func (self *BytecodeReader) ReadInt16() int16

func (*BytecodeReader) ReadInt32

func (self *BytecodeReader) ReadInt32() int32

func (*BytecodeReader) ReadInt32s

func (self *BytecodeReader) ReadInt32s(n int32) []int32

func (*BytecodeReader) ReadInt8

func (self *BytecodeReader) ReadInt8() int8

func (*BytecodeReader) ReadUint16

func (self *BytecodeReader) ReadUint16() uint16

func (*BytecodeReader) ReadUint8

func (self *BytecodeReader) ReadUint8() uint8

func (*BytecodeReader) Reset

func (self *BytecodeReader) Reset(code []byte, pc int)

Reset 重置BytecodeReader,放置每次创建新的BytecodeReader

func (*BytecodeReader) SkipPadding

func (self *BytecodeReader) SkipPadding()

type Index16Instruction

type Index16Instruction struct {
	Index uint
}

Index16Instruction * 有一些指令需要访问运行时常量池,常量池索引由两字节操 作数给出。把这类指令抽象成Index16Instruction结构体,用Index字 段表示常量池索引。

func (*Index16Instruction) FetchOperands

func (self *Index16Instruction) FetchOperands(reader *BytecodeReader)

type Index8Instruction

type Index8Instruction struct {
	Index uint
}

Index8Instruction * 存储和加载类指令需要根据索引存取局部变量表,索引由单字节操作数给出。 把这类指令抽象成Index8Instruction结构体, 用Index字段表示局部变量表索引。

func (*Index8Instruction) FetchOperands

func (self *Index8Instruction) FetchOperands(reader *BytecodeReader)

type Instruction

type Instruction interface {
	FetchOperands(reader *BytecodeReader)
	Execute(frame *rtda.Frame)
}

Instruction * 字节码指令的通用接口 包括两个方法: 1. FetchOperands : 从字节码中提取操作数 2. Execute : 执行字节码指令

type NoOperandsInstruction

type NoOperandsInstruction struct{}

NoOperandsInstruction 表示没有操作数的字节码指令,故其操作数获取方法为空

func (*NoOperandsInstruction) FetchOperands

func (self *NoOperandsInstruction) FetchOperands(reader *BytecodeReader)

Jump to

Keyboard shortcuts

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