@Override public K apply(KApply k) { return super.apply(closeCell(k)); }
public synchronized K close(K term) { resetVars(); gatherVars(term); return transform(term); }
@Test public void testClosedCellError1() { K term = cell("<thread>", cell("<k>")); exception.expect(KEMException.class); exception.expectMessage("Closed parent cell missing required children [EnvCell]"); new CloseCells(cfgInfo, sortInfo, labelInfo).close(term); }
public ConcretizeCells(ConfigurationInfo configurationInfo, LabelInfo labelInfo, SortInfo sortInfo, Module module) { this.configurationInfo = configurationInfo; this.labelInfo = labelInfo; this.sortInfo = sortInfo; this.module = module; addRootCell = new AddTopCellToRules(configurationInfo, labelInfo); addParentCells = new AddParentCells(configurationInfo, labelInfo); closeCells = new CloseCells(configurationInfo, sortInfo, labelInfo); sortCells = new SortCells(configurationInfo, labelInfo, module); }
KRewrite rw = (KRewrite) item; for (K leftItem : IncompleteCellUtils.flattenCells(rw.left())) { filterRequired(requiredLeft, leftItem); filterRequired(requiredRight, rightItem); filterRequired(requiredLeft, item); filterRequired(requiredRight, item); newItems.add(newDotVariable(null)); return KApply(label, KList(newItems)); } else { newItems.add(newDotVariable(cellType)); newItems.add(newDotVariable(cellType)); leftVar = newDotVariable(cellType); body = KApply(closeOperator, KList(body, newDotVariable(cellType)));
@Test public void testSimpleClosure() { K term = cell("<k>", false, true, KApply(KLabel("_+_"), KVariable("I"), KVariable("J"))); K expected = ccell("<k>", KSequence(KApply(KLabel("_+_"), KVariable("I"), KVariable("J")), KVariable("DotVar0"))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }
@Test public void testCloseMap() { K term = cell("<env>", true, false, KApply(KLabel("'_|=>_"), intToToken(1), intToToken(2))); K expected = ccell("<env>", KApply(KLabel("_Map_"), KApply(KLabel("'_|=>_"), intToToken(1), intToToken(2)), KVariable("DotVar0"))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }
private Context close(Context context) { resetVars(); gatherVars(context.body()); gatherVars(context.requires()); return new Context( transform(context.body()), transform(context.requires()), context.att()); }
public Sentence concretize(Sentence s) { s = addRootCell.addImplicitCells(s); s = addParentCells.concretize(s); s = closeCells.close(s); s = sortCells.preprocess(s); s = sortCells.sortCells(s); s = sortCells.postprocess(s); return s; } }
@Test public void testCloseCellVar() { K term = KApply(KLabels.CELLS, cell("<thread>", true, false, cell("<k>", intToToken(1))), cell("<thread>", false, true, cell("<k>", intToToken(2))), cell("<thread>", true, true, cell("<k>", intToToken(2)))); K expected = KApply(KLabels.CELLS, ccell("<thread>", ccell("<k>", intToToken(1)), KVariable("DotVar0")), ccell("<thread>", ccell("<k>", intToToken(2)), KVariable("DotVar1")), ccell("<thread>", ccell("<k>", intToToken(2)), KVariable("DotVar2"))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }
private Rule close(Rule rule) { resetVars(); gatherVars(rule.body()); gatherVars(rule.requires()); gatherVars(rule.ensures()); return new Rule( transform(rule.body()), transform(rule.requires()), transform(rule.ensures()), rule.att()); }
@Test public void testCloseList() { K term = KApply(KLabels.CELLS, cell("<list>", true, false, intToToken(1)), cell("<list>", false, true, intToToken(2)), cell("<list>", true, true, intToToken(3))); K expected = KApply(KLabels.CELLS, ccell("<list>", KApply(KLabel("_List_"), KVariable("DotVar0"), intToToken(1))), ccell("<list>", KApply(KLabel("_List_"), intToToken(2), KVariable("DotVar1"))), ccell("<list>", KApply(KLabel("_List_"), KVariable("DotVar2"), KApply(KLabel("_List_"), intToToken(3), KVariable("DotVar3"))))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }
@Test public void testCloseCellTerm() { K term = KRewrite(cells(), cells(cell("<thread>", true, false, cell("<k>", intToToken(1))), cell("<thread>", false, true, cell("<k>", intToToken(2))), cell("<thread>", true, true, cell("<env>", intToToken(2))))); K expected = KRewrite(cells(), cells(ccell("<thread>", ccell("<k>", intToToken(1)), ccell("<env>", KApply(KLabel(".Map")))), ccell("<thread>", ccell("<k>", intToToken(2)), ccell("<env>", KApply(KLabel(".Map")))), ccell("<thread>", ccell("<env>", intToToken(2)), ccell("<k>", stringToToken("defaultK"))))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }