ast

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSection

type DataSection struct {
	Name   string // 名字
	Offset uint32 // 偏移量(0 表示自动计算)
	Value  []byte // 初始化值
}

初始化数据

type ElemSection

type ElemSection struct {
	Name   string   // 名字
	Offset uint32   // 偏移量(从 0 开始)
	Values []string // 初始化值, 引用的是其他 func 的名字
}

表格元素数据

type ExportSpec

type ExportSpec struct {
	Name      string      // 导出名字
	Kind      token.Token // 导出类型
	FuncIdx   string      // 导出函数ID
	TableIdx  string      // 导出表格ID
	MemoryIdx string      // 导出内存ID
	GlobalIdx string      // 导出全局变量ID
}

导出对象

type Field

type Field struct {
	Name string      // 变量名字
	Type token.Token // 变量类型: I32, I64, F32, F64
}

参数和局部变量信息

type Func

type Func struct {
	Name       string    // 函数名
	ExportName string    // 导出名字
	Type       *FuncType // 函数类型
	Body       *FuncBody // 函数体
}

函数定义

type FuncBody

type FuncBody struct {
	Locals []Field       // 局部变量
	Insts  []Instruction // 指令列表
}

函数定义

type FuncType

type FuncType struct {
	Params  []Field       // 参数名字
	Results []token.Token // 返回值类型: I32, I64, F32, F64
}

函数类型

type Global

type Global struct {
	Name       string      // 全局变量名
	ExportName string      // 导出名字
	Mutable    bool        // 是否可写
	Type       token.Token // 类型信息
	I32Value   int32       // 初始值(导入变量忽略)
	I64Value   int64       // 初始值(导入变量忽略)
	F32Value   float32     // 初始值(导入变量忽略)
	F64Value   float64     // 初始值(导入变量忽略)
}

全局变量

type ImportSpec

type ImportSpec struct {
	ObjModule string      // 模块路径
	ObjName   string      // 实体名字
	ObjKind   token.Token // 导入类别: MEMORY, TABLE, FUNC, GLOBAL

	Memory     *Memory     // 导入内存
	TableName  string      // 导入Table编号
	GlobalName string      // 导入全局变量名字
	GlobalType token.Token // 导入全局变量类型: I32, I64, F32, F64
	FuncName   string      // 导入后函数名字
	FuncType   *FuncType   // 导入函数类型
}

导入对象(仅支持函数)

type Ins_Block

type Ins_Block struct {
	OpToken
	Label   string
	Results []token.Token // 返回值类型: I32, I64, F32, F64
	List    []Instruction
}

type Ins_Br

type Ins_Br struct {
	OpToken
	X string // todo: IdxOrLabel
}

type Ins_BrIf

type Ins_BrIf struct {
	OpToken
	X string
}

type Ins_BrTable

type Ins_BrTable struct {
	OpToken
	XList []string
}

type Ins_Call

type Ins_Call struct {
	OpToken
	X string
}

type Ins_CallIndirect

type Ins_CallIndirect struct {
	OpToken
	TableIdx string
	TypeIdx  string
}

type Ins_Drop

type Ins_Drop struct{ OpToken }

type Ins_Else

type Ins_Else struct{ OpToken }

type Ins_End

type Ins_End struct{ OpToken }

type Ins_F32Abs

type Ins_F32Abs struct{ OpToken }

type Ins_F32Add

type Ins_F32Add struct{ OpToken }

type Ins_F32Ceil

type Ins_F32Ceil struct{ OpToken }

type Ins_F32Const

type Ins_F32Const struct {
	OpToken
	X float32
}

type Ins_F32ConvertI32S

type Ins_F32ConvertI32S struct{ OpToken }

type Ins_F32ConvertI32U

type Ins_F32ConvertI32U struct{ OpToken }

type Ins_F32ConvertI64S

type Ins_F32ConvertI64S struct{ OpToken }

type Ins_F32ConvertI64U

type Ins_F32ConvertI64U struct{ OpToken }

type Ins_F32Copysign

type Ins_F32Copysign struct{ OpToken }

type Ins_F32DemoteF64

type Ins_F32DemoteF64 struct{ OpToken }

type Ins_F32Div

type Ins_F32Div struct{ OpToken }

type Ins_F32Eq

type Ins_F32Eq struct{ OpToken }

type Ins_F32Floor

type Ins_F32Floor struct{ OpToken }

type Ins_F32Ge

type Ins_F32Ge struct{ OpToken }

type Ins_F32Gt

type Ins_F32Gt struct{ OpToken }

type Ins_F32Le

