diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleIndex.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleIndex.kt index 357b1dea..cf994da1 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleIndex.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleIndex.kt @@ -110,58 +110,6 @@ class RuleIndex(): Iterable, RuleLookup } } - @Deprecated(message = "update functionality to be dropped") - fun updateIndexFromRules(rules: Iterable) { - val removedTags = allRules.map { it.rule.uniqueTag() }.toHashSet() - rules.map { it.uniqueTag() }.forEach{ removedTags.remove(it) } - - val allRulesIt = allRules.listIterator() - var nextIdx = 0 - rules.forEach { rule -> - var skip = false - while (allRulesIt.hasNext()) { - val irule = allRulesIt.next() - if (removedTags.contains(irule.rule.uniqueTag())) { - removeRuleFromIndex(irule) - allRulesIt.remove() - - } else if (!irule.rule.uniqueTag().equals(rule.uniqueTag())) { - allRulesIt.previous() - break - - } else { - irule.idx = nextIdx - skip = true - break - } - } - if (!skip) { - IndexedRule(nextIdx, rule).also { - addRuleToIndex(it) - allRulesIt.add(it) - } - } - nextIdx++ - } - while (allRulesIt.hasNext()) { - val irule = allRulesIt.next() - removeRuleFromIndex(irule) - allRulesIt.remove() - } - } - - private fun removeRuleFromIndex(irule: IndexedRule) { - val uniqueTag = irule.rule.uniqueTag() - tag2rule.remove(uniqueTag) - val ruleBit = tag2bit.remove(uniqueTag) - bit2ruleAndMask.remove(ruleBit) - val head = irule.rule.headKept() + irule.rule.headReplaced() - for ((headPos, cst) in head.withIndex()) { - symbol2index[cst.symbol()]?.clear(cst, ruleBit, headPos) - } - - } - private fun addRuleToIndex(irule: IndexedRule) { val uniqueTag = irule.rule.uniqueTag() if (tag2rule.containsKey(uniqueTag)) throw IllegalStateException("duplicate rule tag $uniqueTag") diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt index e77fb169..34cabe05 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt @@ -136,7 +136,6 @@ interface MatchJournal : EvidenceSource { * [RuleMatch] which defines this [Chunk] */ val match: RuleMatch - val ruleUniqueTag: Any get() = match.rule().uniqueTag() } /** diff --git a/reactor/Test/test/TestRuleIndex.kt b/reactor/Test/test/TestRuleIndex.kt index a6542d77..66f4f759 100644 --- a/reactor/Test/test/TestRuleIndex.kt +++ b/reactor/Test/test/TestRuleIndex.kt @@ -59,14 +59,6 @@ class TestRuleIndex { with (ruleIndex.forOccurrence(occurrence("bar"))) { iterator().hasNext() shouldBe false } - - ruleIndex.updateIndexFromRules(second.rules) - with (ruleIndex.forOccurrence(occurrence("foo"))) { - iterator().hasNext() shouldBe false - } - with (ruleIndex.forOccurrence(occurrence("bar"))) { - map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1") - } } } @@ -91,14 +83,6 @@ class TestRuleIndex { with (ruleIndex.forOccurrence(occurrence("foo"))) { map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule0") } - - ruleIndex.updateIndexFromRules(second.rules) - with (ruleIndex.forOccurrence(occurrence("foo"))) { - map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1","rule0") - } - with (ruleIndex.forOccurrence(occurrence("bar"))) { - map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1","rule2") - } } } @@ -127,11 +111,6 @@ class TestRuleIndex { with (ruleIndex.forOccurrence(occurrence("bar"))) { map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1","rule2") } - - ruleIndex.updateIndexFromRules(second.rules) - with (ruleIndex.forOccurrence(occurrence("foo"))) { - map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1") - } } } @@ -158,14 +137,6 @@ class TestRuleIndex { with (ruleIndex.forOccurrence(occurrence("bar"))) { map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1","rule2") } - - ruleIndex.updateIndexFromRules(second.rules) - with (ruleIndex.forOccurrence(occurrence("foo"))) { - map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule0") - } - with (ruleIndex.forOccurrence(occurrence("bar"))) { - iterator().hasNext() shouldBe false - } } } @@ -208,20 +179,6 @@ class TestRuleIndex { with (ruleIndex.forOccurrence(occurrence("qux"))) { map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule4") } - - ruleIndex.updateIndexFromRules(second.rules) - with (ruleIndex.forOccurrence(occurrence("foo"))) { - map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule5", "rule0") - } - with (ruleIndex.forOccurrence(occurrence("bar"))) { - map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule2") - } - with (ruleIndex.forOccurrence(occurrence("baz"))) { - iterator().hasNext() shouldBe false - } - with (ruleIndex.forOccurrence(occurrence("qux"))) { - map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule4", "rule6") - } } }