Add Print statements to AST equals Methods
This commit is contained in:
parent
8e0b215140
commit
21ece58cc9
@ -3,6 +3,8 @@ package abstractSyntaxTree.Expression;
|
||||
import abstractSyntaxTree.Node;
|
||||
import abstractSyntaxTree.StatementExpression.NewStatementExpression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SubReceiver implements Node {
|
||||
boolean thisExpression;
|
||||
public NewStatementExpression newStatementExpression;
|
||||
@ -19,4 +21,16 @@ public class SubReceiver implements Node {
|
||||
public SubReceiver(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SubReceiver subReceiver = (SubReceiver) o;
|
||||
boolean result = (Objects.equals(thisExpression, subReceiver.thisExpression)
|
||||
);
|
||||
System.out.println("In SubReceiver: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -77,9 +77,12 @@ public class UnaryExpression extends AbstractType implements IExpression{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
UnaryExpression unaryExpression = (UnaryExpression) o;
|
||||
return (Objects.equals(operator, unaryExpression.operator)
|
||||
boolean result = (Objects.equals(operator, unaryExpression.operator)
|
||||
&& Objects.equals(operand, unaryExpression.operand)
|
||||
);
|
||||
System.out.println("In UnaryExpression: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,8 +19,11 @@ public class Parameter implements Node {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Parameter parameter = (Parameter) o;
|
||||
return (Objects.equals(type, parameter.type)
|
||||
boolean result = (Objects.equals(type, parameter.type)
|
||||
&& Objects.equals(identifier, parameter.identifier)
|
||||
);
|
||||
System.out.println("In Parameter: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,10 @@ public class ParameterList implements Node {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ParameterList parameterListObj = (ParameterList) o;
|
||||
return (Objects.equals(parameterList, parameterListObj.parameterList)
|
||||
boolean result = (Objects.equals(parameterList, parameterListObj.parameterList)
|
||||
);
|
||||
System.out.println("In ParameterList: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -129,10 +129,13 @@ public class BlockStatement extends AbstractType implements IStatement {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
BlockStatement blockStatement = (BlockStatement) o;
|
||||
return (Objects.equals(localVars, blockStatement.localVars)
|
||||
boolean result = (Objects.equals(localVars, blockStatement.localVars)
|
||||
&& Objects.equals(returnType, blockStatement.returnType)
|
||||
&& Objects.equals(statements, blockStatement.statements)
|
||||
);
|
||||
System.out.println("In ParameterList: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,13 +24,16 @@ public class EmptyStatement extends AbstractType implements IStatement{
|
||||
//An empty statement does not generate any code
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeCheckResult getTypeCheckResult() {
|
||||
return super.getTypeCheckResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -82,10 +82,13 @@ public class IfElseStatement extends AbstractType implements IStatement{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
IfElseStatement ifElseStatement = (IfElseStatement) o;
|
||||
return (Objects.equals(condition, ifElseStatement.condition)
|
||||
boolean result = (Objects.equals(condition, ifElseStatement.condition)
|
||||
&& Objects.equals(ifStatement, ifElseStatement.ifStatement)
|
||||
&& Objects.equals(elseStatement, ifElseStatement.elseStatement)
|
||||
);
|
||||
System.out.println("In PrintStatement: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,9 +62,12 @@ public class IfStatement extends AbstractType implements IStatement{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
IfStatement ifStatementObj = (IfStatement) o;
|
||||
return (Objects.equals(condition, ifStatementObj.condition)
|
||||
boolean result = (Objects.equals(condition, ifStatementObj.condition)
|
||||
&& Objects.equals(ifStatement, ifStatementObj.ifStatement)
|
||||
);
|
||||
System.out.println("In IfStatement: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,9 +102,12 @@ public class LocalVarDecl extends AbstractType implements IStatement{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
LocalVarDecl localVarDecl = (LocalVarDecl) o;
|
||||
return (Objects.equals(type, localVarDecl.type)
|
||||
boolean result = (Objects.equals(type, localVarDecl.type)
|
||||
&& Objects.equals(identifier, localVarDecl.identifier)
|
||||
);
|
||||
System.out.println("In LocalVarDecl: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,6 +15,18 @@ public class PrintStatement extends AbstractType implements IStatement {
|
||||
String variableName;
|
||||
public String thisClass;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PrintStatement printStatement = (PrintStatement) o;
|
||||
boolean result = (Objects.equals(variableName, printStatement.variableName)
|
||||
);
|
||||
System.out.println("In PrintStatement: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public PrintStatement(String variableName) {
|
||||
this.variableName = variableName;
|
||||
}
|
||||
|
@ -60,8 +60,11 @@ public class ReturnStatement extends AbstractType implements IStatement{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ReturnStatement returnStatement = (ReturnStatement) o;
|
||||
return (Objects.equals(expression, returnStatement.expression)
|
||||
boolean result = (Objects.equals(expression, returnStatement.expression)
|
||||
);
|
||||
System.out.println("In PrintStatement: " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,9 +67,13 @@ public class WhileStatement extends AbstractType implements IStatement {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
WhileStatement whileStatement = (WhileStatement) o;
|
||||
return (Objects.equals(condition, whileStatement.condition)
|
||||
boolean result = (Objects.equals(condition, whileStatement.condition)
|
||||
&& Objects.equals(statement, whileStatement.statement)
|
||||
);
|
||||
System.out.println("In PrintStatement: " + result);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user