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

cast null

parent 4f1d914a
No related branches found
No related tags found
2 merge requests!30New new string,!20Master
...@@ -426,7 +426,7 @@ class CastNode(ASTNode): ...@@ -426,7 +426,7 @@ class CastNode(ASTNode):
# only test if not primitive # only test if not primitive
if self.right.myType.isArray == self.left.myType.isArray: if self.right.myType.isArray == self.left.myType.isArray:
if (not self.left.myType.isPrimitive): if (not self.right.myType.isPrimitive):
# cast would've exception if array is casting to non-array and not Object # cast would've exception if array is casting to non-array and not Object
offset = self.left.myType.typePointer.subTypeOffset offset = self.left.myType.typePointer.subTypeOffset
self.code += p("mov", "ebx", "[eax]", "start subtype test") # access class tag of left object self.code += p("mov", "ebx", "[eax]", "start subtype test") # access class tag of left object
...@@ -703,7 +703,7 @@ class ExprNode(ASTNode): ...@@ -703,7 +703,7 @@ class ExprNode(ASTNode):
# only test if non-primitive, both arrays or both non arrays # only test if non-primitive, both arrays or both non arrays
if self.right.myType.isArray == self.left.myType.isArray: if self.right.myType.isArray == self.left.myType.isArray:
if not self.right.myType.isPrimitive: if not self.left.myType.isPrimitive:
offset = self.right.myType.typePointer.subTypeOffset offset = self.right.myType.typePointer.subTypeOffset
self.code += p("mov", "eax", "[eax]") # access class tag of left object self.code += p("mov", "eax", "[eax]") # access class tag of left object
self.code += p("mov", "eax", "[eax + 4]") # access subtype testing column self.code += p("mov", "eax", "[eax + 4]") # access subtype testing column
......
...@@ -41,7 +41,7 @@ class TypeStruct(): ...@@ -41,7 +41,7 @@ class TypeStruct():
self.isPrimitive = False self.isPrimitive = False
self.typePointer = typePointer self.typePointer = typePointer
self.name = name self.name = name
if name in ['boolean', 'byte', 'char', 'int', 'short', 'void']: if name in ['boolean', 'byte', 'char', 'int', 'short', 'void', 'null']:
self.isPrimitive = True self.isPrimitive = True
def link(self, env): def link(self, env):
......
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