forked from KeYProject/key
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from tobias-rnh/taclet-pbuilder
SemiSequent and EqualsModProperty
- Loading branch information
Showing
8 changed files
with
877 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
keyext.rusty_while/src/main/java/org/key_project/rusty/logic/FormulaChangeInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.key_project.rusty.logic; | ||
|
||
public record FormulaChangeInfo(PosInOccurrence positionOfModification, SequentFormula newFormula) { | ||
|
||
public SequentFormula getOriginalFormula() { | ||
return positionOfModification().sequentFormula(); | ||
} | ||
|
||
/** | ||
* @return position within the original formula | ||
*/ | ||
@Override | ||
public PosInOccurrence positionOfModification() { | ||
return positionOfModification; | ||
} | ||
|
||
public String toString() { | ||
return "Replaced " + positionOfModification + " with " + newFormula; | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
keyext.rusty_while/src/main/java/org/key_project/rusty/logic/NameAbstractionTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.key_project.rusty.logic; | ||
|
||
import org.key_project.rusty.ast.RustyProgramElement; | ||
|
||
import java.util.Iterator; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
public class NameAbstractionTable { | ||
|
||
/** | ||
* The order in which symbols are declared in the two terms or programs that are compared. The | ||
* latest declaration of a symbol will be the first matching entry in the list | ||
*/ | ||
private List<RustyProgramElement> declarations0 = null, declarations1 = null; | ||
|
||
/** | ||
* adds the given two elements to the table | ||
* | ||
* @param pe1 RustyProgramElement to be added | ||
* @param pe2 RustyProgramElement to be added | ||
*/ | ||
public void add(RustyProgramElement pe1, RustyProgramElement pe2) { | ||
if (declarations0 == null) { | ||
declarations0 = new LinkedList<>(); | ||
declarations1 = new LinkedList<>(); | ||
} | ||
|
||
declarations0.add(0, pe1); | ||
declarations1.add(0, pe2); | ||
} | ||
|
||
/** | ||
* tests if the given elements have been assigned to the same abstract name. | ||
* | ||
* @param pe0 RustyProgramElement | ||
* @param pe1 RustyProgramElement | ||
* @returns true if the pe1 and pe2 have been assigned to the same name | ||
*/ | ||
public boolean sameAbstractName(RustyProgramElement pe0, RustyProgramElement pe1) { | ||
if (declarations0 != null) { | ||
final Iterator<RustyProgramElement> it0 = declarations0.iterator(); | ||
final Iterator<RustyProgramElement> it1 = declarations1.iterator(); | ||
|
||
while (it0.hasNext()) { | ||
// both lists are assumed to hold the same number of elements | ||
final Object o0 = it0.next(); | ||
final Object o1 = it1.next(); | ||
|
||
if (pe0.equals(o0)) { | ||
return pe1.equals(o1); | ||
} else if (pe1.equals(o1)) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return pe0.equals(pe1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
keyext.rusty_while/src/main/java/org/key_project/rusty/logic/equality/EqualsModProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.key_project.rusty.logic.equality; | ||
|
||
public interface EqualsModProperty<T> { | ||
<V> boolean equalsModProperty(Object o, Property<T> property, V... v); | ||
|
||
/** | ||
* Computes the hash code according to the given ignored {@code property}. | ||
* | ||
* @param property the ignored property according to which the hash code is computed | ||
* @return the hash code of this object | ||
*/ | ||
int hashCodeModProperty(Property<T> property); | ||
} |
24 changes: 24 additions & 0 deletions
24
keyext.rusty_while/src/main/java/org/key_project/rusty/logic/equality/Property.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.key_project.rusty.logic.equality; | ||
|
||
public interface Property<T> { | ||
/** | ||
* Checks {@code t1} and {@code t2} for equality ignoring a certain property. | ||
* | ||
* @param t1 the first element of the equality check | ||
* @param t2 the second element of the equality check | ||
* @param v the additional arguments needed for the equality check | ||
* @return whether {@code t1} and {@code t2} are equal ignoring a certain property | ||
* @param <V> the type of the additional parameters needed for the comparison | ||
*/ | ||
<V> boolean equalsModThisProperty(T t1, T t2, V... v); | ||
|
||
/** | ||
* Computes the hash code of {@code t} in a context where | ||
* {@link this#equalsModThisProperty(Object, Object, Object[])} | ||
* is used as an equality check, so that it can be used in, e.g., a HashMap. | ||
* | ||
* @param t the object to compute the hash code for | ||
* @return the hash code of {@code t} ignoring a certain property | ||
*/ | ||
int hashCodeModThisProperty(T t); | ||
} |
Oops, something went wrong.