default List<K> items() { return klist().items(); }
private Set<KApply> getOrContents(KApply k) { return KLabels.ML_OR.equals(k.klabel()) ? k.klist().items().stream().map(KApply.class::cast).collect(Collectors.toSet()) : Collections.singleton(k); }
public static boolean isOpenLeft(KApply cell) { return isOpen(cell.klist().items().get(0)); } public static boolean isOpenRight(KApply cell) {
public static boolean isOpenRight(KApply cell) { return isOpen(cell.klist().items().get(2)); }
public void applyKLabel(KApply k) { sb.append("KApply ("); apply(k.klabel()); sb.append(", "); apply(k.klist().items(), true); sb.append(")"); }
private void convertLHS(StringBuilder sb, RuleType type, K left, VarInfo vars) { Visitor visitor = convert(sb, false, vars, false, false); if (type == RuleType.ANYWHERE || type == RuleType.FUNCTION) { KApply kapp = (KApply) ((KSequence) left).items().get(0); sb.append("("); visitor.applyTuple(kapp.klist().items()); sb.append(")"); } else { visitor.apply(left); } }
@Override public Term transform(KItem kItem) { if (!KLabels.KREWRITE.equals(kItem.kLabel())) { return (Term) super.transform(kItem); } Term rhs = ((InnerRHSRewrite) kItem.klist().items().get(1)).theRHS[i]; if (rhs == null) { return (Term) ((Term) kItem.klist().items().get(0)).accept(this); } hasRewrite[0] = true; return rhs; } });
public scala.collection.Set<K> apply(KApply k) { if (k.klabel().name().equals("#RESTORE_CONFIGURATION")) return org.kframework.Collections.Set(k.klist().items().get(0)); else return super.apply(k); } }.apply(theNew).head();
private boolean hasCells(KApply k) { for (int i = 0; i < k.klist().size(); i++) { K item = k.klist().items().get(i); if (item instanceof KApply && ((KApply) item).klabel().name().equals("#cells")) { return true; } } return false; }
@Override public K apply(KVariable k) { if (varToTypedVar.containsKey(k)) { return varToTypedVar.get(k); } return super.apply(k); } }.apply(term);
private static void flattenCells(List<K> children, K item) { if (item instanceof KApply && KLabels.CELLS.equals(((KApply) item).klabel())) { for (K deeper : ((KApply) item).klist().items()) { flattenCells(children, deeper); } } else { children.add(item); } } public static List<K> flattenCells(K cells) {
private boolean isCellFragmentTest(KApply app) { if (app.klist().size() != 1) return false; K argument = app.klist().items().get(0); if (!(argument instanceof KVariable)) return false; VarInfo info = variables.get((KVariable)argument); if (info == null) return false; KLabel expectedPredicate = KLabel("is"+cfg.getCellSort(info.parentCell).toString()+"Fragment"); return app.klabel().equals(expectedPredicate); }
@Override public K apply(KApply k) { List<K> children = new ArrayList<>(); for (K child : k.klist().items()) { K res = apply(child); if (res instanceof KSequence) { children.add(res); } else { children.add(KSequence(res)); } } return KApply(k.klabel(), KList(children), k.att()); }
@Override public Term transform(KItem kItem) { if (!KLabels.KREWRITE.equals(kItem.kLabel())) { return (Term) super.transform(kItem); } return (Term) ((Term) kItem.klist().items().get(0)).accept(this); } });
@Override public K apply(KApply k) { if (k.klabel() instanceof KVariable && predicates.containsKey(k.klabel())) { return KApply(apply(k.klabel()), k.klist().items().stream().map(this::apply).collect(org.kframework.Collections.toList()), k.att()); } return super.apply(k); }
private Context upContext(K contents) { KApply ruleContents = (KApply) contents; List<K> items = ruleContents.klist().items(); switch (ruleContents.klabel().name()) { case "#ruleNoConditions": return Context(items.get(0), BooleanUtils.TRUE, ruleContents.att()); case "#ruleRequires": return Context(items.get(0), items.get(1), ruleContents.att()); default: throw KEMException.criticalError("Illegal context with ensures clause detected.", contents); } }
private boolean isHOLE(K k) { if (k instanceof KApply) { KApply kapp = (KApply) k; return kapp.klabel().name().startsWith("#SemanticCastTo") && kapp.klist().size() == 1 && isHOLEVar(kapp.klist().items().get(0)); } else { return isHOLEVar(k); } }
private static Att getCellPropertiesAsAtt(K k) { if (k instanceof KApply) { KApply kapp = (KApply) k; if (kapp.klabel().name().equals("#cellPropertyListTerminator")) { return Att(); } else if (kapp.klabel().name().equals("#cellPropertyList")) { if (kapp.klist().size() == 2) { Tuple2<String, String> attribute = getCellProperty(kapp.klist().items().get(0)); return Att().add(attribute._1(), attribute._2()).addAll(getCellPropertiesAsAtt(kapp.klist().items().get(1))); } } } throw KEMException.compilerError("Malformed cell properties", k); }
public static K flattenTerm(Module mod, KApply kapp) { List<K> items = new ArrayList<>(); Att att = mod.attributesFor().apply(KLabel(kapp.klabel().name())); if (att.contains("assoc") && att.contains("unit")) { items = Assoc.flatten(kapp.klabel(), kapp.klist().items(), KLabel(att.get("unit"))); } else { items = kapp.klist().items(); } return KApply(kapp.klabel(), KList(items), kapp.att()); }