public override String AttrPrint() { String retVal; if (Utilities.attrToType(this.attrRef) == "ErrorTypeDescriptor") { retVal = String.Format("\nType: {0} (check argument in this loop-statement)", Utilities.attrToType(this.attrRef)); } else { IterationStmtTypeDescriptor ITD = this.attrRef.typeInfo; retVal = String.Format("\nType: {0} (Loop-Statement) with valid boolean condition", Utilities.attrToType(this.attrRef)); // If we have an else path if (ITD.ConditionNode != null) { retVal += String.Format("\nCondition Type: {0}", Utilities.attrToType(ITD.ConditionNode.attrRef)); } if (ITD.BlockNode != null) { retVal += String.Format("\nBlock Type: {0}", ITD.BlockNode.NodeType.Name); } } return(retVal); }
public void VisitNode(Stmt node) { // Iteration statements handled here if (node.Name != null && node.Name.Contains("Iteration")) { // Dcl-Visit all children Utilities.DclVisitAllChildren(node, this); // We always have an expression // We always have a block Attributes a = new Attributes("IterationStmt"); IterationStmtTypeDescriptor ITD = new IterationStmtTypeDescriptor(); ITD.BlockNode = null; ITD.ConditionNode = null; ErrorTypeDescriptor ETD = new ErrorTypeDescriptor(); // If our expression is a boolean, we are valid a.typeInfo = ETD; List <Expr> matchingChildren = Utilities.GetChildren(node, typeof(Expr)).Cast <Expr>().ToList(); if (Utilities.attrToType(matchingChildren[0].attrRef) == "BooleanTypeDescriptor") { a.typeInfo = ITD; } // Get all children AbstractNode an; an = node.Child; while (an != null) { // Filter out all expr from this if (an.NodeType.Name == "Expr") { ITD.ConditionNode = an; } if (an.NodeType.Name == "Block") { ITD.BlockNode = an; } an = an.Sib; } node.attrRef = a; //currentSymbolTable.decrNestLevel(); } }