feat(frontend): 命令行添加IR和AST选择输出

This commit is contained in:
jing
2026-02-28 23:40:05 +08:00
parent d08b23276a
commit 66659524c8
7 changed files with 75 additions and 16 deletions

View File

@@ -3,3 +3,27 @@
// - 表达式、语句、声明、函数、类型等节点
// - 支持后续阶段在节点上附加信息(类型、符号绑定、常量值等)
#include "ast/AstNodes.h"
#include <utility>
namespace ast {
NumberExpr::NumberExpr(int v) : value(v) {}
VarExpr::VarExpr(std::string n) : name(std::move(n)) {}
BinaryExpr::BinaryExpr(BinaryOp op, std::shared_ptr<Expr> lhs,
std::shared_ptr<Expr> rhs)
: op(op), lhs(std::move(lhs)), rhs(std::move(rhs)) {}
ReturnStmt::ReturnStmt(std::shared_ptr<Expr> v) : value(std::move(v)) {}
VarDecl::VarDecl(std::string n, std::shared_ptr<Expr> i)
: name(std::move(n)), init(std::move(i)) {}
FuncDef::FuncDef(std::string n, std::shared_ptr<Block> b)
: name(std::move(n)), body(std::move(b)) {}
CompUnit::CompUnit(std::shared_ptr<FuncDef> f) : func(std::move(f)) {}
} // namespace ast