Skip to content
Snippets Groups Projects
Commit b928c01e authored by Xun Yang's avatar Xun Yang
Browse files

fix instanceof check

parent 23bede0d
No related branches found
No related tags found
No related merge requests found
...@@ -324,7 +324,7 @@ class ExprNode(ASTNode): ...@@ -324,7 +324,7 @@ class ExprNode(ASTNode):
return return
# Other Comparisons: # Other Comparisons:
elif self.left.myType.assignable(self.right.myType) or self.right.myType.assignable(self.left.myType): elif self.left.myType.assignable(self.right.myType) or self.right.myType.assignable(self.left.myType):
if self.op == '==' or self.op == '!=': if self.op == '==' or self.op == '!=' or self.op == 'instanceof':
self.myType = TypeStruct("boolean", None) self.myType = TypeStruct("boolean", None)
return return
...@@ -335,16 +335,9 @@ class ExprNode(ASTNode): ...@@ -335,16 +335,9 @@ class ExprNode(ASTNode):
self.myType.link(self.env) self.myType.link(self.env)
return return
elif self.op == 'instanceof':
# assume it's correct for now, wait for runtime check
self.myType = TypeStruct("boolean", None)
return
raise Exception("ERROR: Incompatible types. Left of {} type can't be used with right of {} type on operation {}".format(self.op, self.left.myType.name, self.right.myType.name)) raise Exception("ERROR: Incompatible types. Left of {} type can't be used with right of {} type on operation {}".format(self.op, self.left.myType.name, self.right.myType.name))
################################################################################### ###################################################################################
# fieldAccess primary PERIOD ID # fieldAccess primary PERIOD ID
class FieldAccessNode(ASTNode): class FieldAccessNode(ASTNode):
......
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