diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 09:16:22 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 09:16:22 +0000 |
| commit | 64aa538142148faf06b9a3c71907eacee04cd49d (patch) | |
| tree | 8c8b572d391a5cf5c269fd5c2484e1ba82ed5fcb /lib/CodeGen/StatementGen.cc | |
| parent | 39e50838bd12057d9305575f50c63990984df01a (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.cc | 6 |
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; |
