Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function encodeInstr(n: Instr): Array {
const out = [];
let instructionName = n.id;
if (typeof n.object === "string") {
instructionName = `${n.object}.${String(n.id)}`;
}
const byteString = constants.symbolsByName[instructionName];
if (typeof byteString === "undefined") {
throw new Error(
"encodeInstr: unknown instruction " + JSON.stringify(instructionName)
);
}
const byte = parseInt(byteString, 10);
out.push(byte);
if (n.args) {
n.args.forEach(arg => {
let encoder = encodeU32;
// find correct encoder
export function encodeInstr(n) {
var out = [];
var instructionName = n.id;
if (typeof n.object === "string") {
instructionName = "".concat(n.object, ".").concat(String(n.id));
}
var byteString = constants.symbolsByName[instructionName];
if (typeof byteString === "undefined") {
throw new Error("encodeInstr: unknown instruction " + JSON.stringify(instructionName));
}
var byte = parseInt(byteString, 10);
out.push(byte);
if (n.args) {
n.args.forEach(function (arg) {
var encoder = encodeU32; // find correct encoder
if (n.object === "i32") {
encoder = encodeI32;
}
export function encodeInstr(n) {
var out = [];
var instructionName = n.id;
if (typeof n.object === "string") {
instructionName = "".concat(n.object, ".").concat(String(n.id));
}
var byteString = constants.symbolsByName[instructionName];
if (typeof byteString === "undefined") {
throw new Error("encodeInstr: unknown instruction " + JSON.stringify(instructionName));
}
var byte = parseInt(byteString, 10);
out.push(byte);
if (n.args) {
n.args.forEach(function (arg) {
var encoder = encodeU32; // find correct encoder
if (n.object === "i32") {
encoder = encodeI32;
}