1
1
mirror of https://github.com/wader/fq.git synced 2024-12-23 13:22:58 +03:00

wasm: make the godoc formatter happy

This commit is contained in:
@0xb17bea125 2022-08-22 21:30:49 +09:00
parent d5d9e738b6
commit e5cf1731e3
No known key found for this signature in database
GPG Key ID: 1A292BFDF101D448
3 changed files with 163 additions and 89 deletions

View File

@ -24,6 +24,8 @@ func decodeMemArg(d *decode.D, name string) {
})
}
// Decode expr.
//
// expr ::= (in:instr)* 0x0B => in* end
func decodeExpr(d *decode.D, name string) {
d.FieldArray(name, func(d *decode.D) {

View File

@ -20,6 +20,8 @@ var sectionIDToSym = scalar.UToSymStr{
sectionIDDataCount: "data_count_section",
}
// A map to convert valtypes to symbols.
//
// valtype ::= t:numtype => t
// | t:vectype => t
// | t:reftype => t
@ -43,6 +45,8 @@ var valtypeToSymMapper = scalar.UToSymStr{
0x6f: "externref",
}
// A map to convert tags of importdesc to symbols.
//
// importdesc ::= 0x00 x:typeidx => func x
// | 0x01 tt:tabletype => table tt
// | 0x02 mt:memtype => mem mt
@ -54,6 +58,8 @@ var importdescTagToSym = scalar.UToSymStr{
0x03: "global",
}
// A map to convert tags of exportdesc to symbols.
//
// exportdesc ::= 0x00 x:funcidx => func x
// | 0x01 x:tableidx => table x
// | 0x02 x:memidx => mem x
@ -65,6 +71,8 @@ var exportdescTagToSym = scalar.UToSymStr{
0x03: "globalidx",
}
// A map to convert reftypes to symbols.
//
// reftype ::= 0x70 => funcref
// | 0x6F => externref
var reftypeTagToSym = scalar.UToSymStr{
@ -72,6 +80,8 @@ var reftypeTagToSym = scalar.UToSymStr{
0x6f: "externref",
}
// A map to convert mut to symbols.
//
// mut ::= 0x00 => const
// | 0x01 => var
var mutToSym = scalar.UToSymStr{
@ -79,6 +89,8 @@ var mutToSym = scalar.UToSymStr{
0x01: "var",
}
// A map to convert elemkind to symbols.
//
// elemkind ::= 0x00 => funcref
var elemkindTagToSym = scalar.UToSymStr{
0x00: "funcref",

View File

@ -79,12 +79,16 @@ func decodeName(d *decode.D, name string) {
})
}
// Decode reftype.
//
// reftype ::= 0x70 => funcref
// | 0x6F => externref
func decodeRefType(d *decode.D, name string) {
d.FieldU8(name, reftypeTagToSym)
}
// Decode valtype.
//
// valtype ::= t:numtype => t
// | t:vectype => t
// | t:reftype => t
@ -93,6 +97,8 @@ func decodeValType(d *decode.D, name string) {
d.FieldU8(name, valtypeToSymMapper, scalar.ActualHex)
}
// Decode resulttype.
//
// resulttype ::= t*:vec(valtype) => [t*]
func decodeResultType(d *decode.D, name string) {
decodeVec(d, name, func(d *decode.D) {
@ -100,6 +106,8 @@ func decodeResultType(d *decode.D, name string) {
})
}
// Decode functype.
//
// functype ::= 0x60 rt1:resulttype rt2:resulttype => rt1 -> rt2
func decodeFuncType(d *decode.D, name string) {
d.FieldStruct(name, func(d *decode.D) {
@ -109,6 +117,8 @@ func decodeFuncType(d *decode.D, name string) {
})
}
// Decode limits.
//
// limits ::= 0x00 n:u32 => {min: n, max: ε}
// | 0x01 n:u32 m:u32 => {min: n, max: m}
func decodeLimits(d *decode.D, name string) {
@ -126,6 +136,8 @@ func decodeLimits(d *decode.D, name string) {
})
}
// Decode memtype.
//
// memtype ::= lim:limits => lim
func decodeMemType(d *decode.D, name string) {
d.FieldStruct(name, func(d *decode.D) {
@ -133,6 +145,8 @@ func decodeMemType(d *decode.D, name string) {
})
}
// Decode tabletype.
//
// tabletype ::= et:reftype lim:limits => lim et
func decodeTableType(d *decode.D, name string) {
d.FieldStruct(name, func(d *decode.D) {
@ -141,6 +155,8 @@ func decodeTableType(d *decode.D, name string) {
})
}
// Decode globaltype.
//
// globaltype ::= t:valtype m:mut => m t
// mut ::= 0x00 => const
// | 0x01 => var
@ -151,51 +167,71 @@ func decodeGlobalType(d *decode.D, name string) {
})
}
// Decode typeidx.
//
// typeidx ::= x:u32 => x
func decodeTypeIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode funcidx.
//
// funcidx ::= x:u32 => x
func decodeFuncIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode tableidx.
//
// tableidx ::= x:u32 => x
func decodeTableIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode memidx.
//
// memidx ::= x:u32 => x
func decodeMemIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode globalidx.
//
// globalidx ::= x:u32 => x
func decodeGlobalIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode elemidx.
//
// elemidx ::= x:u32 => x
func decodeElemIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode dataidx.
//
// dataidx ::= x:u32 => x
func decodeDataIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode localidx.
//
// localidx ::= x:u32 => x
func decodeLocalIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode labelidx.
//
// labelidx ::= l:u32 => l
func decodeLabelIdx(d *decode.D, name string) {
fieldU32(d, name)
}
// Decode custom section.
//
// customsec ::= section_0(custom)
// custom ::= name byte*
func decodeCustomSection(d *decode.D) {
@ -203,6 +239,8 @@ func decodeCustomSection(d *decode.D) {
d.FieldRawLen("bytes", d.BitsLeft())
}
// Decode type section.
//
// typesec ::= ft*:section_1(vec(functype)) => ft*
func decodeTypeSection(d *decode.D) {
decodeVec(d, "ft", func(d *decode.D) {
@ -210,6 +248,8 @@ func decodeTypeSection(d *decode.D) {
})
}
// Decode import section.
//
// importsec ::= im*:section_2(vec(import)) => im*
// import ::= mod:name nm:name d:importdesc => {module mod, name nm, desc d}
// importdesc ::= 0x00 x:typeidx => func x
@ -248,6 +288,8 @@ func decodeImportDesc(d *decode.D, name string) {
})
}
// Decode function section.
//
// funcsec ::= x*:section_3(vec(typeidx)) => x*
func decodeFunctionSection(d *decode.D) {
decodeVec(d, "x", func(d *decode.D) {
@ -255,6 +297,8 @@ func decodeFunctionSection(d *decode.D) {
})
}
// Decode table section.
//
// tablesec ::= tab*:section_4(vec(table)) => tab*
// table ::= tt:tabletype => {type tt}
func decodeTableSection(d *decode.D) {
@ -263,6 +307,8 @@ func decodeTableSection(d *decode.D) {
})
}
// Decode memory section.
//
// memsec ::= mem*:section_5(vec(mem)) => mem*
// mem ::= mt:memtype => {type mt}
func decodeMemorySection(d *decode.D) {
@ -271,6 +317,8 @@ func decodeMemorySection(d *decode.D) {
})
}
// Decode global section.
//
// globalsec ::= glob*:section_6(vec(global)) => glob*
// global ::= gt:globaltype e:expr => {type gt, init e}
func decodeGlobalSection(d *decode.D) {
@ -286,6 +334,8 @@ func decodeGlobal(d *decode.D, name string) {
})
}
// Decode export section.
//
// exportsec ::= ex*:section_7(vec(export)) => ex*
// export ::= nm:name d:exportdesc => {name nm, desc d}
// exportdesc ::= 0x00 x:funcidx => func x
@ -323,6 +373,8 @@ func decodeExportDesc(d *decode.D, name string) {
})
}
// Decode start section.
//
// startsec ::= st?:section_8(start) => st?
// start ::= x:funcidx => {func x}
func decodeStartSection(d *decode.D) {
@ -335,6 +387,8 @@ func decodeStart(d *decode.D, name string) {
})
}
// Decode element section.
//
// elemsec ::= seg*:section_9(vec(elem)) => seg*
// elem ::= 0:u32 e:expr y*:vec(funcidx) => {type funcref, init ((ref.func y) end)*, mode active {table 0, offset e}}
// | 1:u32 et:elemkind y*:vec(funcidx) => {type et, init ((ref.func y) end)*, mode passive}
@ -398,6 +452,8 @@ func decodeElemKind(d *decode.D, name string) {
d.FieldU8(name, d.AssertU(0x00), elemkindTagToSym)
}
// Decode code section.
//
// codesec ::= code*:section_10(vec(code)) => code*
// code ::= size:u32 code:func => code (if size = ||func||)
// func ::= (t*)*:vec(locals) e:expr => concat((t*)*),e (if |concat((t*)*)| < 2^32)
@ -433,6 +489,8 @@ func decodeLocals(d *decode.D, name string) {
})
}
// Decode data section.
//
// datasec ::= seg*:section_11(vec(data)) => seg*
// data ::= 0:u32 e:expr b*:vec(byte) => {init b*, mode active {memory 0, offset e}}
// | 1:u32 b*:vec(byte) => {init b*, mode passive}
@ -462,6 +520,8 @@ func decodeDataSegment(d *decode.D, name string) {
})
}
// Decode data count section.
//
// datacountsec ::= n?:section_12(u32) => n?
func decodeDataCountSection(d *decode.D) {
fieldU32(d, "n")