forked from NUDT-compiler/nudt-compiler-cpp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
493 B
20 lines
493 B
// 语句翻译模块:
|
|
// - 处理 if/while/return 等控制流构造
|
|
// - 负责基本块创建、分支跳转与控制流收束
|
|
|
|
#include "irgen/IRGen.h"
|
|
|
|
#include <stdexcept>
|
|
|
|
#include "ast/AstNodes.h"
|
|
#include "ir/IR.h"
|
|
|
|
void IRGenImpl::GenStmt(const ast::Stmt& stmt) {
|
|
if (auto ret = dynamic_cast<const ast::ReturnStmt*>(&stmt)) {
|
|
ir::Value* v = GenExpr(*ret->value);
|
|
builder_.CreateRet(v);
|
|
return;
|
|
}
|
|
throw std::runtime_error("[irgen] 暂不支持的语句类型");
|
|
}
|