type Ins_F32Le struct{ OpToken }

type Ins_F32Load

type Ins_F32Load struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_F32Lt

type Ins_F32Lt struct{ OpToken }

type Ins_F32Max

type Ins_F32Max struct{ OpToken }

type Ins_F32Min

type Ins_F32Min struct{ OpToken }

type Ins_F32Mul

type Ins_F32Mul struct{ OpToken }

type Ins_F32Ne

type Ins_F32Ne struct{ OpToken }

type Ins_F32Nearest

type Ins_F32Nearest struct{ OpToken }

type Ins_F32Neg

type Ins_F32Neg struct{ OpToken }

type Ins_F32ReintepretI32

type Ins_F32ReintepretI32 struct{ OpToken }

type Ins_F32Sqrt

type Ins_F32Sqrt struct{ OpToken }

type Ins_F32Store

type Ins_F32Store struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_F32Sub

type Ins_F32Sub struct{ OpToken }

type Ins_F32Trunc

type Ins_F32Trunc struct{ OpToken }

type Ins_F64Abs

type Ins_F64Abs struct{ OpToken }

type Ins_F64Add

type Ins_F64Add struct{ OpToken }

type Ins_F64Ceil

type Ins_F64Ceil struct{ OpToken }

type Ins_F64Const

type Ins_F64Const struct {
	OpToken
	X float64
}

type Ins_F64ConvertI32S

type Ins_F64ConvertI32S struct{ OpToken }

type Ins_F64ConvertI32U

type Ins_F64ConvertI32U struct{ OpToken }

type Ins_F64ConvertI64S

type Ins_F64ConvertI64S struct{ OpToken }

type Ins_F64ConvertI64U

type Ins_F64ConvertI64U struct{ OpToken }

type Ins_F64Copysign

type Ins_F64Copysign struct{ OpToken }

type Ins_F64Div

type Ins_F64Div struct{ OpToken }

type Ins_F64Eq

type Ins_F64Eq struct{ OpToken }

type Ins_F64Floor

type Ins_F64Floor struct{ OpToken }

type Ins_F64Ge

type Ins_F64Ge struct{ OpToken }

type Ins_F64Gt

type Ins_F64Gt struct{ OpToken }

type Ins_F64Le

type Ins_F64Le struct{ OpToken }

type Ins_F64Load

type Ins_F64Load struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_F64Lt

type Ins_F64Lt struct{ OpToken }

type Ins_F64Max

type Ins_F64Max struct{ OpToken }

type Ins_F64Min

type Ins_F64Min struct{ OpToken }

type Ins_F64Mul

type Ins_F64Mul struct{ OpToken }

type Ins_F64Ne

type Ins_F64Ne struct{ OpToken }

type Ins_F64Nearest

type Ins_F64Nearest struct{ OpToken }

type Ins_F64Neg

type Ins_F64Neg struct{ OpToken }

type Ins_F64PromoteF32

type Ins_F64PromoteF32 struct{ OpToken }

type Ins_F64ReintepretI64

type Ins_F64ReintepretI64 struct{ OpToken }

type Ins_F64Sqrt

type Ins_F64Sqrt struct{ OpToken }

type Ins_F64Store

type Ins_F64Store struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_F64Sub

type Ins_F64Sub struct{ OpToken }

type Ins_F64Trunc

type Ins_F64Trunc struct{ OpToken }

type Ins_GlobalGet

type Ins_GlobalGet struct {
	OpToken
	X string
}

type Ins_GlobalSet

type Ins_GlobalSet struct {
	OpToken
	X string
}

type Ins_I32Add

type Ins_I32Add struct{ OpToken }

type Ins_I32And

type Ins_I32And struct{ OpToken }

type Ins_I32Clz

type Ins_I32Clz struct{ OpToken }

type Ins_I32Const

type Ins_I32Const struct {
	OpToken
	X int32
}

type Ins_I32Ctz

type Ins_I32Ctz struct{ OpToken }

type Ins_I32DivS

type Ins_I32DivS struct{ OpToken }

type Ins_I32DivU

type Ins_I32DivU struct{ OpToken }

type Ins_I32Eq

type Ins_I32Eq struct{ OpToken }

type Ins_I32Eqz

type Ins_I32Eqz struct{ OpToken }

type Ins_I32GeS

type Ins_I32GeS struct{ OpToken }

type Ins_I32GeU

type Ins_I32GeU struct{ OpToken }

type Ins_I32GtS

type Ins_I32GtS struct{ OpToken }

type Ins_I32GtU

type Ins_I32GtU struct{ OpToken }

type Ins_I32LeS

