aboutsummaryrefslogtreecommitdiff
path: root/include/cps/CodeGen.h
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-22 15:33:17 +0000
committer_ov4 <ov4@ov4.org>2026-10-22 15:35:05 +0000
commit8745f421b4cf7e1d54c17a360d46fab889ca12cc (patch)
tree4c2a3508627db04493af35643580417d41b63f89 /include/cps/CodeGen.h
parent5e84edbe1a79c6a7752ee276ea6c1a4daef4fa8e (diff)
feat(input)!: validate INPUT and read whole lines into STRING
Scalar INPUT now reads one whitespace-delimited token through module-local IR helpers instead of scanf, then skips spaces and tabs and consumes one newline. INTEGER, REAL, BOOLEAN (TRUE or FALSE in any case) and CHAR are validated, and bad input or end of input is a runtime error. STRING INPUT reads the rest of the line. The unused scanf and REAL printf format globals are removed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include/cps/CodeGen.h')
-rw-r--r--include/cps/CodeGen.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/include/cps/CodeGen.h b/include/cps/CodeGen.h
index 9985f9b..ffd589c 100644
--- a/include/cps/CodeGen.h
+++ b/include/cps/CodeGen.h
@@ -151,16 +151,11 @@ class CodeGen {
std::unique_ptr<MemoryHandler> Memory;
llvm::FunctionCallee PrintfFunc;
- llvm::FunctionCallee ScanfFunc;
llvm::Value *PrintfFormatStr; // %lld\n
- llvm::Value *PrintfFloatFormatStr; // %f\n
llvm::Value *PrintfStringFormatStr; // %s\n
llvm::Value *PrintfCharFormatStr; // %c\n
- llvm::Value *ScanfFormatStr; // %lld
- llvm::Value *ScanfFloatFormatStr; // %lf
-
llvm::Value *TrueStr; // "TRUE"
llvm::Value *FalseStr; // "FALSE"
llvm::Value *EmptyStringStr; // ""
@@ -184,7 +179,8 @@ class CodeGen {
llvm::Value *emitCBinaryOp(int Op, llvm::Value *L, const TypeInfo *Left,
llvm::Value *R, const TypeInfo *Right, int Line);
void emitCOutput(llvm::Value *Val, const TypeInfo *Info, bool AppendNewline);
- void emitCInput(llvm::Value *Addr, const TypeInfo *Info);
+ void emitCInput(llvm::Value *Addr, const TypeInfo *Info, int Line);
+ void emitScalarInput(llvm::Value *Addr, const TypeInfo *Info, int Line);
// TYPE-system registration (Designator.cc) and operators (TypeCheckGen.cc).
void runTypePrePass(const std::vector<std::unique_ptr<StmtAST>> &Statements, int Phase);