Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var indicesu32 = readU32();
var indices = indicesu32.value;
eatBytes(indicesu32.nextIndex);
dump([indices], "num indices");
var indexValues = [];
for (var _i4 = 0; _i4 < indices; _i4++) {
var indexu32 = readU32();
var index = indexu32.value;
eatBytes(indexu32.nextIndex);
dump([index], "index");
indexValues.push(t.indexLiteral(index));
}
var endLoc = getPosition();
var elemNode = t.withLoc(t.elem(t.indexLiteral(tableindex), instr, indexValues), endLoc, startLoc);
elems.push(elemNode);
}
return elems;
} // https://webassembly.github.io/spec/core/binary/types.html#memory-types
eatTokenOfType(tokens.closeParen);
return t.withLoc(node, endLoc, startLoc);
}
const instruction = parseFuncInstr();
const endLoc = getEndLoc();
maybeIgnoreComment();
if (typeof instruction === "object") {
if (typeof token !== "undefined") {
eatTokenOfType(tokens.closeParen);
}
return t.withLoc(instruction, endLoc, startLoc);
}
}
if (token.type === tokens.comment) {
const startLoc = getStartLoc();
const builder =
token.opts.type === "leading" ? t.leadingComment : t.blockComment;
const node = builder(token.value);
eatToken(); // comment
const endLoc = getEndLoc();
return t.withLoc(node, endLoc, startLoc);
}
const signature = t.signatureForOpcode(object || "", name);
const { args, namedArgs } = parseFuncInstrArguments(signature);
const endLoc = token.loc.end;
if (typeof object === "undefined") {
return t.withLoc(
t.instruction(name, args, namedArgs),
endLoc,
startLoc
);
} else {
return t.withLoc(
t.objectInstruction(name, object, args, namedArgs),
endLoc,
startLoc
);
}
} else if (isKeyword(token, keywords.loop)) {
/**
* Else a instruction with a keyword (loop or block)
*/
eatToken(); // keyword
return parseLoop();
} else if (isKeyword(token, keywords.block)) {
eatToken(); // keyword
return parseBlock();
};
var sizeEndLoc = {
line: -1,
column: start + 1
}; // 1 byte for the empty vector
var size = t.withLoc(t.numberLiteralFromRaw(1), sizeEndLoc, sizeStartLoc);
var vectorOfSizeStartLoc = {
line: -1,
column: sizeEndLoc.column
};
var vectorOfSizeEndLoc = {
line: -1,
column: sizeEndLoc.column + 1
};
var vectorOfSize = t.withLoc(t.numberLiteralFromRaw(0), vectorOfSizeEndLoc, vectorOfSizeStartLoc);
var sectionMetadata = t.sectionMetadata(section, start, size, vectorOfSize);
var sectionBytes = encodeNode(sectionMetadata);
uint8Buffer = overrideBytesInBuffer(uint8Buffer, start - 1, end, sectionBytes); // Add section into the AST for later lookups
if (_typeof(ast.body[0].metadata) === "object") {
// $FlowIgnore: metadata can not be empty
ast.body[0].metadata.sections.push(sectionMetadata);
t.sortSectionMetadata(ast.body[0]);
}
/**
* Update AST
*/
// Once we hit our section every that is after needs to be shifted by the delta
var deltaBytes = +sectionBytes.length;
eatBytes(1);
if (sectionId >= sectionIndex || sectionIndex === sections.custom) {
sectionIndex = sectionId + 1;
} else {
if (sectionId !== sections.custom) throw new _helperApiError.CompileError("Unexpected section: " + toHex(sectionId));
}
var nextSectionIndex = sectionIndex;
var startOffset = offset;
var startPosition = getPosition();
var u32 = readU32();
var sectionSizeInBytes = u32.value;
eatBytes(u32.nextIndex);
var sectionSizeInBytesEndLoc = getPosition();
var sectionSizeInBytesNode = t.withLoc(t.numberLiteralFromRaw(sectionSizeInBytes), sectionSizeInBytesEndLoc, startPosition);
switch (sectionId) {
case sections.type:
{
dumpSep("section Type");
dump([sectionId], "section code");
dump([sectionSizeInBytes], "section size");
var _startPosition = getPosition();
var _u = readU32();
var numberOfTypes = _u.value;
eatBytes(_u.nextIndex);
var endPosition = getPosition();
if (token.type !== tokens.name) {
throw new TypeError("Unknown token: " + token.type + ", name expected");
}
_name2 = token.value;
eatToken();
}
if (token.type === tokens.closeParen) {
var _endLoc = token.loc.end;
if (typeof object === "undefined") {
return t.withLoc(t.instruction(_name2), _endLoc, startLoc);
} else {
return t.withLoc(t.objectInstruction(_name2, object, []), _endLoc, startLoc);
}
}
var signature = t.signatureForOpcode(object || "", _name2);
var _parseFuncInstrArgume = parseFuncInstrArguments(signature),
_args = _parseFuncInstrArgume.args,
_namedArgs = _parseFuncInstrArgume.namedArgs;
var endLoc = token.loc.end;
if (typeof object === "undefined") {
return t.withLoc(t.instruction(_name2, _args, _namedArgs), endLoc, startLoc);
} else {
return t.withLoc(t.objectInstruction(_name2, object, _args, _namedArgs), endLoc, startLoc);
}
var _endLoc12 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node10, _endLoc12, startLoc);
}
if (isKeyword(token, keywords.start)) {
eatToken();
var _node11 = parseStart();
var _endLoc13 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node11, _endLoc13, startLoc);
}
if (isKeyword(token, keywords.elem)) {
eatToken();
var _node12 = parseElem();
var _endLoc14 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node12, _endLoc14, startLoc);
}
var instruction = parseFuncInstr();
var endLoc = getEndLoc();
maybeIgnoreComment();
var _endLoc9 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node7, _endLoc9, startLoc);
}
if (isKeyword(token, keywords.table)) {
eatToken();
var _node8 = parseTable();
var _endLoc10 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node8, _endLoc10, startLoc);
}
if (isKeyword(token, keywords.global)) {
eatToken();
var _node9 = parseGlobal();
var _endLoc11 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node9, _endLoc11, startLoc);
}
if (isKeyword(token, keywords.type)) {
eatToken();
var _endLoc9 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node7, _endLoc9, startLoc);
}
if (isKeyword(token, keywords.table)) {
eatToken();
var _node8 = parseTable();
var _endLoc10 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node8, _endLoc10, startLoc);
}
if (isKeyword(token, keywords.global)) {
eatToken();
var _node9 = parseGlobal();
var _endLoc11 = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(_node9, _endLoc11, startLoc);
}
if (isKeyword(token, keywords.type)) {
eatToken();