From afff6a80cd58f7787efa1398f7c8cbdce8989323 Mon Sep 17 00:00:00 2001 From: geno Date: Sun, 30 Jun 2024 13:36:37 +0200 Subject: fixed warnings, better formatting, final added where possible --- src/ast/nodes/IfNode.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/ast/nodes/IfNode.java') diff --git a/src/ast/nodes/IfNode.java b/src/ast/nodes/IfNode.java index f51d486..b0e1ddb 100644 --- a/src/ast/nodes/IfNode.java +++ b/src/ast/nodes/IfNode.java @@ -9,9 +9,10 @@ import semanticanalysis.SymbolTable; * Node for the `if` statement of the grammar. */ public class IfNode implements Node { - private Node guard; - private Node thenbranch; - private Node elsebranch; + + private final Node guard; + private final Node thenbranch; + private final Node elsebranch; public IfNode(Node guard, Node thenbranch, Node elsebranch) { this.guard = guard; @@ -21,7 +22,7 @@ public class IfNode implements Node { @Override public ArrayList checkSemantics(SymbolTable ST, int _nesting) { - ArrayList errors = new ArrayList(); + ArrayList errors = new ArrayList(); errors.addAll(guard.checkSemantics(ST, _nesting)); errors.addAll(thenbranch.checkSemantics(ST, _nesting)); @@ -38,9 +39,9 @@ public class IfNode implements Node { if (guard.typeCheck() instanceof BoolType) { Type thenexp = thenbranch.typeCheck(); Type elseexp = elsebranch.typeCheck(); - if (thenexp.getClass().equals(elseexp.getClass())) - return thenexp; - else { + if (thenexp.getClass().equals(elseexp.getClass())) { + return thenexp; + }else { System.out.println("Type Error: incompatible types in then and else branches."); return new ErrorType(); } -- cgit v1.2.3-18-g5258