Merge branch 'master' of https://gitee.com/NUDT-compiler/nudt-compiler-cpp
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "SysYParser.h"
|
||||
#include "ir/IR.h"
|
||||
#include "utils/Log.h"
|
||||
|
||||
void IRGenImpl::GenBlock(SysYParser::BlockContext& block) {
|
||||
for (auto* item : block.blockItem()) {
|
||||
@@ -24,7 +25,7 @@ bool IRGenImpl::GenBlockItem(SysYParser::BlockItemContext& item) {
|
||||
if (item.stmt()) {
|
||||
return GenStmt(*item.stmt());
|
||||
}
|
||||
throw std::runtime_error("[irgen] 暂不支持的 blockItem 类型");
|
||||
throw std::runtime_error(FormatError("irgen", "暂不支持的语句或声明"));
|
||||
}
|
||||
|
||||
void IRGenImpl::GenDecl(SysYParser::DeclContext& decl) {
|
||||
@@ -32,12 +33,12 @@ void IRGenImpl::GenDecl(SysYParser::DeclContext& decl) {
|
||||
GenVarDecl(*decl.varDecl());
|
||||
return;
|
||||
}
|
||||
throw std::runtime_error("[irgen] 暂不支持的声明类型");
|
||||
throw std::runtime_error(FormatError("irgen", "暂不支持的声明类型"));
|
||||
}
|
||||
|
||||
void IRGenImpl::GenVarDecl(SysYParser::VarDeclContext& decl) {
|
||||
if (storage_map_.find(&decl) != storage_map_.end()) {
|
||||
throw std::runtime_error("[irgen] 声明重复生成存储槽位");
|
||||
throw std::runtime_error(FormatError("irgen", "声明重复生成存储槽位"));
|
||||
}
|
||||
auto* slot = builder_.CreateAllocaI32(module_.context().NextTemp());
|
||||
storage_map_[&decl] = slot;
|
||||
|
||||
Reference in New Issue
Block a user