Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(); // (
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)) {
module.exports = function removeFunc(moduleExport, ast) {
const exportName = moduleExport.name;
// TODO(sven): test if we actually want to delete a func
const funcName = moduleExport.descr.id.value;
// console.log(`Remove unused "${exportName}"`);
t.traverse(ast, {
Func(path) {
if (path.node.name.value === funcName) {
path.replaceWith(emptyFunc);
// console.log('\t> remove func');
}
},
ModuleExport(path) {
if (path.node.name === exportName) {
path.remove();
// console.log('\t> remove export');
}
}
});
};
var _nodes11 = parseDataSection(_numberOfElements2);
return {
nodes: _nodes11,
metadata: _metadata11,
nextSectionIndex: nextSectionIndex
};
}
}
case constants.sections.custom:
{
dumpSep("section Custom");
dump([sectionId], "section code");
dump([sectionSizeInBytes], "section size");
var _metadata12 = [t.sectionMetadata("custom", startOffset, sectionSizeInBytesNode)];
var sectionName = readUTF8String();
eatBytes(sectionName.nextIndex);
dump([], "section name (".concat(sectionName.value, ")"));
var _remainingBytes2 = sectionSizeInBytes - sectionName.nextIndex;
if (sectionName.value === "name") {
try {
_metadata12.push.apply(_metadata12, _toConsumableArray(parseNameSection(_remainingBytes2)));
} catch (e) {
console.warn("Failed to decode custom \"name\" section @".concat(offset, "; ignoring (").concat(e.message, ")."));
eatBytes(_remainingBytes2);
}
} else {
// We don't parse the custom section
eatBytes(_remainingBytes2);
function parseTable(): Table {
let name = t.identifier(getUniqueName("table"));
let limit = t.limit(0);
const elemIndices = [];
const 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(); // (
eatToken(); // elem
while (token.type === tokens.identifier) {
elemIndices.push(t.identifier(token.value));
eatToken();
}
eatTokenOfType(tokens.closeParen);
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
// TODO(sven): do something with the data collected here
var stringInitializer = token.value;
eatTokenOfType(tokens.string); // Update limits accordingly
limits = t.limit(stringInitializer.length);
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(); // (
eatToken(); // elem
while (token.type === tokens.identifier) {
elemIndices.push(t.identifier(token.value));
eatToken();
}
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(); // (