Skip to content

Commit

Permalink
Use expression lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltoli committed Nov 1, 2023
1 parent c523139 commit 4214d7c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,15 @@ K addSideCondition(K requires, boolean macro) {
Optional<KApply> sideCondition =
casts.stream()
.map(
k -> {
return new TransformK() {
@Override
public K apply(KVariable k) {
if (varToTypedVar.containsKey(k)) {
return varToTypedVar.get(k);
}
return k;
k -> new TransformK() {
@Override
public K apply(KVariable k) {
if (varToTypedVar.containsKey(k)) {
return varToTypedVar.get(k);
}
}.apply(k);
})
return k;
}
}.apply(k))
.map(k -> KApply(KLabel("is" + getSortNameOfCast((KApply) k)), transform(k)))
.reduce(BooleanUtils::and);
if (!sideCondition.isPresent()) {
Expand Down
4 changes: 1 addition & 3 deletions kernel/src/main/java/org/kframework/compile/SortInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public static SortInfo fromModule(Module module) {
joinOps
.asMap()
.forEach(
(sort, labels) -> {
info.closeOperators.put(sort, Iterators.getNext(labels.iterator(), null));
});
(sort, labels) -> info.closeOperators.put(sort, Iterators.getNext(labels.iterator(), null)));
return info;
}
}
4 changes: 1 addition & 3 deletions kernel/src/main/java/org/kframework/kdep/KDepFrontEnd.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ protected int run() {
List<File> sortedFiles = new ArrayList<File>(allFiles);
Collections.sort(
sortedFiles,
(File a, File b) -> {
return a.getAbsolutePath().compareTo(b.getAbsolutePath());
});
(File a, File b) -> a.getAbsolutePath().compareTo(b.getAbsolutePath()));

for (File file : sortedFiles) {
System.out.println(" " + file.getAbsolutePath() + " \\");
Expand Down
56 changes: 27 additions & 29 deletions kernel/src/main/java/org/kframework/kompile/CompiledDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,39 +116,37 @@ private void initializeConfigurationVariableDefaultSorts(FileUtil files) {
// searching for #SemanticCastTo<Sort>(Map:lookup(_, #token(<VarName>, KConfigVar)))
Collections.stream(kompiledDefinition.mainModule().rules())
.forEach(
r -> {
new VisitK() {
@Override
public void apply(KApply k) {
if (k.klabel().name().startsWith("project:")
&& k.items().size() == 1
&& k.items().get(0) instanceof KApply theMapLookup) {
if (KLabels.MAP_LOOKUP.equals(theMapLookup.klabel())
&& theMapLookup.size() == 2
&& theMapLookup.items().get(1) instanceof KToken t) {
if (t.sort().equals(Sorts.KConfigVar())) {
Sort sort =
Outer.parseSort(k.klabel().name().substring("project:".length()));
configurationVariableDefaultSorts.put(t.s(), sort);
if (sort.equals(Sorts.K())) {
sort = Sorts.KItem();
}
String str =
"declaredConfigVar_"
+ t.s().substring(1)
+ "='"
+ sort.toString()
+ "'\n";
sb.append(str);
String astr = " '" + t.s().substring(1) + "'\n";
arr.append(astr);
r -> new VisitK() {
@Override
public void apply(KApply k) {
if (k.klabel().name().startsWith("project:")
&& k.items().size() == 1
&& k.items().get(0) instanceof KApply theMapLookup) {
if (KLabels.MAP_LOOKUP.equals(theMapLookup.klabel())
&& theMapLookup.size() == 2
&& theMapLookup.items().get(1) instanceof KToken t) {
if (t.sort().equals(Sorts.KConfigVar())) {
Sort sort =
Outer.parseSort(k.klabel().name().substring("project:".length()));
configurationVariableDefaultSorts.put(t.s(), sort);
if (sort.equals(Sorts.K())) {
sort = Sorts.KItem();
}
String str =
"declaredConfigVar_"
+ t.s().substring(1)
+ "='"
+ sort.toString()
+ "'\n";
sb.append(str);
String astr = " '" + t.s().substring(1) + "'\n";
arr.append(astr);
}
}
super.apply(k);
}
}.apply(r.body());
});
super.apply(k);
}
}.apply(r.body()));
sb.append(arr);
sb.append(")\n");

Expand Down

0 comments on commit 4214d7c

Please sign in to comment.