Skip to content

Commit

Permalink
Clean up casts
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltoli committed Nov 8, 2023
1 parent b132c0e commit 6d60c09
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions kernel/src/main/java/org/kframework/compile/ResolveFun.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ public K apply(KApply k) {
body = k.items().get(0);
arg = k.items().get(1);
}
if (arg instanceof KVariable) {
nameHint1 = ((KVariable) arg).name();
} else if (arg instanceof KApply
&& ((KApply) arg).klabel().name().startsWith("#SemanticCastTo")
&& ((KApply) arg).items().get(0) instanceof KVariable) {
nameHint1 = ((KVariable) ((KApply) arg).items().get(0)).name();
if (arg instanceof KVariable var) {
nameHint1 = var.name();
} else if (arg instanceof KApply app
&& app.klabel().name().startsWith("#SemanticCastTo")
&& app.items().get(0) instanceof KVariable) {
nameHint1 = ((KVariable) app.items().get(0)).name();
}
if (body instanceof KApply) {
nameHint2 = ((KApply) body).klabel().name();
Expand Down Expand Up @@ -151,7 +151,7 @@ private boolean isLHSTotal(K lhs) {
} else if (lhs instanceof KApply app) {
return app.klabel().name().startsWith("#SemanticCastTo")
&& app.items().size() == 1
&& isLHSTotal(app.items().get(0));
&& app.items().get(0) instanceof KVariable;
}

return false;
Expand Down Expand Up @@ -230,9 +230,9 @@ private Production lambdaProd(KLabel fun, K k, Sort arg, Sort rhs, Att att) {

private Sort sort(K k) {
if (k instanceof KSequence) return Sorts.K();
if (k instanceof KAs) return sort(((KAs) k).pattern());
if (k instanceof KAs as) return sort(as.pattern());
if (k instanceof InjectedKLabel) return Sorts.KItem();
if (k instanceof KToken) return ((KToken) k).sort();
if (k instanceof KToken token) return token.sort();
if (k instanceof KApply) {
return inj.sort(k, Sorts.K());
}
Expand All @@ -250,12 +250,12 @@ private ContextAlias resolve(ContextAlias context) {
}

public Sentence resolve(Sentence s) {
if (s instanceof Rule) {
return resolve((Rule) s);
} else if (s instanceof Context) {
return resolve((Context) s);
} else if (s instanceof ContextAlias) {
return resolve((ContextAlias) s);
if (s instanceof Rule r) {
return resolve(r);
} else if (s instanceof Context c) {
return resolve(c);
} else if (s instanceof ContextAlias ca) {
return resolve(ca);
} else {
return s;
}
Expand Down

0 comments on commit 6d60c09

Please sign in to comment.