修复函数类型判断,终端跑通所有测试代码。Printer格式需要修复
This commit is contained in:
@ -73,10 +73,12 @@ std::any SysYIRGenerator::visitGlobalVarDecl(SysYParser::GlobalVarDeclContext *c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayValueTree* root = std::any_cast<ArrayValueTree *>(varDef->initVal()->accept(this));
|
ValueCounter values = {};
|
||||||
ValueCounter values;
|
if (varDef->initVal() != nullptr) {
|
||||||
Utils::tree2Array(type, root, dims, dims.size(), values, &builder);
|
ArrayValueTree* root = std::any_cast<ArrayValueTree *>(varDef->initVal()->accept(this));
|
||||||
delete root;
|
Utils::tree2Array(type, root, dims, dims.size(), values, &builder);
|
||||||
|
delete root;
|
||||||
|
}
|
||||||
// 创建全局变量,并更新符号表
|
// 创建全局变量,并更新符号表
|
||||||
module->createGlobalValue(name, Type::getPointerType(type), dims, values);
|
module->createGlobalValue(name, Type::getPointerType(type), dims, values);
|
||||||
}
|
}
|
||||||
@ -456,7 +458,7 @@ std::any SysYIRGenerator::visitReturnStmt(SysYParser::ReturnStmtContext *ctx) {
|
|||||||
returnValue = std::any_cast<Value *>(visitExp(ctx->exp()));
|
returnValue = std::any_cast<Value *>(visitExp(ctx->exp()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Type* funcType = builder.getBasicBlock()->getParent()->getType();
|
Type* funcType = builder.getBasicBlock()->getParent()->getReturnType();
|
||||||
if (funcType!= returnValue->getType() && returnValue != nullptr) {
|
if (funcType!= returnValue->getType() && returnValue != nullptr) {
|
||||||
ConstantValue * constValue = dynamic_cast<ConstantValue *>(returnValue);
|
ConstantValue * constValue = dynamic_cast<ConstantValue *>(returnValue);
|
||||||
if (constValue != nullptr) {
|
if (constValue != nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user