| 590 | } |
| 591 | |
| 592 | Expect<void> |
| 593 | compile(const AST::CodeSegment &Code, |
| 594 | std::pair<std::vector<ValType>, std::vector<ValType>> Type) noexcept { |
| 595 | auto RetBB = LLVM::BasicBlock::create(LLContext, F.Fn, "ret"); |
| 596 | Type.first.clear(); |
| 597 | enterBlock(RetBB, {}, {}, {}, std::move(Type)); |
| 598 | EXPECTED_TRY(compile(Code.getExpr().getInstrs())); |
| 599 | assuming(ControlStack.empty()); |
| 600 | compileReturn(); |
| 601 | |
| 602 | for (auto &[Error, BB] : TrapBB) { |
| 603 | Builder.positionAtEnd(BB); |
| 604 | updateInstrCount(); |
| 605 | updateGasAtTrap(); |
| 606 | auto CallTrap = Builder.createCall( |
| 607 | Context.Trap, {LLContext.getInt32(static_cast<uint32_t>(Error))}); |
| 608 | CallTrap.addCallSiteAttribute(Context.NoReturn); |
| 609 | Builder.createUnreachable(); |
| 610 | } |
| 611 | return {}; |
| 612 | } |
| 613 | |
| 614 | Expect<void> compile(AST::InstrView Instrs) noexcept { |
| 615 | auto Dispatch = [this](const AST::Instruction &Instr) -> Expect<void> { |
nothing calls this directly
no test coverage detected