From 8f2b5dcc1c123088ceda31b88990333b3786042e Mon Sep 17 00:00:00 2001 From: pycsham <shampuiyanchloe@gmail.com> Date: Fri, 6 Mar 2020 22:32:11 -0500 Subject: [PATCH] changed issue with checking type for field access --- ExprPrimaryNodes.py | 5 ++++- NameNode.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ExprPrimaryNodes.py b/ExprPrimaryNodes.py index d853c7d..ea0c0f9 100644 --- a/ExprPrimaryNodes.py +++ b/ExprPrimaryNodes.py @@ -421,7 +421,10 @@ class FieldAccessNode(ASTNode): def checkType(self): self.primary.checkType() - self.ID.prefixLink = self.primary.myType.typePointer + if self.primary.myType.isArray or self.primary.myType.isPrimitive: + self.ID.prefixLink = self.primary + else: + self.ID.prefixLink = self.primary.myType.typePointer self.ID.checkType() self.myType = self.ID.myType diff --git a/NameNode.py b/NameNode.py index 66c5125..74dee52 100644 --- a/NameNode.py +++ b/NameNode.py @@ -65,6 +65,13 @@ class NameNode(ASTNode): self.addToPrefix(typeNode) return True return False + + def checkLength(self): + if not self.IDs: + return True + if self.IDs[0] == "length": + return True + return False # Checks and updates prefix if the next ID in self.IDs is a local variable or a parameter def checkLocalVar(self): @@ -164,6 +171,10 @@ class NameNode(ASTNode): # Checking if a1 is "this" if self.checkThis(): return + + # Checking if a1 is length + if self.checkLength(): + return # Checking if a1 is a local variable if self.checkLocalVar(): -- GitLab