aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/StatementGen.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-22 03:52:21 +0000
committer_ov4 <ov4@ov4.org>2026-10-22 03:58:26 +0000
commite717664c749cf237479147ddecd70a39fc3426f2 (patch)
tree3db2c715f2b566654d356ccd1e3fd6adbe23c260 /lib/CodeGen/StatementGen.cc
parent5fdea7e2edd534d15eff95efb33336430d7b4872 (diff)
refactor(codegen): share writable variable lookup
emitLValue (variable and designator base) and plain assignment repeated the same lookup, enum-or-unknown diagnostic and requireWritable check. Move it into a private lookupWritableSymbol helper. READFILE keeps its own lookup, which has no enum diagnostic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/StatementGen.cc')
-rw-r--r--lib/CodeGen/StatementGen.cc12
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/CodeGen/StatementGen.cc b/lib/CodeGen/StatementGen.cc
index f4cd661..c1a9490 100644
--- a/lib/CodeGen/StatementGen.cc
+++ b/lib/CodeGen/StatementGen.cc
@@ -152,16 +152,8 @@ void CodeGen::emitStmtImpl(StmtAST *Stmt) {
}
if (auto *Assign = dynamic_cast<AssignStmtAST*>(Stmt)) {
- const SymbolInfo *Info = getSymbolInfo(Assign->getName());
- if (!Info) {
- if (Types->lookupEnumConstant(Assign->getName())) {
- reportError("Enum value %s is not an assignable location", Assign->getName().c_str());
- } else {
- reportError("Unknown variable name %s", Assign->getName().c_str());
- }
- return;
- }
- if (!requireWritable(*Info, Assign->getName())) return;
+ const SymbolInfo *Info = lookupWritableSymbol(Assign->getName());
+ if (!Info) return;
if (Info->IsArray) {
reportError("Cannot assign array %s without indices", Assign->getName().c_str());
return;