Documentation ¶
Index ¶
- Variables
- func DecodeSLEB128(stream *Stream) (s int64)
- func DecodeULEB128(stream *Stream) (u uint64)
- func EncodeSLEB128(v int64, stream *Stream) (out []byte)
- func EncodeULEB128(v uint64, stream *Stream) (out []byte)
- func Interface2Bytes(arr interface{}) (out []byte)
- func Json2Wasm(j []JSON) []byte
- func Lcfirst(str string) string
- func Ucfirst(str string) string
- type CodeBody
- type CodeSec
- type CustomSec
- type DataSec
- type DataSegment
- type ElementEntry
- type ElementSec
- type ExportEntry
- type ExportSec
- type FuncSec
- type Global
- type GlobalEntry
- type GlobalSec
- type ImportEntry
- type ImportSec
- type JSON
- type LocalEntry
- type MemLimits
- type MemSec
- type OP
- type SectionHeader
- type StartSec
- type Stream
- type Table
- type TableSec
- type TypeEntry
- type TypeSec
Constants ¶
This section is empty.
Variables ¶
View Source
var ( J2W_LANGUAGE_TYPES = map[string]byte{ "i32": 0x7f, "i64": 0x7e, "f32": 0x7d, "f64": 0x7c, "anyFunc": 0x70, "func": 0x60, "block_type": 0x40, } J2W_EXTERNAL_KIND = map[string]byte{ "function": 0, "table": 1, "memory": 2, "global": 3, } J2W_SECTION_IDS = map[string]byte{ "custom": 0, "type": 1, "import": 2, "function": 3, "table": 4, "memory": 5, "global": 6, "export": 7, "start": 8, "element": 9, "code": 10, "data": 11, } J2W_OPCODES = map[string]byte{}/* 172 elements not displayed */ )
View Source
var ( // https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#language-types // All types are distinguished by a negative varint7 values that is the first // byte of their encoding (representing a type constructor) W2J_LANGUAGE_TYPES = map[byte]string{ 0x7f: "i32", 0x7e: "i64", 0x7d: "f32", 0x7c: "f64", 0x70: "anyFunc", 0x60: "func", 0x40: "block_type", } // https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#external_kind // A single-byte unsigned integer indicating the kind of definition being imported or defined: W2J_EXTERNAL_KIND = map[byte]string{ 0x00: "function", 0x01: "table", 0x02: "memory", 0x03: "global", } W2J_OPCODES = map[byte]string{}/* 172 elements not displayed */ W2J_SECTION_IDS = map[byte]string{ 0: "custom", 1: "type", 2: "import", 3: "function", 4: "table", 5: "memory", 6: "global", 7: "export", 8: "start", 9: "element", 10: "code", 11: "data", } )
View Source
var OP_IMMEDIATES = map[string]string{
"block": "block_type",
"loop": "block_type",
"if": "block_type",
"br": "varuint32",
"br_if": "varuint32",
"br_table": "br_table",
"call": "varuint32",
"call_indirect": "call_indirect",
"get_local": "varuint32",
"set_local": "varuint32",
"tee_local": "varuint32",
"get_global": "varuint32",
"set_global": "varuint32",
"load": "memory_immediate",
"load8_s": "memory_immediate",
"load8_u": "memory_immediate",
"load16_s": "memory_immediate",
"load16_u": "memory_immediate",
"load32_s": "memory_immediate",
"load32_u": "memory_immediate",
"store": "memory_immediate",
"store8": "memory_immediate",
"store16": "memory_immediate",
"store32": "memory_immediate",
"current_memory": "varuint1",
"grow_memory": "varuint1",
"i32": "varint32",
"i64": "varint64",
"f32": "uint32",
"f64": "uint64",
}
Functions ¶
func DecodeSLEB128 ¶
DecodeSLEB128 decodes bytes from stream with signed LEB128 encoding.
func DecodeULEB128 ¶
DecodeULEB128 decodes bytes from stream with unsigned LEB128 encoding.
func EncodeSLEB128 ¶
EncodeSLEB128 appends v to b using signed LEB128 encoding.
func EncodeULEB128 ¶
EncodeULEB128 appends v to b using unsigned LEB128 encoding.
func Interface2Bytes ¶
func Interface2Bytes(arr interface{}) (out []byte)
Types ¶
type CodeBody ¶
type CodeBody struct { Locals []LocalEntry `json:"locals"` Code []OP `json:"code"` }
type CustomSec ¶
type CustomSec struct { Name string `json:"name,omitempty"` SectionName string `json:"section_name,omitempty"` Payload string `json:"payload,omitempty"` }
Section data structures.
type DataSec ¶
type DataSec struct { Name string `json:"name,omitempty"` Entries []DataSegment `json:"entries"` }
type DataSegment ¶
type ElementEntry ¶
type ElementSec ¶
type ElementSec struct { Name string `json:"name,omitempty"` Entries []ElementEntry `json:"entries"` }
type ExportEntry ¶
type ExportSec ¶
type ExportSec struct { Name string `json:"name,omitempty"` Entries []ExportEntry `json:"entries"` }
type GlobalEntry ¶
type GlobalSec ¶
type GlobalSec struct { Name string `json:"name,omitempty"` Entries []GlobalEntry `json:"entries"` }
type ImportEntry ¶
type ImportSec ¶
type ImportSec struct { Name string `json:"name,omitempty"` Entries []ImportEntry `json:"entries"` }
type LocalEntry ¶
type OP ¶
type SectionHeader ¶
type SectionHeader struct { Id byte `json:"id,omitempty"` Name string `json:"name,omitempty"` Size uint64 `json:"size,omitempty"` }
func ParseSectionHeader ¶
func ParseSectionHeader(stream *Stream) SectionHeader
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func GenerateOP ¶
func GeneratePreramble ¶
func GenerateSection ¶
Click to show internal directories.
Click to hide internal directories.