type Ins_I32LeS struct{ OpToken }

type Ins_I32LeU

type Ins_I32LeU struct{ OpToken }

type Ins_I32Load

type Ins_I32Load struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I32Load16S

type Ins_I32Load16S struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I32Load16U

type Ins_I32Load16U struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I32Load8S

type Ins_I32Load8S struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I32Load8U

type Ins_I32Load8U struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I32LtS

type Ins_I32LtS struct{ OpToken }

type Ins_I32LtU

type Ins_I32LtU struct{ OpToken }

type Ins_I32Mul

type Ins_I32Mul struct{ OpToken }

type Ins_I32Ne

type Ins_I32Ne struct{ OpToken }

type Ins_I32Or

type Ins_I32Or struct{ OpToken }

type Ins_I32Popcnt

type Ins_I32Popcnt struct{ OpToken }

type Ins_I32ReintepretF32

type Ins_I32ReintepretF32 struct{ OpToken }

type Ins_I32RemS

type Ins_I32RemS struct{ OpToken }

type Ins_I32RemU

type Ins_I32RemU struct{ OpToken }

type Ins_I32Rotl

type Ins_I32Rotl struct{ OpToken }

type Ins_I32Rotr

type Ins_I32Rotr struct{ OpToken }

type Ins_I32Shl

type Ins_I32Shl struct{ OpToken }

type Ins_I32ShrS

type Ins_I32ShrS struct{ OpToken }

type Ins_I32ShrU

type Ins_I32ShrU struct{ OpToken }

type Ins_I32Store

type Ins_I32Store struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I32Store16

type Ins_I32Store16 struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I32Store8

type Ins_I32Store8 struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I32Sub

type Ins_I32Sub struct{ OpToken }

type Ins_I32TruncF32S

type Ins_I32TruncF32S struct{ OpToken }

type Ins_I32TruncF32U

type Ins_I32TruncF32U struct{ OpToken }

type Ins_I32TruncF64S

type Ins_I32TruncF64S struct{ OpToken }

type Ins_I32TruncF64U

type Ins_I32TruncF64U struct{ OpToken }

type Ins_I32WrapI64

type Ins_I32WrapI64 struct{ OpToken }

type Ins_I32Xor

type Ins_I32Xor struct{ OpToken }

type Ins_I64Add

type Ins_I64Add struct{ OpToken }

type Ins_I64And

type Ins_I64And struct{ OpToken }

type Ins_I64Clz

type Ins_I64Clz struct{ OpToken }

type Ins_I64Const

type Ins_I64Const struct {
	OpToken
	X int64
}

type Ins_I64Ctz

type Ins_I64Ctz struct{ OpToken }

type Ins_I64DivS

type Ins_I64DivS struct{ OpToken }

type Ins_I64DivU

type Ins_I64DivU struct{ OpToken }

type Ins_I64Eq

type Ins_I64Eq struct{ OpToken }

type Ins_I64Eqz

type Ins_I64Eqz struct{ OpToken }

type Ins_I64ExtendI32S

type Ins_I64ExtendI32S struct{ OpToken }

type Ins_I64ExtendI32U

type Ins_I64ExtendI32U struct{ OpToken }

type Ins_I64GeS

type Ins_I64GeS struct{ OpToken }

type Ins_I64GeU

type Ins_I64GeU struct{ OpToken }

type Ins_I64GtS

type Ins_I64GtS struct{ OpToken }

type Ins_I64GtU

type Ins_I64GtU struct{ OpToken }

type Ins_I64LeS

type Ins_I64LeS struct{ OpToken }

type Ins_I64LeU

type Ins_I64LeU struct{ OpToken }

type Ins_I64Load

type Ins_I64Load struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Load16S

type Ins_I64Load16S struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Load16U

type Ins_I64Load16U struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Load32S

type Ins_I64Load32S struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Load32U

type Ins_I64Load32U struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Load8S

type Ins_I64Load8S struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Load8U

type Ins_I64Load8U struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64LtS

type Ins_I64LtS struct{ OpToken }

type Ins_I64LtU

type Ins_I64LtU struct{ OpToken }

type Ins_I64Mul

type Ins_I64Mul struct{ OpToken }

type Ins_I64Ne

type Ins_I64Ne struct{ OpToken }

type Ins_I64Or

type Ins_I64Or struct{ OpToken }

type Ins_I64Popcnt

type Ins_I64Popcnt struct{ OpToken }

type Ins_I64ReintepretF64

type Ins_I64ReintepretF64 struct{ OpToken }

