Commit d0608e92 authored by Dr. Michael Petter's avatar Dr. Michael Petter

assorted changes

parent d70298f0
......@@ -149,6 +149,7 @@ public class Procedure implements java.io.Serializable,Analyzable{
}
public void refreshStates(){
states=new HashSet<>();
transen = null;
collectStates(states, begin);
stateHash = fillHash(states);
}
......
......@@ -197,6 +197,14 @@ public class BinaryExpression implements Expression, java.io.Serializable{
if (!sign.equals(((BinaryExpression)o).sign)) return false;
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 29 * hash + left.hashCode();
hash = 29 * hash + right.hashCode();
hash = 29 * hash + sign.hashCode();
return hash;
}
@Override
public boolean hasArrayAccess() {
......
......@@ -179,6 +179,13 @@ public class FunctionCall implements Expression, java.io.Serializable{
if(it2.hasNext()) return false;
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 97 * hash + name.hashCode();
hash = 97 * hash + params.hashCode();
return hash;
}
private Type type;
/**
......
......@@ -127,6 +127,12 @@ public class IntegerConstant implements Expression, java.io.Serializable{
if (! (o instanceof IntegerConstant)) return false;
return (((IntegerConstant)o).value == value);
}
@Override
public int hashCode() {
int hash = 5;
hash = 59 * hash + this.value;
return hash;
}
@Override
public Type getType() {
......
......@@ -165,9 +165,32 @@ public class Operator implements java.io.Serializable { //java.io.Externalizable
return this.code==code;
}
public boolean equals(Operator op){
if (this.code == op.code ) return true;
return false;
if (this.code == op.code ) return true;
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = 29 * hash + this.code;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Operator other = (Operator) obj;
if (this.code != other.code) {
return false;
}
return true;
}
public String toString(){
return names[code];
......
......@@ -128,7 +128,12 @@ public class StringLiteral implements Expression, java.io.Serializable{
if (! (o instanceof StringLiteral)) return false;
return (((StringLiteral)o).value == value);
}
@Override
public int hashCode() {
int hash = 7;
hash = 79 * hash + value.hashCode();
return hash;
}
@Override
public Type getType() {
return new PointerTo(Char.create());
......
......@@ -146,6 +146,14 @@ public class UnaryExpression implements Expression, java.io.Serializable{
return e.equals(((UnaryExpression)o).e);
}
@Override
public int hashCode() {
int hash = 7;
hash = 23 * hash + e.hashCode();
hash = 23 * hash + sign.hashCode();
return hash;
}
@Override
public boolean hasArrayAccess() {
return e.hasArrayAccess();
......
......@@ -111,6 +111,29 @@ public class UnknownExpression implements Expression, java.io.Serializable{
public int getDegree(){
return -1;
}
@Override
public int hashCode() {
int hash = 3;
hash = 79 * hash + this.type.hashCode();
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final UnknownExpression other = (UnknownExpression) obj;
if (!this.type.equals(other.type)) {
return false;
}
return true;
}
}
......@@ -75,7 +75,7 @@ public class Variable implements Expression, Annotatable, java.io.Serializable{
*
*/
public int hashCode(){
return (new Integer(id)).hashCode();
return id;
}
/**
* check if two variables are equal
......
......@@ -18,13 +18,13 @@ import petter.cfg.expression.visitors.NoVal;
*/
public interface SyntheticComputationDFS<up> extends PropagatingDFS<up, NoVal>{
@Override public default Optional<NoVal> preVisit(BinaryExpression s, NoVal fromParent) { return Optional.empty(); }
@Override public default Optional<NoVal> preVisit(FunctionCall s, NoVal fromParent) { return Optional.empty(); }
@Override public default Optional<NoVal> preVisit(IntegerConstant s, NoVal fromParent) { return Optional.empty(); }
@Override public default Optional<NoVal> preVisit(StringLiteral s, NoVal fromParent) { return Optional.empty(); }
@Override public default Optional<NoVal> preVisit(UnaryExpression s, NoVal fromParent) { return Optional.empty(); }
@Override public default Optional<NoVal> preVisit(UnknownExpression s, NoVal fromParent) { return Optional.empty(); }
@Override public default Optional<NoVal> preVisit(Variable s, NoVal fromParent) { return Optional.empty(); }
@Override public default Optional<NoVal> preVisit(BinaryExpression s, NoVal fromParent) { return Optional.of(new NoVal()); }
@Override public default Optional<NoVal> preVisit(FunctionCall s, NoVal fromParent) { return Optional.of(new NoVal()); }
@Override public default Optional<NoVal> preVisit(IntegerConstant s, NoVal fromParent) { return Optional.of(new NoVal()); }
@Override public default Optional<NoVal> preVisit(StringLiteral s, NoVal fromParent) { return Optional.of(new NoVal()); }
@Override public default Optional<NoVal> preVisit(UnaryExpression s, NoVal fromParent) { return Optional.of(new NoVal()); }
@Override public default Optional<NoVal> preVisit(UnknownExpression s, NoVal fromParent) { return Optional.of(new NoVal()); }
@Override public default Optional<NoVal> preVisit(Variable s, NoVal fromParent) { return Optional.of(new NoVal()); }
@Override public default up postVisit(IntegerConstant s, NoVal fromTop) { return postVisit(s); }
@Override public default up postVisit(StringLiteral s, NoVal fromTop) { return postVisit(s); }
@Override public default up postVisit(UnknownExpression s, NoVal fromParent) { return postVisit(s); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment