Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dump([_value5], "f64 value");
args.push( // $FlowIgnore
t.floatLiteral(_value5, valuef64.nan, valuef64.inf, String(_value5)));
}
} else {
for (var _i2 = 0; _i2 < instruction.numberOfArgs; _i2++) {
var u32 = readU32();
eatBytes(u32.nextIndex);
dump([u32.value], "argument " + _i2);
args.push(t.numberLiteralFromRaw(u32.value));
}
}
if (instructionAlreadyCreated === false) {
if (typeof instruction.object === "string") {
code.push(t.objectInstruction(instruction.name, instruction.object, args));
} else {
var endLoc = getPosition();
var _node2 = t.withLoc(t.instruction(instruction.name, args), endLoc, startLoc);
code.push(_node2);
}
}
}
} // https://webassembly.github.io/spec/core/binary/types.html#limits
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();
} else if (isKeyword(token, keywords.call_indirect)) {
eatTokenOfType(tokens.openParen);
var offset;
if (token.type === tokens.valtype) {
eatTokenOfType(tokens.valtype); // i32
eatTokenOfType(tokens.dot); // .
if (token.value !== "const") {
throw new Error("constant expression required");
}
eatTokenOfType(tokens.name); // const
var numberLiteral = t.numberLiteralFromRaw(token.value, "i32");
offset = t.objectInstruction("const", "i32", [numberLiteral]);
eatToken();
eatTokenOfType(tokens.closeParen);
} else {
eatTokenOfType(tokens.name); // get_global
var _numberLiteral = t.numberLiteralFromRaw(token.value, "i32");
offset = t.instruction("get_global", [_numberLiteral]);
eatToken();
eatTokenOfType(tokens.closeParen);
}
var byteArray = parseString(token.value);
eatToken(); // "string"
return t.data(t.memIndexLiteral(memidx), offset, t.byteArray(byteArray));
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);
}
} 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();
} else if (isKeyword(token, keywords.call_indirect)) {
eatToken(); // keyword
return parseCallIndirect();
eatTokenOfType(tokens.openParen);
var offset;
if (token.type === tokens.valtype) {
eatTokenOfType(tokens.valtype); // i32
eatTokenOfType(tokens.dot); // .
if (token.value !== "const") {
throw new Error("constant expression required");
}
eatTokenOfType(tokens.name); // const
var numberLiteral = t.numberLiteralFromRaw(token.value, "i32");
offset = t.objectInstruction("const", "i32", [numberLiteral]);
eatToken();
eatTokenOfType(tokens.closeParen);
} else {
eatTokenOfType(tokens.name); // get_global
var _numberLiteral = t.numberLiteralFromRaw(token.value, "i32");
offset = t.instruction("get_global", [_numberLiteral]);
eatToken();
eatTokenOfType(tokens.closeParen);
}
var byteArray = parseString(token.value);
eatToken(); // "string"
return t.data(t.memIndexLiteral(memidx), offset, t.byteArray(byteArray));
eatTokenOfType(tokens.openParen);
var offset;
if (token.type === tokens.valtype) {
eatTokenOfType(tokens.valtype); // i32
eatTokenOfType(tokens.dot); // .
if (token.value !== "const") {
throw new Error("constant expression required");
}
eatTokenOfType(tokens.name); // const
var numberLiteral = t.numberLiteralFromRaw(token.value, "i32");
offset = t.objectInstruction("const", "i32", [numberLiteral]);
eatToken();
eatTokenOfType(tokens.closeParen);
} else {
eatTokenOfType(tokens.name); // get_global
var _numberLiteral = t.numberLiteralFromRaw(token.value, "i32");
offset = t.instruction("get_global", [_numberLiteral]);
eatToken();
eatTokenOfType(tokens.closeParen);
}
var byteArray = (0, _stringLiterals.parseString)(token.value);
eatToken(); // "string"
return t.data(t.memIndexLiteral(memidx), offset, t.byteArray(byteArray));
const createDefaultInitForGlobal = globalType => {
if (globalType.valtype[0] === "i") {
// create NumberLiteral global initializer
return t.objectInstruction("const", globalType.valtype, [
t.numberLiteralFromRaw(66)
]);
} else if (globalType.valtype[0] === "f") {
// create FloatLiteral global initializer
return t.objectInstruction("const", globalType.valtype, [
t.floatLiteral(66, false, false, "66")
]);
} else {
throw new Error("unknown type: " + globalType.valtype);
}
};
}
} else {
for (let i = 0; i < instruction.numberOfArgs; i++) {
const u32 = readU32();
eatBytes(u32.nextIndex);
dump([u32.value], "argument " + i);
args.push(t.numberLiteralFromRaw(u32.value));
}
}
if (instructionAlreadyCreated === false) {
if (typeof instruction.object === "string") {
const node = WITH_LOC(
t.objectInstruction(instruction.name, instruction.object, args),
startLoc
);
code.push(node);
} else {
const node = WITH_LOC(
t.instruction(instruction.name, args),
startLoc
);
code.push(node);
}
}
}
}
"Unknown token: " + token.type + ", name expected"
);
}
name = token.value;
eatToken();
}
if (token.type === tokens.closeParen) {
const endLoc = token.loc.end;
if (typeof object === "undefined") {
return t.withLoc(t.instruction(name), endLoc, startLoc);
} else {
return t.withLoc(
t.objectInstruction(name, object, []),
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,
Elem({node}) {
const offset = t.objectInstruction("const", "i32", [
t.numberLiteralFromRaw(0)
]);
node.offset = [offset];
},