aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/StatementGen.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-17 09:16:22 +0000
committer_ov4 <ov4@ov4.org>2026-10-17 09:16:22 +0000
commit64aa538142148faf06b9a3c71907eacee04cd49d (patch)
tree8c8b572d391a5cf5c269fd5c2484e1ba82ed5fcb /lib/CodeGen/StatementGen.cc
parent39e50838bd12057d9305575f50c63990984df01a (diff)
feat(codegen): FUNCTION MAIN entry point
Invoke the internal entry function through the generated exception handler and truncate its INTEGER result to the process exit status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/StatementGen.cc')
-rw-r--r--lib/CodeGen/StatementGen.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/CodeGen/StatementGen.cc b/lib/CodeGen/StatementGen.cc
index 5b6a13c..1a9c285 100644
--- a/lib/CodeGen/StatementGen.cc
+++ b/lib/CodeGen/StatementGen.cc
@@ -99,9 +99,9 @@ void CodeGen::emitStmt(StmtAST *Stmt) {
if (auto *Ret = dynamic_cast<ReturnStmtAST*>(Stmt)) {
Function *F = Builder->GetInsertBlock()->getParent();
- const FuncSig *Sig = FuncGen->getSignature(F->getName().str());
- // Pseudocode cannot name a function "main" (reserved runtime symbol),
- // so no signature means we are emitting the top level.
+ const FuncSig *Sig = F->getName() == "main" ? nullptr
+ : FuncGen->getSignature(F->getName().str());
+ // The generated wrapper has no signature; user MAIN uses __cps_main.
if (!Sig) {
reportError("RETURN is only allowed inside a FUNCTION or PROCEDURE");
return;