Skip to content

Commit

Permalink
fix: Fixed unary operator parsing ignoring left side
Browse files Browse the repository at this point in the history
  • Loading branch information
alinalihassan committed May 26, 2022
1 parent 51541f4 commit 81702f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/liblesma/Backend/Codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,13 +1218,13 @@ llvm::Value *Codegen::genFuncCall(FuncCall *node, const std::vector<llvm::Value

auto *func = dyn_cast<Function>(symbol->getLLVMValue());
if (class_sym != nullptr && class_sym->getType()->is(TY_CLASS)) {
Builder->CreateCall(func, params, func->getReturnType()->isVoidTy() ? "" : "tmp");
Builder->CreateCall(func, params, func->getReturnType()->isVoidTy() ? "" : ".tmp");
auto val = Builder->CreateLoad(class_sym->getLLVMType(), class_ptr);
classSymbol = classSymbolTmp;

return val;
}
return Builder->CreateCall(func, params, func->getReturnType()->isVoidTy() ? "" : "tmp");
return Builder->CreateCall(func, params, func->getReturnType()->isVoidTy() ? "" : ".tmp");
}

int Codegen::FindIndexInFields(SymbolType *_struct, const std::string &field) {
Expand Down
6 changes: 3 additions & 3 deletions src/liblesma/Frontend/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ Expression *Parser::ParseDot() {
}

Expression *Parser::ParseUnary() {
Expression *left = ParseDot();
Expression *left = nullptr;
while (AdvanceIfMatchAny<TokenType::MINUS>()) {
auto op = Previous();
auto expr = ParseTerm();
auto expr = ParseDot();
left = new UnaryOp({op->getStart(), expr->getEnd()}, op->type, expr);
}
return left;
return left == nullptr ? ParseDot() : left;
}

Expression *Parser::ParseCast() {
Expand Down

0 comments on commit 81702f1

Please sign in to comment.