Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _value2 = value64.value;
eatBytes(value64.nextIndex);
dump([_value2], "i64 value");
var node = {
type: "LongNumberLiteral",
value: badI32ToI64Conversion(_value2)
};
args.push(node);
}
if (instruction.object === "u64") {
var valueu64 = readU64();
var _value3 = valueu64.value;
eatBytes(valueu64.nextIndex);
dump([_value3], "u64 value");
args.push(t.numberLiteralFromRaw(_value3));
}
if (instruction.object === "f32") {
var valuef32 = readF32();
var _value4 = valuef32.value;
eatBytes(valuef32.nextIndex);
dump([_value4], "f32 value");
args.push( // $FlowIgnore
t.floatLiteral(_value4, valuef32.nan, valuef32.inf, String(_value4)));
}
if (instruction.object === "f64") {
var valuef64 = readF64();
var _value5 = valuef64.value;
eatBytes(valuef64.nextIndex);
dump([_value5], "f64 value");
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);
}
};
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));
}
/**
dump([value], "f64 value");
args.push(
// $FlowIgnore
t.floatLiteral(value, valuef64.nan, valuef64.inf, String(value))
);
}
} 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
);
var memNode = state.memoriesInModule[index];
if (typeof memNode === "undefined") {
throw new CompileError("unknown memory ".concat(index));
}
id = t.numberLiteralFromRaw(index, String(index));
signature = null;
} else if (constants.exportTypes[typeIndex] === "Global") {
var global = state.globalsInModule[index];
if (typeof global === "undefined") {
throw new CompileError("unknown global ".concat(index));
}
id = t.numberLiteralFromRaw(index, String(index));
signature = null;
} else {
console.warn("Unsupported export type: " + toHex(typeIndex));
return;
}
var endLoc = getPosition();
state.elementsInExportSection.push({
name: name.value,
type: constants.exportTypes[typeIndex],
signature: signature,
id: id,
index: index,
endLoc: endLoc,
startLoc: _startLoc3
});
* Numeric instructions
*/
if (instruction.object === "i32") {
var value32 = read32();
var value = value32.value;
eatBytes(value32.nextIndex);
dump([value], "i32 value");
args.push(t.numberLiteralFromRaw(value));
}
if (instruction.object === "u32") {
var valueu32 = readU32();
var _value = valueu32.value;
eatBytes(valueu32.nextIndex);
dump([_value], "u32 value");
args.push(t.numberLiteralFromRaw(_value));
}
if (instruction.object === "i64") {
var value64 = read64();
var _value2 = value64.value;
eatBytes(value64.nextIndex);
dump([_value2], "i64 value");
var node = {
type: "LongNumberLiteral",
value: badI32ToI64Conversion(_value2)
};
args.push(node);
}
if (instruction.object === "u64") {
var valueu64 = readU64();
case constants.sections.element:
{
dumpSep("section Element");
dump([sectionId], "section code");
dump([sectionSizeInBytes], "section size");
var _startPosition7 = getPosition();
var numberOfElementsu32 = readU32();
var numberOfElements = numberOfElementsu32.value;
eatBytes(numberOfElementsu32.nextIndex);
var _endPosition6 = getPosition();
var _metadata8 = t.sectionMetadata("element", startOffset, sectionSizeInBytesNode, t.withLoc(t.numberLiteralFromRaw(numberOfElements), _endPosition6, _startPosition7));
var _nodes8 = parseElemSection(numberOfElements);
return {
nodes: _nodes8,
metadata: _metadata8,
nextSectionIndex: nextSectionIndex
};
}
case constants.sections.global:
{
dumpSep("section Global");
dump([sectionId], "section code");
dump([sectionSizeInBytes], "section size");
case sections.global:
{
dumpSep("section Global");
dump([sectionId], "section code");
dump([sectionSizeInBytes], "section size");
var _startPosition8 = getPosition();
var numberOfGlobalsu32 = readU32();
var numberOfGlobals = numberOfGlobalsu32.value;
eatBytes(numberOfGlobalsu32.nextIndex);
var _endPosition7 = getPosition();
var _metadata9 = t.sectionMetadata("global", startOffset, sectionSizeInBytesNode, t.withLoc(t.numberLiteralFromRaw(numberOfGlobals), _endPosition7, _startPosition8));
var _nodes9 = parseGlobalSection(numberOfGlobals);
return {
nodes: _nodes9,
metadata: _metadata9,
nextSectionIndex: nextSectionIndex
};
}
case sections.memory:
{
dumpSep("section Memory");
dump([sectionId], "section code");
dump([sectionSizeInBytes], "section size");