From b16ddfd5d0bc48b66123352827979e242fcd6bfc Mon Sep 17 00:00:00 2001 From: bd-912 Date: Mon, 25 Mar 2024 13:05:34 -0600 Subject: Funnel all debug print statements into designated print filter --- minijava/TypeCheckSimp.java | 105 +++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 50 deletions(-) (limited to 'minijava/TypeCheckSimp.java') diff --git a/minijava/TypeCheckSimp.java b/minijava/TypeCheckSimp.java index 4ad0639..57b6be9 100644 --- a/minijava/TypeCheckSimp.java +++ b/minijava/TypeCheckSimp.java @@ -14,19 +14,19 @@ public class TypeCheckSimp implements GJVisitor argu, boolean enter, TypeEnum consensus) { for (int i=0; i < this.offset; ++i) - System.out.print("."); + Utilities.print_filter(".", false); if (enter) - System.out.print("Visiting "); + Utilities.print_filter("Visiting ", false); else - System.out.print("Leaving "); - System.out.print(n.getClass().getSimpleName()); + Utilities.print_filter("Leaving ", false); + Utilities.print_filter(n.getClass().getSimpleName(), false); if (!enter) { if (consensus == TypeEnum.ERROR) - System.out.print(" did not type check."); + Utilities.print_filter(" did not type check.", false); else - System.out.print(" found type " + consensus); + Utilities.print_filter(" found type " + consensus, false); } - System.out.println(); + Utilities.print_filter("", true); } // @@ -174,7 +174,7 @@ public class TypeCheckSimp implements GJVisitor ClassDeclaration() - * | ClassExtendsDeclaration() + * | ClassExtendsDeclaration() */ public TypeInstance visit(TypeDeclaration n, HashMap argu) { ++this.offset; @@ -245,20 +245,26 @@ public class TypeCheckSimp implements GJVisitor Type() * f1 -> Identifier() @@ -375,15 +381,15 @@ public class TypeCheckSimp implements GJVisitor ArrayType() - * | BooleanType() - * | IntegerType() - * | Identifier() + * | BooleanType() + * | IntegerType() + * | Identifier() */ public TypeInstance visit(Type n, HashMap argu) { ++this.offset; this.printNode(n, argu, true, null); - TypeInstance ret = n.f0.accept(this, argu); + TypeInstance ret = n.f0.accept(this, argu); this.printNode(n, argu, false, ret.get_type()); --this.offset; @@ -413,7 +419,7 @@ public class TypeCheckSimp implements GJVisitor Block() - * | AssignmentStatement() - * | ArrayAssignmentStatement() - * | IfStatement() - * | WhileStatement() - * | PrintStatement() + * | AssignmentStatement() + * | ArrayAssignmentStatement() + * | IfStatement() + * | WhileStatement() + * | PrintStatement() */ public TypeInstance visit(Statement n, HashMap argu) { ++this.offset; this.printNode(n, argu, true, null); - TypeInstance ret = n.f0.accept(this, argu); + TypeInstance ret = n.f0.accept(this, argu); this.printNode(n, argu, false, ret.get_type()); --this.offset; @@ -521,9 +527,9 @@ public class TypeCheckSimp implements GJVisitor AndExpression() - * | CompareExpression() - * | PlusExpression() - * | MinusExpression() - * | TimesExpression() - * | ArrayLookup() - * | ArrayLength() - * | MessageSend() - * | PrimaryExpression() + * | CompareExpression() + * | PlusExpression() + * | MinusExpression() + * | TimesExpression() + * | ArrayLookup() + * | ArrayLength() + * | MessageSend() + * | PrimaryExpression() */ public TypeInstance visit(Expression n, HashMap argu) { ++this.offset; @@ -814,7 +820,7 @@ public class TypeCheckSimp implements GJVisitor PrimaryExpression() * f1 -> "." @@ -827,7 +833,6 @@ public class TypeCheckSimp implements GJVisitor IntegerLiteral() - * | TrueLiteral() - * | FalseLiteral() - * | Identifier() - * | ThisExpression() - * | ArrayAllocationExpression() - * | AllocationExpression() - * | NotExpression() - * | BracketExpression() + * | TrueLiteral() + * | FalseLiteral() + * | Identifier() + * | ThisExpression() + * | ArrayAllocationExpression() + * | AllocationExpression() + * | NotExpression() + * | BracketExpression() */ public TypeInstance visit(PrimaryExpression n, HashMap argu) { ++this.offset; -- cgit v1.2.3