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 toIR(ast: Program): IR {
const program = {};
const funcTable = [];
// flatten the ast first
// TODO(sven): do it in a single pass?
flatten(ast);
const module = new Module(ast);
traverse(ast, {
Start({ node }: NodePath) {
const { name, startAt } = module.emitStartFunc(
parseInt(node.index.value)
);
funcTable.push({ name, startAt });
},
Func(funcPath: NodePath) {
module.beginFuncBody(funcPath.node);
traverse(funcPath.node, {