Skip to content

Commit

Permalink
not node in value
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsVind committed May 14, 2024
1 parent c0a2ad3 commit 2249f39
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ target_include_directories(dpli PRIVATE ${PROJECT_SOURCE_DIR}/include)

target_link_libraries(dpli PRIVATE dpllib antlr4_static)

add_subdirectory(tests)
#add_subdirectory(tests)

# Strip debug symbols in Release mode
if(CMAKE_BUILD_TYPE STREQUAL "Release")
Expand Down
3 changes: 0 additions & 3 deletions src/Evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ void Evaluator::visit(const std::shared_ptr<EqualExprNode> &node) {
std::shared_ptr<AstNode> rightNode = node->getRightNode();
rightNode->accept(shared_from_this());

bool numeric = leftNode->getVal().isNumeric() && rightNode->getVal().isNumeric();
bool string = leftNode->getVal().is<Value::STR>() && rightNode->getVal().is<Value::STR>();

// Evaluates the value of the expression
node->setVal(leftNode->getVal() == rightNode->getVal());
}
Expand Down
8 changes: 4 additions & 4 deletions src/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,16 @@ bool Value::operator>=(const Value& other) const { return *this > other || *this

bool Value::operator!() const {
if (is<INT>() || is<FLOAT>()) {
return get<INT>() != 0;
return get<INT>() == 0; // not 0 == true
}
if (is<BOOL>()) {
return !get<BOOL>();
return !get<BOOL>(); // not False == True
}
if (is<STR>()) {
return !get<STR>().empty();
return get<STR>().empty(); // not "" == true
}
if (is<LIST>()) {
return !get<LIST>()->empty();
return get<LIST>()->empty(); // not [] == true
}

throw InternalException("Can not use NOT on this type");
Expand Down

0 comments on commit 2249f39

Please sign in to comment.