Pass all test

main
Odeinjul 12 months ago
parent 1e70dba04c
commit de51429073
No known key found for this signature in database
GPG Key ID: E384228B2B38FFBB

6
.gitignore vendored

@ -1,3 +1,3 @@
.vscode
build
.DS_STORE
cmake-build-debug/
build/

@ -385,8 +385,8 @@ void IRBuilder::visit(SyntaxTree::FuncDef &node) {
scope.push(node.name, func);
scope.enter();
auto entryBlock = BasicBlock::create(module, "funcEntry", func);
retBB = BasicBlock::create(module, "ret", func);
auto entryBlock = BasicBlock::create(module, "", func);
retBB = BasicBlock::create(module, "", func);
builder->set_insert_point(entryBlock);
@ -648,8 +648,8 @@ void IRBuilder::visit(SyntaxTree::BinaryCondExpr &node) {
Ptr<Instruction> cond;
switch (node.op) {
case SyntaxTree::BinaryCondOp::LAND:
trueBB = BasicBlock::create(module, "trueBB_and", curFunc);
falseBB = BasicBlock::create(module, "falseBB_and", curFunc);
trueBB = BasicBlock::create(module, "", curFunc);
falseBB = BasicBlock::create(module, "", curFunc);
node.lhs->accept(*this);
TypeConvert(tmpInst, INT1_T);
builder->create_cond_br(tmpInst, trueBB, falseBB);
@ -665,8 +665,8 @@ void IRBuilder::visit(SyntaxTree::BinaryCondExpr &node) {
break;
case SyntaxTree::BinaryCondOp::LOR:
trueBB = BasicBlock::create(module, "trueBB_and", curFunc);
falseBB = BasicBlock::create(module, "falseBB_and", curFunc);
trueBB = BasicBlock::create(module, "", curFunc);
falseBB = BasicBlock::create(module, "", curFunc);
node.lhs->accept(*this);
TypeConvert(tmpInst, INT1_T);
builder->create_cond_br(tmpInst, trueBB, falseBB);
@ -744,9 +744,9 @@ void IRBuilder::visit(SyntaxTree::FuncCallStmt &node) {
// FINISH
void IRBuilder::visit(SyntaxTree::IfStmt &node) {
auto curFunc = builder->get_insert_block()->get_parent();
auto trueBB = BasicBlock::create(module, "trueBB_if", curFunc);
auto falseBB = BasicBlock::create(module, "falseBB_if", curFunc);
auto afterBB = node.else_statement == nullptr ? falseBB : BasicBlock::create(module, "afterBB_if", curFunc);
auto trueBB = BasicBlock::create(module, "", curFunc);
auto falseBB = BasicBlock::create(module, "", curFunc);
auto afterBB = node.else_statement == nullptr ? falseBB : BasicBlock::create(module, "", curFunc);
node.cond_exp->accept(*this);
@ -771,9 +771,9 @@ void IRBuilder::visit(SyntaxTree::IfStmt &node) {
//FINISH
void IRBuilder::visit(SyntaxTree::WhileStmt &node) {
auto curFunc = builder->get_insert_block()->get_parent();
auto condBB = BasicBlock::create(module, "condBB_while", curFunc);
auto bodyBB = BasicBlock::create(module, "bodyBB_while", curFunc);
auto afterBB = BasicBlock::create(module, "afterBB_while", curFunc);
auto condBB = BasicBlock::create(module, "", curFunc);
auto bodyBB = BasicBlock::create(module, "", curFunc);
auto afterBB = BasicBlock::create(module, "", curFunc);
auto tmpWhileBlock = curWhileBlock;
curWhileBlock = WhileBlock{condBB, bodyBB, afterBB};

Loading…
Cancel
Save