// parseFunctions resolves function constants and it injects the // necessary function prolog and epilog code. // // What the latter means, is that we analyze the registers being // used. If any of them are registers that are guaranteed to // be preserved across function calls, then we explicitly inject stack // push/pop instructions to save their state. // // If there are any `return` instructions, we replace them with `set pc, $$`. // Where `$$` is a label we generate which points to the function epilog. func parseFunctions(ast *parser.AST) (err error) { list := ast.Functions() for i := range list { if err = parseFuncConst(ast, list[i]); err != nil { return } fixFunctionReturns(ast, list[i]) injectFunctionCode(ast, list[i]) } return }