-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(logic): abstract domain interface
Require all abstract domain elements to implement the AbstractValue interface.
- Loading branch information
Showing
41 changed files
with
255 additions
and
192 deletions.
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
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
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
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
27 changes: 5 additions & 22 deletions
27
subprojects/logic/src/main/java/tools/refinery/logic/AbstractDomain.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 |
---|---|---|
@@ -1,37 +1,20 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | ||
* SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/> | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package tools.refinery.logic; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
public non-sealed interface AbstractDomain<A, C> extends AnyAbstractDomain { | ||
public non-sealed interface AbstractDomain<A extends AbstractValue<A, C>, C> extends AnyAbstractDomain { | ||
@Override | ||
Class<A> abstractType(); | ||
|
||
@Override | ||
Class<C> concreteType(); | ||
|
||
A toAbstract(C concreteValue); | ||
|
||
Optional<C> toConcrete(A abstractValue); | ||
|
||
default boolean isConcrete(A abstractValue) { | ||
return toConcrete(abstractValue).isPresent(); | ||
} | ||
|
||
default boolean isRefinement(A originalValue, A refinedValue) { | ||
return Objects.equals(commonRefinement(originalValue, refinedValue), refinedValue); | ||
} | ||
|
||
A commonRefinement(A leftValue, A rightValue); | ||
|
||
A commonAncestor(A leftValue, A rightValue); | ||
|
||
A unknown(); | ||
|
||
boolean isError(A abstractValue); | ||
A error(); | ||
|
||
A toAbstract(C concreteValue); | ||
} |
32 changes: 32 additions & 0 deletions
32
subprojects/logic/src/main/java/tools/refinery/logic/AbstractValue.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,32 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 The Refinery Authors <https://refinery.tools/> | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package tools.refinery.logic; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface AbstractValue<A extends AbstractValue<A, C>, C> { | ||
@Nullable | ||
C getConcrete(); | ||
|
||
default boolean isConcrete() { | ||
return getConcrete() == null; | ||
} | ||
|
||
@Nullable | ||
C getArbitrary(); | ||
|
||
default boolean isError() { | ||
return getArbitrary() == null; | ||
} | ||
|
||
A join(A other); | ||
|
||
A meet(A other); | ||
|
||
default boolean isRefinementOf(A other) { | ||
return equals(meet(other)); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.