type Ins_I64RemS

type Ins_I64RemS struct{ OpToken }

type Ins_I64RemU

type Ins_I64RemU struct{ OpToken }

type Ins_I64Rotl

type Ins_I64Rotl struct{ OpToken }

type Ins_I64Rotr

type Ins_I64Rotr struct{ OpToken }

type Ins_I64Shl

type Ins_I64Shl struct{ OpToken }

type Ins_I64ShrS

type Ins_I64ShrS struct{ OpToken }

type Ins_I64ShrU

type Ins_I64ShrU struct{ OpToken }

type Ins_I64Store

type Ins_I64Store struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Store16

type Ins_I64Store16 struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Store32

type Ins_I64Store32 struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Store8

type Ins_I64Store8 struct {
	OpToken
	Align  uint
	Offset uint
}

type Ins_I64Sub

type Ins_I64Sub struct{ OpToken }

type Ins_I64TruncF32S

type Ins_I64TruncF32S struct{ OpToken }

type Ins_I64TruncF32U

type Ins_I64TruncF32U struct{ OpToken }

type Ins_I64TruncF64S

type Ins_I64TruncF64S struct{ OpToken }

type Ins_I64TruncF64U

type Ins_I64TruncF64U struct{ OpToken }

type Ins_I64Xor

type Ins_I64Xor struct{ OpToken }

type Ins_If

type Ins_If struct {
	OpToken
	Label   string
	Results []token.Token // 返回值类型: I32, I64, F32, F64
	Body    []Instruction
	Else    []Instruction
}

type Ins_LocalGet

type Ins_LocalGet struct {
	OpToken
	X string
}

type Ins_LocalSet

type Ins_LocalSet struct {
	OpToken
	X string
}

type Ins_LocalTee

type Ins_LocalTee struct {
	OpToken
	X string
}

type Ins_Loop

type Ins_Loop struct {
	OpToken
	Label   string
	Results []token.Token // 返回值类型: I32, I64, F32, F64
	List    []Instruction
}

type Ins_MemoryCopy added in v0.21.0

type Ins_MemoryCopy struct{ OpToken }

type Ins_MemoryFill added in v0.21.0

type Ins_MemoryFill struct{ OpToken }

type Ins_MemoryGrow

type Ins_MemoryGrow struct{ OpToken }

type Ins_MemoryInit added in v0.21.0

type Ins_MemoryInit struct {
	OpToken
	DataIdx int32
}

type Ins_MemorySize

type Ins_MemorySize struct{ OpToken }

type Ins_Nop

type Ins_Nop struct{ OpToken }

type Ins_Return

type Ins_Return struct{ OpToken }

type Ins_Select

type Ins_Select struct {
	OpToken
	ResultTyp string
}

type Ins_TableGet

type Ins_TableGet struct {
	OpToken
	TableIdx string
}

type Ins_TableSet

type Ins_TableSet struct {
	OpToken
	TableIdx string
}

type Ins_Unreachable

type Ins_Unreachable struct{ OpToken }

type Instruction

type Instruction interface {
	Token() token.Token
	// contains filtered or unexported methods
}

指令对应接口

type Memory

type Memory struct {
	Name     string // 内存对象的名字
	Pages    int    // 页数, 每页 64 KB
	MaxPages int    // 最大页数
}

内存信息

type Module

type Module struct {
	Name    string         // 模块的名字(可空)
	Types   []*TypeSection // 类型定义
	Imports []*ImportSpec  // 导入对象
	Exports []*ExportSpec  // 导出对象
	Memory  *Memory        // 内存对象, 包含 Data 信息(可空)
	Data    []*DataSection // 初始化数据, 可能重叠
	Table   *Table         // 表格对象, 包含 Elem 信息(可空)
	Elem    []*ElemSection // 初始化数据
	Globals []*Global      // 全局对象
	Funcs   []*Func        // 函数对象
	Start   string         // start 函数
}

Module 表示一个 WASM 模块。

func (*Module) String

func (m *Module) String() string

type OpToken

type OpToken token.Token

func (OpToken) String

func (tok OpToken) String() string

func (OpToken) Token

func (tok OpToken) Token() token.Token

func (OpToken) Valid

func (tok OpToken) Valid() bool

type Table

type Table struct {
	Name    string      // Table对象的名字
	Size    int         // 表格容量
	MaxSize int         // 最大容量
	Type    token.Token // 元素类型, 默认为 funcref, externref
}

Table 信息

type TypeSection

type TypeSection struct {
	Name string
	Type *FuncType
}

类型信息

Jump to

Keyboard shortcuts

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