Pass all test

main
Odeinjul 11 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 .DS_STORE
build cmake-build-debug/
build/

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

Loading…
Cancel
Save