Skip to content
Snippets Groups Projects
Commit 6f8f3032 authored by Derval Guillaume's avatar Derval Guillaume
Browse files

Eq for expressions

parent 39866aa1
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,13 @@ class BoolExpressionComparison(BoolExpression):
operator: Operator
rhs: Expression
def __bool__(self):
""" Checks if lhs and rhs are *exactly* the same tree in an eq relation """
#TODO improve me
if self.operator == Operator.equal:
return self.lhs is self.rhs
return False
@dataclass
class ExpressionUseGenScope(ExpressionObj):
......
......@@ -5,7 +5,14 @@ from gboml.ast.base import GBOMLObject
@dataclass
class ExpressionObj(GBOMLObject):
pass
def __eq__(self, obj):
from gboml.ast.expression_operators import Operator, BoolExpressionComparison
# first: check type
if not isinstance(obj, Expression):
return False
if self is obj:
return True
return BoolExpressionComparison(self, Operator.equal, obj)
Expression = int | float | ExpressionObj
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment