mirror of
https://github.com/Z3Prover/z3
synced 2025-06-07 06:33:23 +00:00
Fixed .equals for AST, FuncDecl, and Sort, and AST.compareTo in Java
Fixes #143
This commit is contained in:
parent
5f755a5bd8
commit
1bad614646
3 changed files with 21 additions and 26 deletions
|
@ -22,10 +22,8 @@ import com.microsoft.z3.enumerations.Z3_ast_kind;
|
||||||
/**
|
/**
|
||||||
* The abstract syntax tree (AST) class.
|
* The abstract syntax tree (AST) class.
|
||||||
**/
|
**/
|
||||||
public class AST extends Z3Object
|
public class AST extends Z3Object implements Comparable
|
||||||
{
|
{
|
||||||
/* Overloaded operators are not translated. */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object comparison.
|
* Object comparison.
|
||||||
*
|
*
|
||||||
|
@ -35,7 +33,7 @@ public class AST extends Z3Object
|
||||||
{
|
{
|
||||||
AST casted = null;
|
AST casted = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
casted = AST.class.cast(o);
|
casted = AST.class.cast(o);
|
||||||
} catch (ClassCastException e)
|
} catch (ClassCastException e)
|
||||||
|
@ -43,8 +41,13 @@ public class AST extends Z3Object
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getNativeObject() == casted.getNativeObject();
|
return
|
||||||
}
|
(this == casted) ||
|
||||||
|
(this != null) &&
|
||||||
|
(casted != null) &&
|
||||||
|
(getContext().nCtx() == casted.getContext().nCtx()) &&
|
||||||
|
(Native.isEqAst(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object Comparison.
|
* Object Comparison.
|
||||||
|
|
|
@ -26,22 +26,6 @@ import com.microsoft.z3.enumerations.Z3_parameter_kind;
|
||||||
**/
|
**/
|
||||||
public class FuncDecl extends AST
|
public class FuncDecl extends AST
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Comparison operator.
|
|
||||||
*
|
|
||||||
* @return True if {@code a"/> and <paramref name="b} share the
|
|
||||||
* same context and are equal, false otherwise.
|
|
||||||
**/
|
|
||||||
/* Overloaded operators are not translated. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Comparison operator.
|
|
||||||
*
|
|
||||||
* @return True if {@code a"/> and <paramref name="b} do not
|
|
||||||
* share the same context or are not equal, false otherwise.
|
|
||||||
**/
|
|
||||||
/* Overloaded operators are not translated. */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object comparison.
|
* Object comparison.
|
||||||
**/
|
**/
|
||||||
|
@ -55,7 +39,12 @@ public class FuncDecl extends AST
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getNativeObject() == casted.getNativeObject();
|
return
|
||||||
|
(this == casted) ||
|
||||||
|
(this != null) &&
|
||||||
|
(casted != null) &&
|
||||||
|
(getContext().nCtx() == casted.getContext().nCtx()) &&
|
||||||
|
(Native.isEqFuncDecl(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,8 +25,6 @@ import com.microsoft.z3.enumerations.Z3_sort_kind;
|
||||||
**/
|
**/
|
||||||
public class Sort extends AST
|
public class Sort extends AST
|
||||||
{
|
{
|
||||||
/* Overloaded operators are not translated. */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equality operator for objects of type Sort.
|
* Equality operator for objects of type Sort.
|
||||||
* @param o
|
* @param o
|
||||||
|
@ -42,7 +40,12 @@ public class Sort extends AST
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getNativeObject() == casted.getNativeObject();
|
return
|
||||||
|
(this == casted) ||
|
||||||
|
(this != null) &&
|
||||||
|
(casted != null) &&
|
||||||
|
(getContext().nCtx() == casted.getContext().nCtx()) &&
|
||||||
|
(Native.isEqSort(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue