Skip to content

Commit

Permalink
Clean up AddTopCellToRules
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltoli committed Oct 24, 2023
1 parent b6b2d96 commit 29c22a3
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions kernel/src/main/java/org/kframework/compile/AddTopCellToRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,14 @@
* Rules with the anywhere attribute are not modified.
*/
// TODO: rules defining functions shouldn't be wrapped
public class AddTopCellToRules {

private final ConfigurationInfo cfg;
private final LabelInfo labelInfo;

public AddTopCellToRules(ConfigurationInfo cfg, LabelInfo labelInfo) {
this.cfg = cfg;
this.labelInfo = labelInfo;
}
public record AddTopCellToRules(ConfigurationInfo cfg, LabelInfo labelInfo) {

public K addImplicitCells(K term, Module m) {
if (m.isFunction(term)) return term;
return addRootCell(term);
}

protected K addRootCell(K term) {
private K addRootCell(K term) {
KLabel root;
root = KLabels.GENERATED_TOP_CELL;

Expand Down Expand Up @@ -92,8 +84,7 @@ protected K addRootCell(K term) {
}

// KRewrite instance
if (term instanceof KRewrite) {
KRewrite rew = (KRewrite) term;
if (term instanceof KRewrite rew) {
K left = addRootCell(rew.left());
if (left == rew.left()) {
return KRewrite(rew.left(), rew.right());
Expand Down

0 comments on commit 29c22a3

Please sign in to comment.