@Override public Function<Module, Module> specificationSteps(Definition def) { BiFunction<Module, K, K> convertCellCollections = (Module m, K k) -> new ConvertDataStructureToLookup(m, false).convert(k); return m -> ModuleTransformer.fromSentenceTransformer(new ResolveAnonVar()::resolve, "resolve anonymous varaibles") .andThen(ModuleTransformer.fromSentenceTransformer(s -> new ResolveSemanticCasts(kompileOptions.backend.equals(Backends.JAVA)).resolve(s), "resolve semantic casts")) .andThen(AddImplicitComputationCell::transformModule) .andThen(ConcretizeCells::transformModule) .andThen(ModuleTransformer.fromRuleBodyTransformer(RewriteToTop::bubbleRewriteToTopInsideCells, "bubble out rewrites below cells")) .andThen(AddBottomSortForListsWithIdenticalLabels.singleton()) .andThen(ModuleTransformer.fromSentenceTransformer((mod, s) -> new ExpandMacros(mod, files, kompileOptions, false).expand(s), "expand macros")) .andThen(ModuleTransformer.fromKTransformerWithModuleInfo(convertCellCollections::apply, "convert cell to the underlying collections")) .andThen(ModuleTransformer.fromRuleBodyTransformer(JavaBackend::ADTKVariableToSortedVariable, "ADT.KVariable to SortedVariable")) .andThen(ModuleTransformer.fromRuleBodyTransformer(JavaBackend::convertKSeqToKApply, "kseq to kapply")) .andThen(ModuleTransformer.fromRuleBodyTransformer(NormalizeKSeq.self(), "normalize kseq")) .andThen(mod -> JavaBackend.markRegularRules(def, mod)) .andThen(ModuleTransformer.fromSentenceTransformer(new AddConfigurationRecoveryFlags()::apply, "add refers_THIS_CONFIGURATION_marker")) .apply(m); }
Sentence threadLocal = Production(KLabel("#ThreadLocal"), Sorts.KItem(), Seq(Terminal("#ThreadLocal"))); Function1<Module, Module> pipeline = preprocessKLabelPredicates .andThen(splitThreadCell) .andThen(mod -> Module(mod.name(), mod.imports(), Stream.concat(stream(mod.localSentences()),
@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); }