Skip to content

Commit

Permalink
Fix TokType::Rem assert
Browse files Browse the repository at this point in the history
  • Loading branch information
Ttimofeyka committed Jul 22, 2024
1 parent 09113f2 commit bf18f77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/first.rave
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import <std/io> <std/map>
import <std/io> <std/string>

void main {

Expand Down
10 changes: 3 additions & 7 deletions src/parser/nodes/NodeBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,9 @@ LLVMValueRef NodeBinary::generate() {
}

if(this->op == TokType::Rem) {
if(instanceof<TypeBasic>(this->first->getType())) {
TypeBasic* type = (TypeBasic*)this->first->getType();
if(type->type == BasicType::Float || type->type == BasicType::Double) return (new NodeBuiltin("fmodf", {this->first, this->second}, this->loc, nullptr))->generate();
return (new NodeCast(type, new NodeBuiltin("fmodf", {this->first, this->second}, this->loc, nullptr), this->loc))->generate();
}
generator->error("NodeBinary: TokType::Rem assert!", loc);
return nullptr;
Type* type = this->first->getType();
if(instanceof<TypeBasic>(type) && (((TypeBasic*)type)->type == BasicType::Float || ((TypeBasic*)type)->type == BasicType::Double)) return (new NodeBuiltin("fmodf", {this->first, this->second}, this->loc, nullptr))->generate();
return (new NodeCast(instanceof<TypeVoid>(type) ? new TypeBasic(BasicType::Double) : type, new NodeBuiltin("fmodf", {this->first, this->second}, this->loc, nullptr), this->loc))->generate();
}

LLVMValueRef vFirst = this->first->generate();
Expand Down

0 comments on commit bf18f77

Please sign in to comment.