Skip to content
Snippets Groups Projects
Commit 19eb00f4 authored by pycsham's avatar pycsham
Browse files

Fixed remaining definitve assignemnt issues. Passing 80% on local

parent 68c2b22e
No related branches found
No related tags found
No related merge requests found
......@@ -136,6 +136,7 @@ def getParseTreeNodes(names, tree, terminateList = []):
result.extend(getParseTreeNodes(names, n, terminateList))
return result
# Getting a list of nodes with the provided list of names of the nodes
def getASTNode(names, AST):
result = []
if not AST:
......
from AST import ASTNode, getParseTreeNodes
from AST import ASTNode, getParseTreeNodes, getASTNode
from Environment import Env
from ExprPrimaryNodes import makeNodeFromExpr, makeNodeFromAllPrimary, MethodInvNode, ClassCreateNode
from TheTypeNode import TypeNode, TypeStruct
......@@ -113,7 +113,12 @@ class VarDclNode(ASTNode):
# Checking for definite assignment
if checkAssign:
if not self.variableInit:
raise Exception("ERROR: local variable declaration not assigned")
raise Exception("ERROR: local variable declaration {} is not assigned".format(self.name))
# Checking if the local variable appears in it's own intializer
nameNodes = getASTNode(["NameNode"], self.variableInit)
for node in nameNodes:
if self.name in node.IDs:
raise Exception("ERROR: local variable {} appears in it's own intialization".format(self.name))
self.myType = self.dclType.myType
self.children.append(self.dclType)
......
......@@ -134,7 +134,7 @@ def run(testFiles):
parseTrees.append((f, tree))
# for (n, t) in parseTrees:
# if n == "Tests/A3/J1_accessstaticfield/Main.java":
# if n == "./Tests/A4/Je_8_DefiniteAssignment_InitToItself.java":
# print(n)
# print(t)
try:
......@@ -142,11 +142,12 @@ def run(testFiles):
except Exception as e:
return "AST buidling: " + e.args[0]
# for (n, t) in ASTs:
# print(n)
# print("--------------------")
# t.printTree()
# print("\n \n\n \n")
for (n, t) in ASTs:
if n == "./Tests/A4/Je_8_DefiniteAssignment_ComplexInitializer.java":
print(n)
print("--------------------")
t.printTree()
print("\n \n\n \n")
try:
buildEnvAndLink(ASTs)
......
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