Skip to content

Commit 605c1e5

Browse files
author
dwightguth
authored
Fix regression in java backend (runtimeverification#102)
* roll back using klabel key for map * add test for regression
1 parent 169807c commit 605c1e5

7 files changed

Lines changed: 46 additions & 9 deletions

File tree

java-backend/src/main/java/org/kframework/backend/java/compile/KOREtoBackendKIL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public Term KApply1(org.kframework.kore.KLabel klabel, org.kframework.kore.KList
152152
private Optional<KLabel> getAssocKLabelForUnit(KLabel klabel) {
153153
return definition.kLabelAttributes().entrySet().stream()
154154
.filter(e -> effectivelyAssocAttributes(e.getValue()) && e.getValue().get(Att.unit()).equals(klabel.name()))
155-
.map(e -> e.getKey())
155+
.map(e -> KORE.KLabel(e.getKey()))
156156
.findAny();
157157
}
158158

java-backend/src/main/java/org/kframework/backend/java/kil/Definition.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ private static class DefinitionData implements Serializable {
5353
public final Subsorts subsorts;
5454
public Map<String, DataStructureSort> dataStructureSorts;
5555
public final SetMultimap<String, SortSignature> signatures;
56-
public final ImmutableMap<org.kframework.kore.KLabel, Att> kLabelAttributes;
56+
public final ImmutableMap<String, Att> kLabelAttributes;
5757
public final Map<Sort, org.kframework.kore.KLabel> freshFunctionNames;
5858
public final Map<Sort, Sort> smtSortFlattening;
5959

6060
private DefinitionData(
6161
Subsorts subsorts,
6262
Map<String, DataStructureSort> dataStructureSorts,
6363
SetMultimap<String, SortSignature> signatures,
64-
ImmutableMap<org.kframework.kore.KLabel, Att> kLabelAttributes,
64+
ImmutableMap<String, Att> kLabelAttributes,
6565
Map<Sort, org.kframework.kore.KLabel> freshFunctionNames,
6666
Map<Sort, Sort> smtSortFlattening) {
6767
this.subsorts = subsorts;
@@ -119,9 +119,9 @@ public Definition(org.kframework.definition.Module module, KExceptionManager kem
119119
});
120120
});
121121

122-
ImmutableMap.Builder<org.kframework.kore.KLabel, Att> attributesBuilder = ImmutableMap.builder();
122+
ImmutableMap.Builder<String, Att> attributesBuilder = ImmutableMap.builder();
123123
JavaConversions.mapAsJavaMap(module.attributesFor()).entrySet().stream().forEach(e -> {
124-
attributesBuilder.put(e.getKey(), e.getValue());
124+
attributesBuilder.put(e.getKey().name(), e.getValue());
125125
});
126126

127127
definitionData = new DefinitionData(
@@ -346,12 +346,12 @@ public Set<SortSignature> signaturesOf(String label) {
346346
return definitionData.signatures.get(label);
347347
}
348348

349-
public Map<org.kframework.kore.KLabel, Att> kLabelAttributes() {
349+
public Map<String, Att> kLabelAttributes() {
350350
return definitionData.kLabelAttributes;
351351
}
352352

353353
public Att kLabelAttributesOf(org.kframework.kore.KLabel label) {
354-
return Optional.ofNullable(definitionData.kLabelAttributes.get(label)).orElse(Att.empty());
354+
return Optional.ofNullable(definitionData.kLabelAttributes.get(label.name())).orElse(Att.empty());
355355
}
356356

357357
public DataStructureSort dataStructureSortOf(Sort sort) {

java-backend/src/main/java/org/kframework/backend/java/symbolic/BuiltinFunction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.kframework.backend.java.util.ImpureFunctionException;
1010
import org.kframework.kil.Attribute;
1111
import org.kframework.kore.KLabel;
12+
import org.kframework.kore.KORE;
1213
import org.kframework.utils.errorsystem.KEMException;
1314
import org.kframework.utils.errorsystem.KExceptionManager;
1415

@@ -53,7 +54,7 @@ public BuiltinFunction(Definition definition, Map<String, MethodHandle> hookProv
5354
} catch (NoSuchMethodException | IllegalAccessException e) {
5455
throw KEMException.internalError("Failed to load partial evaluation hook implementation", e);
5556
}
56-
for (Map.Entry<KLabel, Att> entry : definition.kLabelAttributes().entrySet()) {
57+
for (Map.Entry<String, Att> entry : definition.kLabelAttributes().entrySet()) {
5758
String hookAttribute = entry.getValue().getOptional(Attribute.HOOK_KEY).orElse(null);
5859
if (hookAttribute != null) {
5960
/*
@@ -72,7 +73,7 @@ public BuiltinFunction(Definition definition, Map<String, MethodHandle> hookProv
7273
continue;
7374
}
7475

75-
table.put(KLabelConstant.of(entry.getKey(), definition), hookProvider.get(hookAttribute));
76+
table.put(KLabelConstant.of(KORE.KLabel(entry.getKey()), definition), hookProvider.get(hookAttribute));
7677
}
7778
}
7879
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
symbolicFoo
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<TEST>
2+
<s>
3+
false
4+
</s>
5+
<k>
6+
V0
7+
</k>
8+
</TEST>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DEF=test
2+
EXT=test
3+
TESTDIR=.
4+
KOMPILE_FLAGS=--backend java
5+
KRUN_FLAGS=-cSTRATEGY='^ F2B'
6+
7+
include ../../../include/ktest.mak
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2018 K Team. All Rights Reserved.
2+
module TEST
3+
imports DOMAINS
4+
imports STRATEGY
5+
imports BASIC-STRATEGY
6+
7+
configuration
8+
<TEST>
9+
<s/>
10+
<k> $PGM:Foo </k>
11+
</TEST>
12+
13+
syntax Foo ::= "symbolicFoo" [function]
14+
| "foo" | "bar"
15+
16+
rule <s> ~ S => . ... </s>
17+
rule symbolicFoo => ?X:Foo
18+
rule <k> foo => bar ... </k> [tag(F2B)]
19+
rule <k> bar => foo ... </k> [tag(B2F)]
20+
endmodule

0 commit comments

Comments
 (0)