feat: refactoring project
This commit is contained in:
271
node_modules/@webassemblyjs/wasm-parser/esm/decoder.js
generated
vendored
271
node_modules/@webassemblyjs/wasm-parser/esm/decoder.js
generated
vendored
@@ -345,7 +345,13 @@ export function decode(ab, opts) {
|
||||
if (type == constants.types.func) {
|
||||
dump([type], "func");
|
||||
var paramValtypes = parseVec(function (b) {
|
||||
return constants.valtypes[b];
|
||||
var valtype = constants.valtypes[b];
|
||||
|
||||
if (valtype === undefined) {
|
||||
throw new Error("unexpected value type ".concat(b));
|
||||
}
|
||||
|
||||
return valtype;
|
||||
});
|
||||
var params = paramValtypes.map(function (v) {
|
||||
return t.funcParam(
|
||||
@@ -574,10 +580,7 @@ export function decode(ab, opts) {
|
||||
var bodySizeU32 = readU32();
|
||||
eatBytes(bodySizeU32.nextIndex);
|
||||
dump([bodySizeU32.value], "function body size");
|
||||
var code = [];
|
||||
/**
|
||||
* Parse locals
|
||||
*/
|
||||
var code = []; // Parse locals
|
||||
|
||||
var funcLocalNumU32 = readU32();
|
||||
var funcLocalNum = funcLocalNumU32.value;
|
||||
@@ -639,6 +642,13 @@ export function decode(ab, opts) {
|
||||
if (instructionByte === 0xfe) {
|
||||
instructionByte = 0xfe00 + readByte();
|
||||
eatBytes(1);
|
||||
} // Table instructions
|
||||
// https://webassembly.github.io/spec/core/binary/instructions.html#table-instructions
|
||||
|
||||
|
||||
if (instructionByte === 0xfc) {
|
||||
instructionByte = 0xfc00 + readByte();
|
||||
eatBytes(1);
|
||||
}
|
||||
|
||||
var instruction = constants.symbolsByByte[instructionByte];
|
||||
@@ -647,6 +657,10 @@ export function decode(ab, opts) {
|
||||
throw new CompileError("Unexpected instruction: " + toHex(instructionByte));
|
||||
}
|
||||
|
||||
if (instruction === "illegal") {
|
||||
throw new Error("tried to decode an illegal bytecode: ".concat(toHex(instructionByte)));
|
||||
}
|
||||
|
||||
if (typeof instruction.object === "string") {
|
||||
dump([instructionByte], "".concat(instruction.object, ".").concat(instruction.name));
|
||||
} else {
|
||||
@@ -673,15 +687,7 @@ export function decode(ab, opts) {
|
||||
if (instruction.name === "loop") {
|
||||
var _startLoc7 = getPosition();
|
||||
|
||||
var blocktypeByte = readByte();
|
||||
eatBytes(1);
|
||||
var blocktype = constants.blockTypes[blocktypeByte];
|
||||
dump([blocktypeByte], "blocktype");
|
||||
|
||||
if (typeof blocktype === "undefined") {
|
||||
throw new CompileError("Unexpected blocktype: " + toHex(blocktypeByte));
|
||||
}
|
||||
|
||||
var blocktype = parseBlockType();
|
||||
var instr = [];
|
||||
parseInstructionBlock(instr); // preserve anonymous
|
||||
|
||||
@@ -697,15 +703,7 @@ export function decode(ab, opts) {
|
||||
} else if (instruction.name === "if") {
|
||||
var _startLoc8 = getPosition();
|
||||
|
||||
var _blocktypeByte = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
var _blocktype = constants.blockTypes[_blocktypeByte];
|
||||
dump([_blocktypeByte], "blocktype");
|
||||
|
||||
if (typeof _blocktype === "undefined") {
|
||||
throw new CompileError("Unexpected blocktype: " + toHex(_blocktypeByte));
|
||||
}
|
||||
var _blocktype = parseBlockType();
|
||||
|
||||
var testIndex = t.withRaw(t.identifier(getUniqueName("if")), "");
|
||||
var ifBody = [];
|
||||
@@ -736,15 +734,7 @@ export function decode(ab, opts) {
|
||||
} else if (instruction.name === "block") {
|
||||
var _startLoc9 = getPosition();
|
||||
|
||||
var _blocktypeByte2 = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
var _blocktype2 = constants.blockTypes[_blocktypeByte2];
|
||||
dump([_blocktypeByte2], "blocktype");
|
||||
|
||||
if (typeof _blocktype2 === "undefined") {
|
||||
throw new CompileError("Unexpected blocktype: " + toHex(_blocktypeByte2));
|
||||
}
|
||||
var _blocktype2 = parseBlockType();
|
||||
|
||||
var _instr2 = [];
|
||||
parseInstructionBlock(_instr2); // preserve anonymous
|
||||
@@ -995,7 +985,7 @@ export function decode(ab, opts) {
|
||||
var elementType = constants.tableTypes[elementTypeByte];
|
||||
|
||||
if (typeof elementType === "undefined") {
|
||||
throw new CompileError("Unknown element type in table: " + toHex(elementType));
|
||||
throw new CompileError("Unknown element type in table: " + toHex(elementTypeByte));
|
||||
}
|
||||
|
||||
var limits = parseLimits();
|
||||
@@ -1201,39 +1191,176 @@ export function decode(ab, opts) {
|
||||
var _startLoc12 = getPosition();
|
||||
|
||||
var tableindexu32 = readU32();
|
||||
var tableindex = tableindexu32.value;
|
||||
var bitfield = tableindexu32.value;
|
||||
eatBytes(tableindexu32.nextIndex);
|
||||
dump([tableindex], "table index");
|
||||
/**
|
||||
* Parse instructions
|
||||
*/
|
||||
dump([bitfield], "bitfield");
|
||||
|
||||
var instr = [];
|
||||
parseInstructionBlock(instr);
|
||||
/**
|
||||
* Parse ( vector function index ) *
|
||||
*/
|
||||
if (bitfield === 0) {
|
||||
// Parse instructions
|
||||
var instr = [];
|
||||
parseInstructionBlock(instr); // Parse ( vector function index ) *
|
||||
|
||||
var indicesu32 = readU32();
|
||||
var indices = indicesu32.value;
|
||||
eatBytes(indicesu32.nextIndex);
|
||||
dump([indices], "num indices");
|
||||
var indexValues = [];
|
||||
var indicesu32 = readU32();
|
||||
var indices = indicesu32.value;
|
||||
eatBytes(indicesu32.nextIndex);
|
||||
dump([indices], "num indices");
|
||||
var indexValues = [];
|
||||
|
||||
for (var _i5 = 0; _i5 < indices; _i5++) {
|
||||
var indexu32 = readU32();
|
||||
var index = indexu32.value;
|
||||
eatBytes(indexu32.nextIndex);
|
||||
dump([index], "index");
|
||||
indexValues.push(t.indexLiteral(index));
|
||||
for (var _i5 = 0; _i5 < indices; _i5++) {
|
||||
var indexu32 = readU32();
|
||||
var index = indexu32.value;
|
||||
eatBytes(indexu32.nextIndex);
|
||||
dump([index], "index");
|
||||
indexValues.push(t.indexLiteral(index));
|
||||
}
|
||||
|
||||
var elemNode = function () {
|
||||
var endLoc = getPosition();
|
||||
return t.withLoc(t.elem(t.indexLiteral(bitfield), instr, indexValues), endLoc, _startLoc12);
|
||||
}();
|
||||
|
||||
elems.push(elemNode);
|
||||
} else if (bitfield === 1) {
|
||||
var elemKind = readByte();
|
||||
eatBytes(1);
|
||||
|
||||
if (elemKind !== 0) {
|
||||
throw new Error("unexpected Elem kind: ".concat(toHex(elemKind)));
|
||||
} // Parse ( vector function index ) *
|
||||
|
||||
|
||||
var _indicesu = readU32();
|
||||
|
||||
var _indices = _indicesu.value;
|
||||
eatBytes(_indicesu.nextIndex);
|
||||
dump([_indices], "num indices");
|
||||
var _indexValues = [];
|
||||
|
||||
for (var _i6 = 0; _i6 < _indices; _i6++) {
|
||||
var _indexu2 = readU32();
|
||||
|
||||
var _index3 = _indexu2.value;
|
||||
eatBytes(_indexu2.nextIndex);
|
||||
dump([_index3], "index");
|
||||
|
||||
_indexValues.push(t.indexLiteral(_index3));
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else if (bitfield === 2) {
|
||||
var u32 = readU32();
|
||||
var tableidx = u32.value;
|
||||
eatBytes(u32.nextIndex);
|
||||
dump([tableidx], "tableidx"); // Parse instructions
|
||||
|
||||
var _instr3 = [];
|
||||
parseInstructionBlock(_instr3);
|
||||
|
||||
var _elemKind = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
|
||||
if (_elemKind !== 0) {
|
||||
throw new Error("unexpected Elem kind: ".concat(toHex(_elemKind)));
|
||||
} // Parse ( vector function index ) *
|
||||
|
||||
|
||||
var _indicesu2 = readU32();
|
||||
|
||||
var _indices2 = _indicesu2.value;
|
||||
eatBytes(_indicesu2.nextIndex);
|
||||
dump([_indices2], "num indices");
|
||||
var _indexValues2 = [];
|
||||
|
||||
for (var _i7 = 0; _i7 < _indices2; _i7++) {
|
||||
var _indexu3 = readU32();
|
||||
|
||||
var _index4 = _indexu3.value;
|
||||
eatBytes(_indexu3.nextIndex);
|
||||
dump([_index4], "index");
|
||||
|
||||
_indexValues2.push(t.indexLiteral(_index4));
|
||||
}
|
||||
|
||||
var _elemNode = function () {
|
||||
var endLoc = getPosition();
|
||||
return t.withLoc(t.elem(t.indexLiteral(bitfield), _instr3, _indexValues2), endLoc, _startLoc12);
|
||||
}();
|
||||
|
||||
elems.push(_elemNode);
|
||||
} else if (bitfield === 3) {
|
||||
var _elemKind2 = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
|
||||
if (_elemKind2 !== 0) {
|
||||
throw new Error("unexpected Elem kind: ".concat(toHex(_elemKind2)));
|
||||
} // Parse ( vector function index ) *
|
||||
|
||||
|
||||
var countU32 = readU32();
|
||||
var count = countU32.value;
|
||||
eatBytes(countU32.nextIndex);
|
||||
dump([count], "count");
|
||||
|
||||
for (var _i8 = 0; _i8 < count; _i8++) {
|
||||
var _indexu4 = readU32();
|
||||
|
||||
var _index5 = _indexu4.value;
|
||||
eatBytes(_indexu4.nextIndex);
|
||||
dump([_index5], "index");
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else if (bitfield === 4) {
|
||||
var expr = [];
|
||||
parseInstructionBlock(expr);
|
||||
|
||||
var _countU = readU32();
|
||||
|
||||
var _count = _countU.value;
|
||||
eatBytes(_countU.nextIndex);
|
||||
dump([_count], "count");
|
||||
|
||||
for (var _i9 = 0; _i9 < _count; _i9++) {
|
||||
var code = [];
|
||||
parseInstructionBlock(code);
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else if (bitfield === 5) {
|
||||
var reftype = readByte();
|
||||
eatBytes(1);
|
||||
dump([reftype], "reftype");
|
||||
|
||||
var _countU2 = readU32();
|
||||
|
||||
var _count2 = _countU2.value;
|
||||
eatBytes(_countU2.nextIndex);
|
||||
dump([_count2], "count");
|
||||
|
||||
for (var _i10 = 0; _i10 < _count2; _i10++) {
|
||||
var _code = [];
|
||||
parseInstructionBlock(_code);
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else if (bitfield === 7) {
|
||||
var _reftype = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
dump([_reftype], "reftype");
|
||||
|
||||
var _countU3 = readU32();
|
||||
|
||||
var _count3 = _countU3.value;
|
||||
eatBytes(_countU3.nextIndex);
|
||||
dump([_count3], "count");
|
||||
|
||||
for (var _i11 = 0; _i11 < _count3; _i11++) {
|
||||
var _code2 = [];
|
||||
parseInstructionBlock(_code2);
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else {
|
||||
throw new Error("unexpected Elem with bitfield ".concat(toHex(bitfield)));
|
||||
}
|
||||
|
||||
var elemNode = function () {
|
||||
var endLoc = getPosition();
|
||||
return t.withLoc(t.elem(t.indexLiteral(tableindex), instr, indexValues), endLoc, _startLoc12);
|
||||
}();
|
||||
|
||||
elems.push(elemNode);
|
||||
}
|
||||
|
||||
return elems;
|
||||
@@ -1702,6 +1829,28 @@ export function decode(ab, opts) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseBlockType() {
|
||||
var blocktypeByte = readByte();
|
||||
var blocktype = constants.blockTypes[blocktypeByte];
|
||||
|
||||
if (typeof blocktype !== "undefined") {
|
||||
eatBytes(1);
|
||||
dump([blocktypeByte], "blocktype"); // value type
|
||||
|
||||
return blocktype;
|
||||
} else {
|
||||
// type index
|
||||
var u32 = readU32();
|
||||
eatBytes(u32.nextIndex);
|
||||
var signature = state.typesInModule[u32.value];
|
||||
console.log({
|
||||
signature: signature
|
||||
});
|
||||
dump([u32.value], "typeidx");
|
||||
return u32.value;
|
||||
}
|
||||
}
|
||||
|
||||
parseModuleHeader();
|
||||
parseVersion();
|
||||
var moduleFields = [];
|
||||
|
||||
271
node_modules/@webassemblyjs/wasm-parser/lib/decoder.js
generated
vendored
271
node_modules/@webassemblyjs/wasm-parser/lib/decoder.js
generated
vendored
@@ -365,7 +365,13 @@ function decode(ab, opts) {
|
||||
if (type == _helperWasmBytecode["default"].types.func) {
|
||||
dump([type], "func");
|
||||
var paramValtypes = parseVec(function (b) {
|
||||
return _helperWasmBytecode["default"].valtypes[b];
|
||||
var valtype = _helperWasmBytecode["default"].valtypes[b];
|
||||
|
||||
if (valtype === undefined) {
|
||||
throw new Error("unexpected value type ".concat(b));
|
||||
}
|
||||
|
||||
return valtype;
|
||||
});
|
||||
var params = paramValtypes.map(function (v) {
|
||||
return t.funcParam(
|
||||
@@ -594,10 +600,7 @@ function decode(ab, opts) {
|
||||
var bodySizeU32 = readU32();
|
||||
eatBytes(bodySizeU32.nextIndex);
|
||||
dump([bodySizeU32.value], "function body size");
|
||||
var code = [];
|
||||
/**
|
||||
* Parse locals
|
||||
*/
|
||||
var code = []; // Parse locals
|
||||
|
||||
var funcLocalNumU32 = readU32();
|
||||
var funcLocalNum = funcLocalNumU32.value;
|
||||
@@ -659,6 +662,13 @@ function decode(ab, opts) {
|
||||
if (instructionByte === 0xfe) {
|
||||
instructionByte = 0xfe00 + readByte();
|
||||
eatBytes(1);
|
||||
} // Table instructions
|
||||
// https://webassembly.github.io/spec/core/binary/instructions.html#table-instructions
|
||||
|
||||
|
||||
if (instructionByte === 0xfc) {
|
||||
instructionByte = 0xfc00 + readByte();
|
||||
eatBytes(1);
|
||||
}
|
||||
|
||||
var instruction = _helperWasmBytecode["default"].symbolsByByte[instructionByte];
|
||||
@@ -667,6 +677,10 @@ function decode(ab, opts) {
|
||||
throw new _helperApiError.CompileError("Unexpected instruction: " + toHex(instructionByte));
|
||||
}
|
||||
|
||||
if (instruction === "illegal") {
|
||||
throw new Error("tried to decode an illegal bytecode: ".concat(toHex(instructionByte)));
|
||||
}
|
||||
|
||||
if (typeof instruction.object === "string") {
|
||||
dump([instructionByte], "".concat(instruction.object, ".").concat(instruction.name));
|
||||
} else {
|
||||
@@ -693,15 +707,7 @@ function decode(ab, opts) {
|
||||
if (instruction.name === "loop") {
|
||||
var _startLoc7 = getPosition();
|
||||
|
||||
var blocktypeByte = readByte();
|
||||
eatBytes(1);
|
||||
var blocktype = _helperWasmBytecode["default"].blockTypes[blocktypeByte];
|
||||
dump([blocktypeByte], "blocktype");
|
||||
|
||||
if (typeof blocktype === "undefined") {
|
||||
throw new _helperApiError.CompileError("Unexpected blocktype: " + toHex(blocktypeByte));
|
||||
}
|
||||
|
||||
var blocktype = parseBlockType();
|
||||
var instr = [];
|
||||
parseInstructionBlock(instr); // preserve anonymous
|
||||
|
||||
@@ -717,15 +723,7 @@ function decode(ab, opts) {
|
||||
} else if (instruction.name === "if") {
|
||||
var _startLoc8 = getPosition();
|
||||
|
||||
var _blocktypeByte = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
var _blocktype = _helperWasmBytecode["default"].blockTypes[_blocktypeByte];
|
||||
dump([_blocktypeByte], "blocktype");
|
||||
|
||||
if (typeof _blocktype === "undefined") {
|
||||
throw new _helperApiError.CompileError("Unexpected blocktype: " + toHex(_blocktypeByte));
|
||||
}
|
||||
var _blocktype = parseBlockType();
|
||||
|
||||
var testIndex = t.withRaw(t.identifier(getUniqueName("if")), "");
|
||||
var ifBody = [];
|
||||
@@ -756,15 +754,7 @@ function decode(ab, opts) {
|
||||
} else if (instruction.name === "block") {
|
||||
var _startLoc9 = getPosition();
|
||||
|
||||
var _blocktypeByte2 = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
var _blocktype2 = _helperWasmBytecode["default"].blockTypes[_blocktypeByte2];
|
||||
dump([_blocktypeByte2], "blocktype");
|
||||
|
||||
if (typeof _blocktype2 === "undefined") {
|
||||
throw new _helperApiError.CompileError("Unexpected blocktype: " + toHex(_blocktypeByte2));
|
||||
}
|
||||
var _blocktype2 = parseBlockType();
|
||||
|
||||
var _instr2 = [];
|
||||
parseInstructionBlock(_instr2); // preserve anonymous
|
||||
@@ -1015,7 +1005,7 @@ function decode(ab, opts) {
|
||||
var elementType = _helperWasmBytecode["default"].tableTypes[elementTypeByte];
|
||||
|
||||
if (typeof elementType === "undefined") {
|
||||
throw new _helperApiError.CompileError("Unknown element type in table: " + toHex(elementType));
|
||||
throw new _helperApiError.CompileError("Unknown element type in table: " + toHex(elementTypeByte));
|
||||
}
|
||||
|
||||
var limits = parseLimits();
|
||||
@@ -1221,39 +1211,176 @@ function decode(ab, opts) {
|
||||
var _startLoc12 = getPosition();
|
||||
|
||||
var tableindexu32 = readU32();
|
||||
var tableindex = tableindexu32.value;
|
||||
var bitfield = tableindexu32.value;
|
||||
eatBytes(tableindexu32.nextIndex);
|
||||
dump([tableindex], "table index");
|
||||
/**
|
||||
* Parse instructions
|
||||
*/
|
||||
dump([bitfield], "bitfield");
|
||||
|
||||
var instr = [];
|
||||
parseInstructionBlock(instr);
|
||||
/**
|
||||
* Parse ( vector function index ) *
|
||||
*/
|
||||
if (bitfield === 0) {
|
||||
// Parse instructions
|
||||
var instr = [];
|
||||
parseInstructionBlock(instr); // Parse ( vector function index ) *
|
||||
|
||||
var indicesu32 = readU32();
|
||||
var indices = indicesu32.value;
|
||||
eatBytes(indicesu32.nextIndex);
|
||||
dump([indices], "num indices");
|
||||
var indexValues = [];
|
||||
var indicesu32 = readU32();
|
||||
var indices = indicesu32.value;
|
||||
eatBytes(indicesu32.nextIndex);
|
||||
dump([indices], "num indices");
|
||||
var indexValues = [];
|
||||
|
||||
for (var _i5 = 0; _i5 < indices; _i5++) {
|
||||
var indexu32 = readU32();
|
||||
var index = indexu32.value;
|
||||
eatBytes(indexu32.nextIndex);
|
||||
dump([index], "index");
|
||||
indexValues.push(t.indexLiteral(index));
|
||||
for (var _i5 = 0; _i5 < indices; _i5++) {
|
||||
var indexu32 = readU32();
|
||||
var index = indexu32.value;
|
||||
eatBytes(indexu32.nextIndex);
|
||||
dump([index], "index");
|
||||
indexValues.push(t.indexLiteral(index));
|
||||
}
|
||||
|
||||
var elemNode = function () {
|
||||
var endLoc = getPosition();
|
||||
return t.withLoc(t.elem(t.indexLiteral(bitfield), instr, indexValues), endLoc, _startLoc12);
|
||||
}();
|
||||
|
||||
elems.push(elemNode);
|
||||
} else if (bitfield === 1) {
|
||||
var elemKind = readByte();
|
||||
eatBytes(1);
|
||||
|
||||
if (elemKind !== 0) {
|
||||
throw new Error("unexpected Elem kind: ".concat(toHex(elemKind)));
|
||||
} // Parse ( vector function index ) *
|
||||
|
||||
|
||||
var _indicesu = readU32();
|
||||
|
||||
var _indices = _indicesu.value;
|
||||
eatBytes(_indicesu.nextIndex);
|
||||
dump([_indices], "num indices");
|
||||
var _indexValues = [];
|
||||
|
||||
for (var _i6 = 0; _i6 < _indices; _i6++) {
|
||||
var _indexu2 = readU32();
|
||||
|
||||
var _index3 = _indexu2.value;
|
||||
eatBytes(_indexu2.nextIndex);
|
||||
dump([_index3], "index");
|
||||
|
||||
_indexValues.push(t.indexLiteral(_index3));
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else if (bitfield === 2) {
|
||||
var u32 = readU32();
|
||||
var tableidx = u32.value;
|
||||
eatBytes(u32.nextIndex);
|
||||
dump([tableidx], "tableidx"); // Parse instructions
|
||||
|
||||
var _instr3 = [];
|
||||
parseInstructionBlock(_instr3);
|
||||
|
||||
var _elemKind = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
|
||||
if (_elemKind !== 0) {
|
||||
throw new Error("unexpected Elem kind: ".concat(toHex(_elemKind)));
|
||||
} // Parse ( vector function index ) *
|
||||
|
||||
|
||||
var _indicesu2 = readU32();
|
||||
|
||||
var _indices2 = _indicesu2.value;
|
||||
eatBytes(_indicesu2.nextIndex);
|
||||
dump([_indices2], "num indices");
|
||||
var _indexValues2 = [];
|
||||
|
||||
for (var _i7 = 0; _i7 < _indices2; _i7++) {
|
||||
var _indexu3 = readU32();
|
||||
|
||||
var _index4 = _indexu3.value;
|
||||
eatBytes(_indexu3.nextIndex);
|
||||
dump([_index4], "index");
|
||||
|
||||
_indexValues2.push(t.indexLiteral(_index4));
|
||||
}
|
||||
|
||||
var _elemNode = function () {
|
||||
var endLoc = getPosition();
|
||||
return t.withLoc(t.elem(t.indexLiteral(bitfield), _instr3, _indexValues2), endLoc, _startLoc12);
|
||||
}();
|
||||
|
||||
elems.push(_elemNode);
|
||||
} else if (bitfield === 3) {
|
||||
var _elemKind2 = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
|
||||
if (_elemKind2 !== 0) {
|
||||
throw new Error("unexpected Elem kind: ".concat(toHex(_elemKind2)));
|
||||
} // Parse ( vector function index ) *
|
||||
|
||||
|
||||
var countU32 = readU32();
|
||||
var count = countU32.value;
|
||||
eatBytes(countU32.nextIndex);
|
||||
dump([count], "count");
|
||||
|
||||
for (var _i8 = 0; _i8 < count; _i8++) {
|
||||
var _indexu4 = readU32();
|
||||
|
||||
var _index5 = _indexu4.value;
|
||||
eatBytes(_indexu4.nextIndex);
|
||||
dump([_index5], "index");
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else if (bitfield === 4) {
|
||||
var expr = [];
|
||||
parseInstructionBlock(expr);
|
||||
|
||||
var _countU = readU32();
|
||||
|
||||
var _count = _countU.value;
|
||||
eatBytes(_countU.nextIndex);
|
||||
dump([_count], "count");
|
||||
|
||||
for (var _i9 = 0; _i9 < _count; _i9++) {
|
||||
var code = [];
|
||||
parseInstructionBlock(code);
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else if (bitfield === 5) {
|
||||
var reftype = readByte();
|
||||
eatBytes(1);
|
||||
dump([reftype], "reftype");
|
||||
|
||||
var _countU2 = readU32();
|
||||
|
||||
var _count2 = _countU2.value;
|
||||
eatBytes(_countU2.nextIndex);
|
||||
dump([_count2], "count");
|
||||
|
||||
for (var _i10 = 0; _i10 < _count2; _i10++) {
|
||||
var _code = [];
|
||||
parseInstructionBlock(_code);
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else if (bitfield === 7) {
|
||||
var _reftype = readByte();
|
||||
|
||||
eatBytes(1);
|
||||
dump([_reftype], "reftype");
|
||||
|
||||
var _countU3 = readU32();
|
||||
|
||||
var _count3 = _countU3.value;
|
||||
eatBytes(_countU3.nextIndex);
|
||||
dump([_count3], "count");
|
||||
|
||||
for (var _i11 = 0; _i11 < _count3; _i11++) {
|
||||
var _code2 = [];
|
||||
parseInstructionBlock(_code2);
|
||||
} // TODO: emit a AST node, for now just make it parse.
|
||||
|
||||
} else {
|
||||
throw new Error("unexpected Elem with bitfield ".concat(toHex(bitfield)));
|
||||
}
|
||||
|
||||
var elemNode = function () {
|
||||
var endLoc = getPosition();
|
||||
return t.withLoc(t.elem(t.indexLiteral(tableindex), instr, indexValues), endLoc, _startLoc12);
|
||||
}();
|
||||
|
||||
elems.push(elemNode);
|
||||
}
|
||||
|
||||
return elems;
|
||||
@@ -1722,6 +1849,28 @@ function decode(ab, opts) {
|
||||
}
|
||||
}
|
||||
|
||||
function parseBlockType() {
|
||||
var blocktypeByte = readByte();
|
||||
var blocktype = _helperWasmBytecode["default"].blockTypes[blocktypeByte];
|
||||
|
||||
if (typeof blocktype !== "undefined") {
|
||||
eatBytes(1);
|
||||
dump([blocktypeByte], "blocktype"); // value type
|
||||
|
||||
return blocktype;
|
||||
} else {
|
||||
// type index
|
||||
var u32 = readU32();
|
||||
eatBytes(u32.nextIndex);
|
||||
var signature = state.typesInModule[u32.value];
|
||||
console.log({
|
||||
signature: signature
|
||||
});
|
||||
dump([u32.value], "typeidx");
|
||||
return u32.value;
|
||||
}
|
||||
}
|
||||
|
||||
parseModuleHeader();
|
||||
parseVersion();
|
||||
var moduleFields = [];
|
||||
|
||||
26
node_modules/@webassemblyjs/wasm-parser/package.json
generated
vendored
26
node_modules/@webassemblyjs/wasm-parser/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@webassemblyjs/wasm-parser",
|
||||
"version": "1.12.1",
|
||||
"version": "1.14.1",
|
||||
"keywords": [
|
||||
"webassembly",
|
||||
"javascript",
|
||||
@@ -17,12 +17,12 @@
|
||||
"author": "Sven Sauleau",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@webassemblyjs/ast": "1.12.1",
|
||||
"@webassemblyjs/helper-api-error": "1.11.6",
|
||||
"@webassemblyjs/helper-wasm-bytecode": "1.11.6",
|
||||
"@webassemblyjs/ieee754": "1.11.6",
|
||||
"@webassemblyjs/leb128": "1.11.6",
|
||||
"@webassemblyjs/utf8": "1.11.6"
|
||||
"@webassemblyjs/ast": "1.14.1",
|
||||
"@webassemblyjs/helper-api-error": "1.13.2",
|
||||
"@webassemblyjs/helper-wasm-bytecode": "1.13.2",
|
||||
"@webassemblyjs/ieee754": "1.13.2",
|
||||
"@webassemblyjs/leb128": "1.13.2",
|
||||
"@webassemblyjs/utf8": "1.13.2"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -32,13 +32,13 @@
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@webassemblyjs/helper-buffer": "1.12.1",
|
||||
"@webassemblyjs/helper-test-framework": "1.12.1",
|
||||
"@webassemblyjs/helper-wasm-bytecode": "1.7.7",
|
||||
"@webassemblyjs/wasm-gen": "1.12.1",
|
||||
"@webassemblyjs/wast-parser": "1.12.1",
|
||||
"@webassemblyjs/helper-buffer": "1.14.1",
|
||||
"@webassemblyjs/helper-test-framework": "1.14.1",
|
||||
"@webassemblyjs/helper-wasm-bytecode": "1.13.2",
|
||||
"@webassemblyjs/wasm-gen": "1.14.1",
|
||||
"@webassemblyjs/wast-parser": "1.14.1",
|
||||
"mamacro": "^0.0.7",
|
||||
"wabt": "1.0.12"
|
||||
},
|
||||
"gitHead": "67c75cf2da65e5588b5e81c10b0d7692d174760b"
|
||||
"gitHead": "25d52b1296e151ac56244a7c3886661e6b4a69ea"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user