public static String getKompiledString(Module mainModule, KLabel topCellInitializer, FileUtil files, boolean heatCoolEquations) { mainModule = new GenerateSortPredicateRules(true).gen(mainModule); mainModule = ModuleTransformer.fromKTransformer(new AddSortInjections(mainModule)::addInjections, "Add sort injections").apply(mainModule); mainModule = ModuleTransformer.fromSentenceTransformer(new MinimizeTermConstruction(mainModule)::resolve, "Minimize term construction").apply(mainModule); ModuleToKORE moduleToKORE = new ModuleToKORE(mainModule, files, topCellInitializer); String kompiledString = moduleToKORE.convert(heatCoolEquations); Properties koreToKLabels = new Properties(); koreToKLabels.putAll(moduleToKORE.getKToKoreLabelMap().inverse()); try { FileOutputStream output = new FileOutputStream(files.resolveKompiled("kore_to_k_labels.properties")); koreToKLabels.store(output, "Properties file containing the mapping from kore to k labels"); } catch (IOException e) { throw KEMException.criticalError("Error while saving kore to K labels map", e); } return kompiledString; }
public static Module transformModule(Module mod) { ConfigurationInfoFromModule configInfo = new ConfigurationInfoFromModule(mod); LabelInfo labelInfo = new LabelInfoFromModule(mod); return ModuleTransformer.fromSentenceTransformer( new AddImplicitComputationCell(configInfo, labelInfo), "concretizing configuration").apply(mod); }
private static Module markRegularRules(Definition d, Module mod) { ConfigurationInfoFromModule configInfo = new ConfigurationInfoFromModule(d.mainModule()); return ModuleTransformer.fromSentenceTransformer(s -> markRegularRules(d, configInfo, s, "specification"), "mark regular rules").apply(mod); }
private static Module spliceModule(Module specModule, Definition kompiledDefinition) { return ModuleTransformer.from(mod -> kompiledDefinition.getModule(mod.name()).isDefined() ? kompiledDefinition.getModule(mod.name()).get() : mod, "splice imports of specification module").apply(specModule); } }
public static Module transformModule(Module mod) { ConfigurationInfoFromModule configInfo = new ConfigurationInfoFromModule(mod); LabelInfo labelInfo = new LabelInfoFromModule(mod); SortInfo sortInfo = SortInfo.fromModule(mod); return ModuleTransformer.fromSentenceTransformer( new ConcretizeCells(configInfo, labelInfo, sortInfo, mod)::concretize, "concretizing configuration").apply(mod); }
}, "apply program parsing modules").apply(mod);
@Override public Function<Module, Module> specificationSteps(Definition def) { Module mod = def.mainModule(); ConfigurationInfoFromModule configInfo = new ConfigurationInfoFromModule(mod); LabelInfo labelInfo = new LabelInfoFromModule(mod); SortInfo sortInfo = SortInfo.fromModule(mod); ModuleTransformer resolveAnonVars = ModuleTransformer.fromSentenceTransformer( new ResolveAnonVar()::resolve, "resolving \"_\" vars"); ModuleTransformer resolveSemanticCasts = ModuleTransformer.fromSentenceTransformer( new ResolveSemanticCasts(true)::resolve, "resolving semantic casts"); ModuleTransformer subsortKItem = ModuleTransformer.from(Kompile::subsortKItem, "subsort all sorts to KItem"); ModuleTransformer addImplicitComputationCell = ModuleTransformer.fromSentenceTransformer( new AddImplicitComputationCell(configInfo, labelInfo), "concretizing configuration"); Function1<Module, Module> resolveFreshConstants = d -> ModuleTransformer.from(new ResolveFreshConstants(def, true)::resolve, "resolving !Var variables").apply(d); ModuleTransformer concretizeCells = ModuleTransformer.fromSentenceTransformer( new ConcretizeCells(configInfo, labelInfo, sortInfo, mod)::concretize, "concretizing configuration"); return m -> resolveAnonVars .andThen(resolveSemanticCasts) .andThen(addImplicitComputationCell) .andThen(resolveFreshConstants) .andThen(concretizeCells) .andThen(subsortKItem) .apply(m); }