aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-13 08:47:52 +0000
committer_ov4 <ov4@ov4.org>2026-10-13 08:47:52 +0000
commit5d5c14920a9aa3397d4b479c22e37392be5557f4 (patch)
tree31eec35c4ef9b7afc310fb624ce1abdb43e3e497 /lib/CodeGen
parent58e2cfe505ba9942524f06bb1b1419e6c579efad (diff)
feat: support comma-separated OUTPUT expressions
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CodeGen.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc
index d5942e9..c0da7ee 100644
--- a/lib/CodeGen/CodeGen.cc
+++ b/lib/CodeGen/CodeGen.cc
@@ -1138,20 +1138,23 @@ void CodeGen::emitStmt(StmtAST *Stmt) {
}
if (auto *Out = dynamic_cast<OutputStmtAST*>(Stmt)) {
- bool Handled = Arrays->tryEmitArrayOutput(Out->getExpr(), *this);
- if (Handled) return;
+ const auto &Exprs = Out->getExprs();
+ for (size_t I = 0; I < Exprs.size(); ++I) {
+ ExprAST *Expr = Exprs[I].get();
+ if (Arrays->tryEmitArrayOutput(Expr, *this)) continue;
- Value *Val = emitExpr(Out->getExpr());
- const TypeInfo *TypeInfo = getExprTypeInfo(Out->getExpr());
- if (!TypeInfo) {
- reportError("Cannot infer the type of the OUTPUT expression");
- return;
- }
- if (TypeInfo->isVoid()) {
- reportError("Cannot OUTPUT the result of a PROCEDURE call");
- return;
+ Value *Val = emitExpr(Expr);
+ const TypeInfo *TypeInfo = getExprTypeInfo(Expr);
+ if (!TypeInfo) {
+ reportError("Cannot infer the type of the OUTPUT expression");
+ continue;
+ }
+ if (TypeInfo->isVoid()) {
+ reportError("Cannot OUTPUT the result of a PROCEDURE call");
+ continue;
+ }
+ emitOutputValue(Val, TypeInfo, I + 1 == Exprs.size());
}
- emitOutputValue(Val, TypeInfo, true);
return;
}