Implemented comparison equality operators
This commit is contained in:
@@ -275,6 +275,26 @@ BoundExpression* Binder::BindBinaryOperator(BinaryExpression* expression){
|
||||
case BinaryOperatorKind ::Inequality:
|
||||
return new BoundBinaryExpression(boundLeft, boundRight, BoundBinaryOperation::Inequality, std::make_shared<ScriptType>(TypeClass::Bool),
|
||||
expression->GetStartPosition(), expression->GetLength());
|
||||
case BinaryOperatorKind ::Less:
|
||||
if (boundLeft->GetType()->GetClass() == TypeClass::Number && boundRight->GetType()->GetClass() == TypeClass::Number){
|
||||
return new BoundBinaryExpression(boundLeft, boundRight, BoundBinaryOperation::LessThan, std::make_shared<ScriptType>(TypeClass::Bool),
|
||||
expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
case BinaryOperatorKind ::LessOrEquals:
|
||||
if (boundLeft->GetType()->GetClass() == TypeClass::Number && boundRight->GetType()->GetClass() == TypeClass::Number){
|
||||
return new BoundBinaryExpression(boundLeft, boundRight, BoundBinaryOperation::LessThanEquals, std::make_shared<ScriptType>(TypeClass::Bool),
|
||||
expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
case BinaryOperatorKind ::Greater:
|
||||
if (boundLeft->GetType()->GetClass() == TypeClass::Number && boundRight->GetType()->GetClass() == TypeClass::Number){
|
||||
return new BoundBinaryExpression(boundLeft, boundRight, BoundBinaryOperation::GreaterThan, std::make_shared<ScriptType>(TypeClass::Bool),
|
||||
expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
case BinaryOperatorKind ::GreaterOrEquals:
|
||||
if (boundLeft->GetType()->GetClass() == TypeClass::Number && boundRight->GetType()->GetClass() == TypeClass::Number){
|
||||
return new BoundBinaryExpression(boundLeft, boundRight, BoundBinaryOperation::GreaterThanEquals, std::make_shared<ScriptType>(TypeClass::Bool),
|
||||
expression->GetStartPosition(), expression->GetLength());
|
||||
}
|
||||
case BinaryOperatorKind ::LogicalAnd:
|
||||
if (boundLeftType->GetClass() == TypeClass::Bool && boundRightType->GetClass() == TypeClass::Bool)
|
||||
return new BoundBinaryExpression(boundLeft, boundRight, BoundBinaryOperation::LogicalAnd, std::make_shared<ScriptType>(TypeClass::Bool),
|
||||
|
||||
@@ -9,6 +9,11 @@ enum class BoundBinaryOperation{
|
||||
Division,
|
||||
Equality,
|
||||
Inequality,
|
||||
LessThan,
|
||||
LessThanEquals,
|
||||
GreaterThan,
|
||||
GreaterThanEquals,
|
||||
|
||||
LogicalAnd,
|
||||
LogicalOr,
|
||||
Concatenation
|
||||
|
||||
Reference in New Issue
Block a user