for (int partition = 0; partition < partitionsToBeReassigned.size(); partition++) { bldr.append(" {\"topic\":\"").append(topic).append("\",\"partition\":").append(partition).append(",\"replicas\":["); scala.collection.Seq<Object> replicas = partitionsToBeReassigned.apply(partition); for (int replicaIndex = 0; replicaIndex < replicas.size(); replicaIndex++) { Object replica = replicas.apply(replicaIndex);
private int getArity(KLabel functionLabel) { Set<Integer> arities = stream(mainModule.productionsFor().apply(functionLabel)).map(Production::arity).collect(Collectors.toSet()); if (arities.size() > 1) { throw KEMException.compilerError("KLabel " + functionLabel + " has multiple productions with differing arities: " + mainModule.productionsFor().apply(functionLabel)); } assert arities.size() == 1; return arities.iterator().next(); }
private void applyVarRhs(String varOccurrance, StringBuilder sb, KLabel listVar) { if (listVar != null) { sb.append("(List ("); encodeStringToIdentifier(sb, mainModule.sortFor().apply(listVar)); sb.append(", "); encodeStringToIdentifier(sb, listVar); sb.append(", "); sb.append(varOccurrance); sb.append("))"); } else { sb.append(varOccurrance); } }
private void applyVarLhs(KVariable k, StringBuilder sb, VarInfo vars) { String varName = encodeStringToVariable(k.name()); vars.vars.put(k, varName); Sort s = k.att().getOptional(Sort.class).orElse(Sort("")); if (mainModule.sortAttributesFor().contains(s)) { String hook = mainModule.sortAttributesFor().apply(s).<String>getOptional("hook").orElse(""); if (sortVarHooks.containsKey(hook)) { sb.append("("); sb.append(sortVarHooks.get(hook).apply(s)); sb.append(" as ").append(varName).append(")"); return; } } sb.append(varName); }
private void forEachKLabel(Consumer<Tuple2<KLabel, Long>> action) { for (KLabel label : iterable(mainModule.definedKLabels())) { if (ConvertDataStructureToLookup.isLookupKLabel(label) || label.name().equals("#KToken")) continue; stream(mainModule.productionsFor().apply(label)).map(p -> Tuple2.apply(p.klabel().get(), stream(p.items()).filter(pi -> pi instanceof NonTerminal).count())).distinct().forEach(action); } }
private KLabel getWrapElement(KLabel collectionLabel) { return KLabel(m.attributesFor().apply(collectionLabel).get("wrapElement")); }
private KLabel getWrapElement(KLabel collectionLabel) { return KLabel(m.attributesFor().apply(collectionLabel).get("wrapElement")); }
@Override public Optional<KApply> apply(KApply k) { if (k.klabel() instanceof KVariable) { return super.apply(k); } if (m.attributesFor().apply(k.klabel()).contains("thread")) { return Optional.of(k); } return super.apply(k); }
private Either<Set<ParseFailedException>, Term> wrapTermWithCast(Constant c, Sort declared) { Production cast; if (addCast) { cast = productions.apply(KLabel("#SemanticCastTo" + declared.toString())).head(); } else if (inferCasts && !hasCastAlready && productions.contains(KLabel("#SyntacticCast"))) { cast = stream(productions.apply(KLabel("#SyntacticCast"))).filter(p -> p.sort().equals(declared)).findAny().get(); } else { cast = null; } if (cast == null) { return Right.apply(c); } else { return Right.apply(TermCons.apply(ConsPStack.singleton(c), cast, c.location(), c.source())); } }
private boolean isUnit(K item, boolean klist, boolean rhs, VarInfo vars, boolean anywhereRule) { return isList(item, klist, rhs, vars, anywhereRule) && item instanceof KApply && !(((KApply)item).klabel() instanceof KVariable) && mainModule.attributesFor().apply(((KApply)item).klabel()).contains("returnsUnit"); }
private Production production(KApply term) { scala.collection.Set<Production> prods = mod.productionsFor().apply(((KApply) term).klabel()); if (prods.size() != 1) { throw KEMException.compilerError("Could not find production for KApply with label " + term.klabel(), term); } return prods.head(); }
@Override public K apply(KApply k) { if (m.attributesFor().apply(k.klabel()).contains("thread")) { return KApply(k.klabel(), KApply(KLabel("#ThreadLocal"))); } return super.apply(k); } }.apply(body);
private boolean isConstructorLike(KLabel klabel) { String labelName = klabel.name(); if (isInjectionLabel(labelName) || isBuiltinModuloConstructor(klabel)) return true; Set<Production> productionSet = module.productionsFor().apply(klabel); assert productionSet.size() == 1 : "Should not have more than one production"; Production production = productionSet.head(); return !production.att().contains(Att.Function()); }
private Production production(KApply term) { if (term.klabel().name().equals(KLabels.INJ)) return Production(INJ_PROD.klabel(), INJ_PROD.sort(), INJ_PROD.items(), Att.empty().add("originalPrd", Production.class, INJ_PROD)); scala.collection.Set<Production> prods = module.productionsFor().apply(((KApply) term).klabel()); assert(prods.size() == 1); return computePolyProd(prods.head()); }
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()); }
private static Sentence markRegularRules(Definition d, ConfigurationInfoFromModule configInfo, Sentence s, String att) { if (s instanceof org.kframework.definition.Rule) { org.kframework.definition.Rule r = (org.kframework.definition.Rule) s; if (r.body() instanceof KApply) { KLabel klabel = ((KApply) r.body()).klabel(); if (d.mainModule().sortFor().contains(klabel) //is false for rules in specification modules not part of semantics && d.mainModule().sortFor().apply(klabel).equals(configInfo.topCell())) { return Rule.apply(r.body(), r.requires(), r.ensures(), r.att().add(att)); } } } return s; }