attempt to fix linux install

This commit is contained in:
Talles Amadeu 2025-12-09 14:17:40 -03:00
parent 512b1a821e
commit 05b3ff6e1e
4 changed files with 13 additions and 25 deletions

Binary file not shown.

View File

@ -370,8 +370,8 @@ void CodeGen::visit(IfStmt& node) {
llvm::Function* theFunction = builder->GetInsertBlock()->getParent();
llvm::BasicBlock* thenBB = llvm::BasicBlock::Create(*context, "then", theFunction);
llvm::BasicBlock* elseBB = llvm::BasicBlock::Create(*context, "else");
llvm::BasicBlock* mergeBB = llvm::BasicBlock::Create(*context, "ifcont");
llvm::BasicBlock* elseBB = llvm::BasicBlock::Create(*context, "else", theFunction);
llvm::BasicBlock* mergeBB = llvm::BasicBlock::Create(*context, "ifcont", theFunction);
builder->CreateCondBr(condV, thenBB, elseBB);
@ -385,7 +385,6 @@ void CodeGen::visit(IfStmt& node) {
}
// Emit else block.
theFunction->insert(theFunction->end(), elseBB);
builder->SetInsertPoint(elseBB);
if (node.elseBranch) {
node.elseBranch->accept(*this);
@ -396,7 +395,6 @@ void CodeGen::visit(IfStmt& node) {
}
// Emit merge block.
theFunction->insert(theFunction->end(), mergeBB);
builder->SetInsertPoint(mergeBB);
}
@ -404,8 +402,8 @@ void CodeGen::visit(WhileStmt& node) {
llvm::Function* theFunction = builder->GetInsertBlock()->getParent();
llvm::BasicBlock* condBB = llvm::BasicBlock::Create(*context, "loopcond", theFunction);
llvm::BasicBlock* bodyBB = llvm::BasicBlock::Create(*context, "loopbody");
llvm::BasicBlock* afterBB = llvm::BasicBlock::Create(*context, "loopafter");
llvm::BasicBlock* bodyBB = llvm::BasicBlock::Create(*context, "loopbody", theFunction);
llvm::BasicBlock* afterBB = llvm::BasicBlock::Create(*context, "loopafter", theFunction);
// Jump to condition
builder->CreateBr(condBB);
@ -420,7 +418,6 @@ void CodeGen::visit(WhileStmt& node) {
builder->CreateCondBr(condV, bodyBB, afterBB);
// Body Block
theFunction->insert(theFunction->end(), bodyBB);
builder->SetInsertPoint(bodyBB);
breakStack.push_back(afterBB);
@ -430,7 +427,6 @@ void CodeGen::visit(WhileStmt& node) {
builder->CreateBr(condBB); // Loop back to condition
// After Block
theFunction->insert(theFunction->end(), afterBB);
builder->SetInsertPoint(afterBB);
}
@ -443,8 +439,8 @@ void CodeGen::visit(ForStmt& node) {
}
llvm::BasicBlock* condBB = llvm::BasicBlock::Create(*context, "loopcond", theFunction);
llvm::BasicBlock* bodyBB = llvm::BasicBlock::Create(*context, "loopbody");
llvm::BasicBlock* afterBB = llvm::BasicBlock::Create(*context, "loopafter");
llvm::BasicBlock* bodyBB = llvm::BasicBlock::Create(*context, "loopbody", theFunction);
llvm::BasicBlock* afterBB = llvm::BasicBlock::Create(*context, "loopafter", theFunction);
// Jump to condition
builder->CreateBr(condBB);
@ -466,7 +462,6 @@ void CodeGen::visit(ForStmt& node) {
builder->CreateCondBr(condV, bodyBB, afterBB);
// Body Block
theFunction->insert(theFunction->end(), bodyBB);
builder->SetInsertPoint(bodyBB);
breakStack.push_back(afterBB);
@ -481,7 +476,6 @@ void CodeGen::visit(ForStmt& node) {
builder->CreateBr(condBB); // Loop back to condition
// After Block
theFunction->insert(theFunction->end(), afterBB);
builder->SetInsertPoint(afterBB);
}
@ -504,8 +498,8 @@ void CodeGen::visit(ForInStmt& node) {
// 4. Create Loop Blocks
llvm::BasicBlock* condBB = llvm::BasicBlock::Create(*context, "loopcond", theFunction);
llvm::BasicBlock* bodyBB = llvm::BasicBlock::Create(*context, "loopbody");
llvm::BasicBlock* afterBB = llvm::BasicBlock::Create(*context, "loopafter");
llvm::BasicBlock* bodyBB = llvm::BasicBlock::Create(*context, "loopbody", theFunction);
llvm::BasicBlock* afterBB = llvm::BasicBlock::Create(*context, "loopafter", theFunction);
builder->CreateBr(condBB);
@ -516,7 +510,6 @@ void CodeGen::visit(ForInStmt& node) {
builder->CreateCondBr(condV, bodyBB, afterBB);
// 6. Body
theFunction->insert(theFunction->end(), bodyBB);
builder->SetInsertPoint(bodyBB);
// Fetch element at index
@ -568,7 +561,6 @@ void CodeGen::visit(ForInStmt& node) {
builder->CreateBr(condBB);
// After Block
theFunction->insert(theFunction->end(), afterBB);
builder->SetInsertPoint(afterBB);
}
@ -840,18 +832,18 @@ void CodeGen::visit(SwitchStmt& node) {
llvm::Function* theFunction = builder->GetInsertBlock()->getParent();
// 2. Create Merge Block (after switch)
llvm::BasicBlock* mergeBB = llvm::BasicBlock::Create(*context, "switchmerge");
llvm::BasicBlock* mergeBB = llvm::BasicBlock::Create(*context, "switchmerge", theFunction);
// Push mergeBB to breakStack so 'break' jumps here
breakStack.push_back(mergeBB);
// 3. Create Default Block
llvm::BasicBlock* defaultBB = llvm::BasicBlock::Create(*context, "switchdefault");
llvm::BasicBlock* defaultBB = llvm::BasicBlock::Create(*context, "switchdefault", theFunction);
// 4. Create Blocks for Cases
std::vector<llvm::BasicBlock*> caseBBs;
for (size_t i = 0; i < node.cases.size(); ++i) {
caseBBs.push_back(llvm::BasicBlock::Create(*context, "case" + std::to_string(i)));
caseBBs.push_back(llvm::BasicBlock::Create(*context, "case" + std::to_string(i), theFunction));
}
// 5. Generate Comparisons (If-Else Chain)
@ -886,7 +878,6 @@ void CodeGen::visit(SwitchStmt& node) {
// 6. Generate Case Bodies
for (size_t i = 0; i < node.cases.size(); ++i) {
theFunction->insert(theFunction->end(), caseBBs[i]);
builder->SetInsertPoint(caseBBs[i]);
node.cases[i].body->accept(*this);
@ -902,7 +893,6 @@ void CodeGen::visit(SwitchStmt& node) {
}
// 7. Generate Default Body
theFunction->insert(theFunction->end(), defaultBB);
builder->SetInsertPoint(defaultBB);
if (node.defaultCase) {
node.defaultCase->accept(*this);
@ -914,7 +904,6 @@ void CodeGen::visit(SwitchStmt& node) {
// 8. Finish
breakStack.pop_back();
theFunction->insert(theFunction->end(), mergeBB);
builder->SetInsertPoint(mergeBB);
}
@ -927,7 +916,6 @@ void CodeGen::visit(BreakStmt& node) {
builder->CreateBr(breakStack.back());
llvm::Function* theFunction = builder->GetInsertBlock()->getParent();
llvm::BasicBlock* deadBB = llvm::BasicBlock::Create(*context, "dead");
theFunction->insert(theFunction->end(), deadBB);
llvm::BasicBlock* deadBB = llvm::BasicBlock::Create(*context, "dead", theFunction);
builder->SetInsertPoint(deadBB);
}

View File

@ -1,6 +1,6 @@
#ifndef SUN_VERSION_H
#define SUN_VERSION_H
#define SUN_VERSION "0.3.0"
#define SUN_VERSION "0.3.1"
#endif // SUN_VERSION_H

BIN
sun

Binary file not shown.