Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import liquidjava.processor.refinement_checker.object_checkers.AuxHierarchyRefinementsPassage;
import liquidjava.processor.refinement_checker.object_checkers.AuxStateHandler;
import liquidjava.rj_language.Predicate;
import liquidjava.utils.GeneratedNames;
import liquidjava.utils.Utils;
import liquidjava.utils.constants.Formats;
import liquidjava.utils.constants.Keys;
Expand Down Expand Up @@ -330,7 +331,7 @@ private boolean tryRefinements(CtInvocation<?> invocation, String key, String ct
return true;
}

private Map<String, String> checkInvocationRefinements(CtElement invocation, List<CtExpression<?>> arguments,
private Map<String, String> checkInvocationRefinements(CtExpression<?> invocation, List<CtExpression<?>> arguments,
CtExpression<?> target, String methodName, String className, List<CtTypeReference<?>> paramTypes)
throws LJError {
// -- Part 1: Check if the invocation is possible
Expand Down Expand Up @@ -373,11 +374,11 @@ private Map<String, String> checkInvocationRefinements(CtElement invocation, Lis
* matches the post-call VariableInstance. Returns {@code null} for void methods. When the function has no
* refinements to check, the (empty) instance is registered eagerly.
*/
private String prepareReturnInstance(CtElement invocation, RefinedFunction f) {
private String prepareReturnInstance(CtExpression<?> invocation, RefinedFunction f) {
CtTypeReference<?> retType = f.getType();
if (retType == null || "void".equals(retType.toString()))
return null;
String returnViName = String.format(Formats.INSTANCE, f.getName(), rtc.getContext().getCounter());
String returnViName = GeneratedNames.valueOf(invocation, rtc.getContext().getCounter());
invocation.putMetadata(Keys.RETURN_VAR_NAME, returnViName);
if (f.allRefinementsTrue())
rtc.getContext().addInstanceToContext(returnViName, retType, new Predicate(), invocation);
Expand All @@ -388,7 +389,7 @@ private String prepareReturnInstance(CtElement invocation, RefinedFunction f) {
* Part 2 of an invocation check: applies the function's return refinement to the context, substituting argument and
* target variables and registering the resulting return-value instance.
*/
private void applyReturnRefinement(CtElement invocation, RefinedFunction f, Map<String, String> map,
private void applyReturnRefinement(CtExpression<?> invocation, RefinedFunction f, Map<String, String> map,
String returnViName) {
Predicate methodRef = f.getRefReturn();
if (methodRef == null)
Expand All @@ -410,7 +411,7 @@ private void applyReturnRefinement(CtElement invocation, RefinedFunction f, Map<
}

String viName = returnViName != null ? returnViName
: String.format(Formats.INSTANCE, f.getName(), rtc.getContext().getCounter());
: GeneratedNames.valueOf(invocation, rtc.getContext().getCounter());
VariableInstance vi = (VariableInstance) rtc.getContext().addInstanceToContext(viName, f.getType(),
methodRef.substituteVariable(Keys.WILDCARD, viName), invocation); // TODO REVIEW!!
if (varName != null && f.hasStateChange() && equalsThis)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ void namesEachGeneratedValueAfterWhatItIs() {
Map<Integer, String> messages = Diagnostics.getInstance().getErrors().stream().collect(Collectors.toMap(
error -> error.getPosition().getLine(), error -> error.getMessage().replaceAll("[⁰¹²³⁴⁵⁶⁷⁸⁹]", "")));

assertEquals(Map.of(25, "#if_condition == ready && #if_condition is not a subtype of a > 0", 30,
"#loop_condition == ready && #loop_condition == true is not a subtype of a > 0", 34,
"#ternary_condition == ready && #ternary_condition == true is not a subtype of a < 0", 43,
assertEquals(Map.of(25, "#if_condition == #ready_result && #if_condition is not a subtype of a > 0", 30,
"#loop_condition == #ready_result && #loop_condition == true is not a subtype of a > 0", 34,
"#ternary_condition == #ready_result && #ternary_condition == true is not a subtype of a < 0", 43,
"!#try_branch && !#catch_branch is not a subtype of a > 0", 48,
"x == #read_result - 1 is not a subtype of x > 0", 54,
"#if_condition == #operation_result && #if_condition && x == 0 is not a subtype of x > 0", 58,
Expand Down
Loading