Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseTable() {
var name = t.identifier(getUniqueName("table"));
var limit = t.limit(0);
var elemIndices = [];
var elemType = "anyfunc";
if (token.type === tokens.string || token.type === tokens.identifier) {
name = identifierFromToken(token);
eatToken();
} else {
name = t.withRaw(name, ""); // preserve anonymous
}
while (token.type !== tokens.closeParen) {
/**
* Maybe export
*/
if (lookaheadAndCheck(tokens.openParen, keywords.elem)) {
eatToken(); // (
function parseMemory() {
var id = t.identifier(getUniqueName("memory"));
var limits = t.limit(0);
if (token.type === tokens.string || token.type === tokens.identifier) {
id = t.identifier(token.value);
eatToken();
} else {
id = t.withRaw(id, ""); // preserve anonymous
}
/**
* Maybe data
*/
if (lookaheadAndCheck(tokens.openParen, keywords.data)) {
eatToken(); // (
eatToken(); // data
function parseTable() {
var name = t.identifier(getUniqueName("table"));
var limit = t.limit(0);
var elemIndices = [];
var elemType = "anyfunc";
if (token.type === tokens.string || token.type === tokens.identifier) {
name = identifierFromToken(token);
eatToken();
} else {
name = t.withRaw(name, ""); // preserve anonymous
}
while (token.type !== tokens.closeParen) {
/**
* Maybe export
*/
if (lookaheadAndCheck(tokens.openParen, keywords.elem)) {
eatToken(); // (
});
eatTokenOfType(tokens.closeParen);
} else if (isKeyword(token, keywords.anyfunc)) {
// It's the default value, we can ignore it
eatToken(); // anyfunc
} else if (token.type === tokens.number) {
/**
* Table type
*/
var min = parseInt(token.value);
eatToken();
if (token.type === tokens.number) {
var max = parseInt(token.value);
eatToken();
limit = t.limit(min, max);
} else {
limit = t.limit(min);
}
eatToken();
} else {
throw function () {
return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token" + ", given " + tokenToString(token));
}();
}
}
if (elemIndices.length > 0) {
return t.table(elemType, limit, name, elemIndices);
} else {
return t.table(elemType, limit, name);
dump([min], "min");
var u32max = readU32();
max = parseInt(u32max.value);
eatBytes(u32max.nextIndex);
dump([max], "max");
}
if (limitType === 0x00) {
var _u32min = readU32();
min = parseInt(_u32min.value);
eatBytes(_u32min.nextIndex);
dump([min], "min");
}
return t.limit(min, max);
} // https://webassembly.github.io/spec/core/binary/types.html#binary-tabletype
function parseTable() {
var name = t.identifier(getUniqueName("table"));
var limit = t.limit(0);
var elemIndices = [];
var elemType = "anyfunc";
if (token.type === tokens.string || token.type === tokens.identifier) {
name = identifierFromToken(token);
eatToken();
} else {
name = t.withRaw(name, ""); // preserve anonymous
}
while (token.type !== tokens.closeParen) {
/**
* Maybe export
*/
if (lookaheadAndCheck(tokens.openParen, keywords.elem)) {
eatToken(); // (
}
/**
* Maybe data
*/
if (lookaheadAndCheck(tokens.openParen, keywords.data)) {
eatToken(); // (
eatToken(); // data
// TODO(sven): do something with the data collected here
var stringInitializer = token.value;
eatTokenOfType(tokens.string); // Update limits accordingly
limits = t.limit(stringInitializer.length);
eatTokenOfType(tokens.closeParen);
}
/**
* Maybe export
*/
if (lookaheadAndCheck(tokens.openParen, keywords.export)) {
eatToken(); // (
eatToken(); // export
if (token.type !== tokens.string) {
throw function () {
return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Expected string in export" + ", given " + tokenToString(token));
}();
}
/**
* Maybe data
*/
if (lookaheadAndCheck(tokens.openParen, keywords.data)) {
eatToken(); // (
eatToken(); // data
// TODO(sven): do something with the data collected here
var stringInitializer = token.value;
eatTokenOfType(tokens.string); // Update limits accordingly
limits = t.limit(stringInitializer.length);
eatTokenOfType(tokens.closeParen);
}
/**
* Maybe export
*/
if (lookaheadAndCheck(tokens.openParen, keywords.export)) {
eatToken(); // (
eatToken(); // export
if (token.type !== tokens.string) {
throw function () {
return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Expected string in export" + ", given " + tokenToString(token));
}();
const u32max = readU32();
max = parseInt(u32max.value);
eatBytes(u32max.nextIndex);
dump([max], "max");
}
if (limitType === 0x00) {
const u32min = readU32();
min = parseInt(u32min.value);
eatBytes(u32min.nextIndex);
dump([min], "min");
}
return t.limit(min, max);
}
var _name = token.value;
eatToken();
state.registredExportedElements.push({
exportType: "Memory",
name: _name,
id: id
});
eatTokenOfType(tokens.closeParen);
}
/**
* Memory signature
*/
if (token.type === tokens.number) {
limits = t.limit(parse32I(token.value));
eatToken();
if (token.type === tokens.number) {
limits.max = parse32I(token.value);
eatToken();
}
}
return t.memory(limits, id);
}
/**