Updated API sources from the latest version of Logic. Adapted to the new API. LogicalPattern -> MetaLogical. Renamed all *pattern entities. RuleBuilder for tests.
This commit is contained in:
parent
fb65c965c4
commit
619337151f
|
|
@ -30,6 +30,6 @@ public interface Logical<T> {
|
|||
|
||||
public boolean isWildcard();
|
||||
|
||||
public LogicalPattern<T> pattern();
|
||||
public MetaLogical<T> metaLogical();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@ package jetbrains.mps.logic.reactor.logical;
|
|||
|
||||
public interface LogicalContext {
|
||||
|
||||
public <V> Logical<V> variable(LogicalPattern<V> logicalPattern);
|
||||
public <V> Logical<V> variable(MetaLogical<V> metaLogical);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
package jetbrains.mps.logic.reactor.logical;
|
||||
|
||||
/*Generated by MPS */
|
||||
|
||||
|
||||
public interface LogicalPattern<V> {
|
||||
|
||||
public String name();
|
||||
|
||||
public String name(NamingContext namingContext);
|
||||
|
||||
public boolean isWildcard();
|
||||
|
||||
public Class<V> type();
|
||||
|
||||
public Logical<V> instance();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package jetbrains.mps.logic.reactor.logical;
|
||||
|
||||
/*Generated by MPS */
|
||||
|
||||
|
||||
public class MetaLogical<V> {
|
||||
|
||||
private static final String WILDCARD = "_";
|
||||
|
||||
public MetaLogical(String name, Class<V> type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public MetaLogical(Class<V> type) {
|
||||
this.name = MetaLogical.WILDCARD + System.identityHashCode(this);
|
||||
this.type = type;
|
||||
this.wildcard = true;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isWildcard() {
|
||||
return wildcard;
|
||||
}
|
||||
|
||||
public Class<V> type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private Class<V> type;
|
||||
private boolean wildcard = false;
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package jetbrains.mps.logic.reactor.logical;
|
||||
|
||||
/*Generated by MPS */
|
||||
|
||||
|
||||
public interface MultiLogicalPattern<V> extends LogicalPattern<V> {
|
||||
|
||||
public int cardinality();
|
||||
|
||||
public LogicalPattern<V> patternAt(int idx);
|
||||
|
||||
public LogicalPattern[] toArray();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package jetbrains.mps.logic.reactor.logical;
|
||||
|
||||
/*Generated by MPS */
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MultiMetaLogical<V> extends MetaLogical<V> {
|
||||
|
||||
public MultiMetaLogical(String name, Class<V> type, int cardinality) {
|
||||
super(name, type);
|
||||
this.cardinality = cardinality;
|
||||
init();
|
||||
}
|
||||
|
||||
public int cardinality() {
|
||||
return cardinality;
|
||||
}
|
||||
|
||||
public MetaLogical<V> logicalAt(int idx) {
|
||||
return metaLogicals.get(idx);
|
||||
}
|
||||
|
||||
public MetaLogical[] toArray() {
|
||||
MetaLogical[] array = new MetaLogical[cardinality];
|
||||
return metaLogicals.toArray(array);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
for (int i = 0; i < cardinality; i++) {
|
||||
metaLogicals.add(new MetaLogical<V>(name() + "_" + (i + 1), type()));
|
||||
}
|
||||
}
|
||||
|
||||
private int cardinality;
|
||||
private List<MetaLogical<V>> metaLogicals = new ArrayList<MetaLogical<V>>();
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
package jetbrains.mps.logic.reactor.logical;
|
||||
|
||||
/*Generated by MPS */
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
|
||||
public class NamingContext {
|
||||
|
||||
public String uniqueName(Logical logical) {
|
||||
return cachedOrMakeUnique(logical, logical.name());
|
||||
}
|
||||
|
||||
public String uniqueName(LogicalPattern logical) {
|
||||
return cachedOrMakeUnique(logical, logical.name());
|
||||
}
|
||||
|
||||
private String cachedOrMakeUnique(Object named, String name) {
|
||||
if (!(cachedUnique.containsKey(named))) {
|
||||
cachedUnique.put(named, makeUnique(name));
|
||||
}
|
||||
return cachedUnique.get(named);
|
||||
}
|
||||
|
||||
private String makeUnique(String name) {
|
||||
int c = getAndIncrementCounter(name);
|
||||
return (c == 0 ? name : name + c);
|
||||
}
|
||||
|
||||
private int getAndIncrementCounter(String name) {
|
||||
Integer c = (uniqueCounters.containsKey(name) ? uniqueCounters.get(name) : 0);
|
||||
uniqueCounters.put(name, c + 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
private Map<String, Integer> uniqueCounters = new HashMap<String, Integer>();
|
||||
|
||||
private Map<Object, String> cachedUnique = new IdentityHashMap<Object, String>();
|
||||
|
||||
}
|
||||
|
|
@ -1,19 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<debug-info>
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.ConstructorDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.ExpressionStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.FieldDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.IfStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.ForStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.ReturnStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.SuperConstructorInvocation" />
|
||||
<root nodeRef="r:7365f7fe-12e6-4229-8901-f6dc6d5df03f(jetbrains.mps.logic.reactor.logical)/1564179198503508264">
|
||||
<file name="Logical.java">
|
||||
<node id="7045828502339522708" at="8,0,9,0" concept="3" trace="name#()Ljava/lang/String;" />
|
||||
<node id="238586457663160034" at="15,0,16,0" concept="3" trace="findRoot#()Ljetbrains/mps/logic/reactor/logical/Logical;" />
|
||||
<node id="1564179198503509166" at="24,0,25,0" concept="3" trace="value#()null" />
|
||||
<node id="1564179198503509045" at="29,0,30,0" concept="3" trace="isBound#()Z" />
|
||||
<node id="3058061960962299083" at="31,0,32,0" concept="3" trace="isWildcard#()Z" />
|
||||
<node id="8897567155601592702" at="33,0,34,0" concept="3" trace="pattern#()Ljetbrains/mps/logic/reactor/logical/LogicalPattern;" />
|
||||
<node id="7045828502339522708" at="8,0,9,0" concept="4" trace="name#()Ljava/lang/String;" />
|
||||
<node id="238586457663160034" at="15,0,16,0" concept="4" trace="findRoot#()Ljetbrains/mps/logic/reactor/logical/Logical;" />
|
||||
<node id="1564179198503509166" at="24,0,25,0" concept="4" trace="value#()null" />
|
||||
<node id="1564179198503509045" at="29,0,30,0" concept="4" trace="isBound#()Z" />
|
||||
<node id="3058061960962299083" at="31,0,32,0" concept="4" trace="isWildcard#()Z" />
|
||||
<node id="8897567155601592702" at="33,0,34,0" concept="4" trace="metaLogical#()Ljetbrains/mps/logic/reactor/logical/MetaLogical;" />
|
||||
<scope id="7045828502339522708" at="8,0,9,0" />
|
||||
<scope id="238586457663160034" at="15,0,16,0" />
|
||||
<scope id="1564179198503509166" at="24,0,25,0" />
|
||||
|
|
@ -23,61 +26,13 @@
|
|||
<unit id="1564179198503508264" at="6,0,36,0" name="jetbrains.mps.logic.reactor.logical.Logical" />
|
||||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:7365f7fe-12e6-4229-8901-f6dc6d5df03f(jetbrains.mps.logic.reactor.logical)/2966490507992442162">
|
||||
<file name="NamingContext.java">
|
||||
<node id="8897567155601872170" at="11,45,12,55" concept="5" />
|
||||
<node id="8897567155601877662" at="15,52,16,55" concept="5" />
|
||||
<node id="8897567155601872137" at="20,45,21,48" concept="0" />
|
||||
<node id="8897567155601872149" at="22,5,23,35" concept="5" />
|
||||
<node id="7788002923752702358" at="26,42,27,41" concept="4" />
|
||||
<node id="7788002923752701639" at="27,41,28,38" concept="5" />
|
||||
<node id="7788002923752672045" at="31,51,32,82" concept="4" />
|
||||
<node id="7788002923752674066" at="32,82,33,36" concept="0" />
|
||||
<node id="7788002923752668035" at="33,36,34,13" concept="5" />
|
||||
<node id="2966490507992442764" at="37,0,38,0" concept="1" trace="uniqueCounters" />
|
||||
<node id="2966490507992487240" at="39,0,40,0" concept="1" trace="cachedUnique" />
|
||||
<node id="2966490507992442243" at="11,0,14,0" concept="3" trace="uniqueName#(Ljetbrains/mps/logic/reactor/logical/Logical;)Ljava/lang/String;" />
|
||||
<node id="8897567155601877656" at="15,0,18,0" concept="3" trace="uniqueName#(Ljetbrains/mps/logic/reactor/logical/LogicalPattern;)Ljava/lang/String;" />
|
||||
<node id="8897567155601872135" at="19,64,22,5" concept="2" />
|
||||
<node id="2966490507992478411" at="26,0,30,0" concept="3" trace="makeUnique#(Ljava/lang/String;)Ljava/lang/String;" />
|
||||
<node id="7788002923752647499" at="31,0,36,0" concept="3" trace="getAndIncrementCounter#(Ljava/lang/String;)I" />
|
||||
<node id="8897567155601872164" at="19,0,25,0" concept="3" trace="cachedOrMakeUnique#(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;" />
|
||||
<scope id="2966490507992442247" at="11,45,12,55" />
|
||||
<scope id="8897567155601877661" at="15,52,16,55" />
|
||||
<scope id="8897567155601872136" at="20,45,21,48" />
|
||||
<scope id="2966490507992478415" at="26,42,28,38">
|
||||
<var name="c" id="7788002923752702359" />
|
||||
</scope>
|
||||
<scope id="2966490507992442243" at="11,0,14,0">
|
||||
<var name="logical" id="2966490507992442616" />
|
||||
</scope>
|
||||
<scope id="8897567155601877656" at="15,0,18,0">
|
||||
<var name="logical" id="8897567155601877657" />
|
||||
</scope>
|
||||
<scope id="7788002923752647503" at="31,51,34,13">
|
||||
<var name="c" id="7788002923752672046" />
|
||||
</scope>
|
||||
<scope id="8897567155601872134" at="19,64,23,35" />
|
||||
<scope id="2966490507992478411" at="26,0,30,0">
|
||||
<var name="name" id="2966490507992482288" />
|
||||
</scope>
|
||||
<scope id="7788002923752647499" at="31,0,36,0">
|
||||
<var name="name" id="7788002923752648441" />
|
||||
</scope>
|
||||
<scope id="8897567155601872164" at="19,0,25,0">
|
||||
<var name="name" id="8897567155601872156" />
|
||||
<var name="named" id="8897567155601872154" />
|
||||
</scope>
|
||||
<unit id="2966490507992442162" at="9,0,42,0" name="jetbrains.mps.logic.reactor.logical.NamingContext" />
|
||||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:7365f7fe-12e6-4229-8901-f6dc6d5df03f(jetbrains.mps.logic.reactor.logical)/7835819612255545383">
|
||||
<file name="SolverLogical.java">
|
||||
<node id="4650394911992714457" at="11,0,12,0" concept="3" trace="findRoot#()Ljetbrains/mps/logic/reactor/logical/SolverLogical;" />
|
||||
<node id="2322954797151415913" at="18,0,19,0" concept="3" trace="union#(Ljetbrains/mps/logic/reactor/logical/SolverLogical;Ljetbrains/mps/logic/reactor/logical/SolverLogical/ValueReconciler;)V" />
|
||||
<node id="2322954797151538884" at="24,0,25,0" concept="3" trace="union#(Ljetbrains/mps/logic/reactor/logical/SolverLogical;)V" />
|
||||
<node id="7835819612255551865" at="29,0,30,0" concept="3" trace="setValue#(null)V" />
|
||||
<node id="2322954797151528577" at="33,0,34,0" concept="3" trace="reconcile#(nullnull)V" />
|
||||
<node id="4650394911992714457" at="11,0,12,0" concept="4" trace="findRoot#()Ljetbrains/mps/logic/reactor/logical/SolverLogical;" />
|
||||
<node id="2322954797151415913" at="18,0,19,0" concept="4" trace="union#(Ljetbrains/mps/logic/reactor/logical/SolverLogical;Ljetbrains/mps/logic/reactor/logical/SolverLogical/ValueReconciler;)V" />
|
||||
<node id="2322954797151538884" at="24,0,25,0" concept="4" trace="union#(Ljetbrains/mps/logic/reactor/logical/SolverLogical;)V" />
|
||||
<node id="7835819612255551865" at="29,0,30,0" concept="4" trace="setValue#(null)V" />
|
||||
<node id="2322954797151528577" at="33,0,34,0" concept="4" trace="reconcile#(nullnull)V" />
|
||||
<scope id="4650394911992714457" at="11,0,12,0" />
|
||||
<scope id="2322954797151415913" at="18,0,19,0">
|
||||
<var name="other" id="2322954797151420306" />
|
||||
|
|
@ -99,9 +54,9 @@
|
|||
</root>
|
||||
<root nodeRef="r:7365f7fe-12e6-4229-8901-f6dc6d5df03f(jetbrains.mps.logic.reactor.logical)/7835819612256812298">
|
||||
<file name="LogicalUnification.java">
|
||||
<node id="7835819612256815740" at="9,0,10,0" concept="3" trace="asRoot#(null)null" />
|
||||
<node id="7835819612256819308" at="11,0,12,0" concept="3" trace="logical#(null)Ljetbrains/mps/logic/reactor/logical/SolverLogical;" />
|
||||
<node id="7835819612261255414" at="13,0,14,0" concept="3" trace="isLogical#(Ljetbrains/mps/unification/Term;)Z" />
|
||||
<node id="7835819612256815740" at="9,0,10,0" concept="4" trace="asRoot#(null)null" />
|
||||
<node id="7835819612256819308" at="11,0,12,0" concept="4" trace="logical#(null)Ljetbrains/mps/logic/reactor/logical/SolverLogical;" />
|
||||
<node id="7835819612261255414" at="13,0,14,0" concept="4" trace="isLogical#(Ljetbrains/mps/unification/Term;)Z" />
|
||||
<scope id="7835819612256815740" at="9,0,10,0">
|
||||
<var name="term" id="7835819612256818579" />
|
||||
</scope>
|
||||
|
|
@ -115,40 +70,90 @@
|
|||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:7365f7fe-12e6-4229-8901-f6dc6d5df03f(jetbrains.mps.logic.reactor.logical)/8897567155595965539">
|
||||
<file name="LogicalPattern.java">
|
||||
<node id="8897567155595965722" at="8,0,9,0" concept="3" trace="name#()Ljava/lang/String;" />
|
||||
<node id="8897567155595965727" at="10,0,11,0" concept="3" trace="name#(Ljetbrains/mps/logic/reactor/logical/NamingContext;)Ljava/lang/String;" />
|
||||
<node id="8897567155595965985" at="12,0,13,0" concept="3" trace="isWildcard#()Z" />
|
||||
<node id="8897567155598409095" at="14,0,15,0" concept="3" trace="type#()Ljava/lang/Class;" />
|
||||
<node id="3935945753920958541" at="16,0,17,0" concept="3" trace="instance#()Ljetbrains/mps/logic/reactor/logical/Logical;" />
|
||||
<scope id="8897567155595965722" at="8,0,9,0" />
|
||||
<scope id="8897567155595965727" at="10,0,11,0">
|
||||
<var name="namingContext" id="8897567155595965731" />
|
||||
<file name="MetaLogical.java">
|
||||
<node id="8499880265522559267" at="8,0,9,0" concept="7" trace="WILDCARD" />
|
||||
<node id="8499880265522559281" at="10,50,11,21" concept="1" />
|
||||
<node id="8499880265522559287" at="11,21,12,21" concept="1" />
|
||||
<node id="8499880265522559301" at="15,37,16,69" concept="1" />
|
||||
<node id="8499880265522559309" at="16,69,17,21" concept="1" />
|
||||
<node id="8499880265522559315" at="17,21,18,25" concept="1" />
|
||||
<node id="8499880265524914186" at="21,24,22,16" concept="6" />
|
||||
<node id="8499880265524914478" at="25,31,26,20" concept="6" />
|
||||
<node id="8499880265524914776" at="29,26,30,16" concept="6" />
|
||||
<node id="8499880265522559381" at="33,0,34,0" concept="2" trace="name" />
|
||||
<node id="8499880265522559384" at="34,0,35,0" concept="2" trace="type" />
|
||||
<node id="8499880265522559388" at="35,0,36,0" concept="2" trace="wildcard" />
|
||||
<node id="8897567155595965722" at="21,0,24,0" concept="4" trace="name#()Ljava/lang/String;" />
|
||||
<node id="8897567155595965985" at="25,0,28,0" concept="4" trace="isWildcard#()Z" />
|
||||
<node id="8897567155598409095" at="29,0,32,0" concept="4" trace="type#()Ljava/lang/Class;" />
|
||||
<node id="8499880265522559272" at="10,0,14,0" concept="0" trace="MetaLogical#(Ljava/lang/String;Ljava/lang/Class;)V" />
|
||||
<node id="8499880265522559294" at="15,0,20,0" concept="0" trace="MetaLogical#(Ljava/lang/Class;)V" />
|
||||
<scope id="8897567155595965725" at="21,24,22,16" />
|
||||
<scope id="8897567155595965986" at="25,31,26,20" />
|
||||
<scope id="8897567155598409099" at="29,26,30,16" />
|
||||
<scope id="8499880265522559280" at="10,50,12,21" />
|
||||
<scope id="8499880265522559300" at="15,37,18,25" />
|
||||
<scope id="8897567155595965722" at="21,0,24,0" />
|
||||
<scope id="8897567155595965985" at="25,0,28,0" />
|
||||
<scope id="8897567155598409095" at="29,0,32,0" />
|
||||
<scope id="8499880265522559272" at="10,0,14,0">
|
||||
<var name="name" id="8499880265522559273" />
|
||||
<var name="type" id="8499880265522559275" />
|
||||
</scope>
|
||||
<scope id="8897567155595965985" at="12,0,13,0" />
|
||||
<scope id="8897567155598409095" at="14,0,15,0" />
|
||||
<scope id="3935945753920958541" at="16,0,17,0" />
|
||||
<unit id="8897567155595965539" at="6,0,19,0" name="jetbrains.mps.logic.reactor.logical.LogicalPattern" />
|
||||
<scope id="8499880265522559294" at="15,0,20,0">
|
||||
<var name="type" id="8499880265522559295" />
|
||||
</scope>
|
||||
<unit id="8897567155595965539" at="6,0,38,0" name="jetbrains.mps.logic.reactor.logical.MetaLogical" />
|
||||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:7365f7fe-12e6-4229-8901-f6dc6d5df03f(jetbrains.mps.logic.reactor.logical)/8897567155601467909">
|
||||
<file name="MultiLogicalPattern.java">
|
||||
<node id="8897567155598413823" at="8,0,9,0" concept="3" trace="cardinality#()I" />
|
||||
<node id="8897567155601465253" at="10,0,11,0" concept="3" trace="patternAt#(I)Ljetbrains/mps/logic/reactor/logical/LogicalPattern;" />
|
||||
<node id="8897567155608760084" at="12,0,13,0" concept="3" trace="toArray#()[Ljetbrains/mps/logic/reactor/logical/LogicalPattern;" />
|
||||
<scope id="8897567155598413823" at="8,0,9,0" />
|
||||
<scope id="8897567155601465253" at="10,0,11,0">
|
||||
<file name="MultiMetaLogical.java">
|
||||
<node id="8499880265522563072" at="10,72,11,22" concept="8" />
|
||||
<node id="8499880265522563075" at="11,22,12,35" concept="1" />
|
||||
<node id="8499880265522563081" at="12,35,13,11" concept="1" />
|
||||
<node id="8499880265524939109" at="16,28,17,23" concept="6" />
|
||||
<node id="8499880265522563105" at="20,44,21,33" concept="6" />
|
||||
<node id="8499880265522563116" at="24,34,25,55" concept="5" />
|
||||
<node id="8499880265522563125" at="25,55,26,39" concept="6" />
|
||||
<node id="8499880265522563140" at="30,43,31,75" concept="1" />
|
||||
<node id="8499880265522563167" at="35,0,36,0" concept="2" trace="cardinality" />
|
||||
<node id="8499880265522563171" at="36,0,37,0" concept="2" trace="metaLogicals" />
|
||||
<node id="8897567155598413823" at="16,0,19,0" concept="4" trace="cardinality#()I" />
|
||||
<node id="8897567155601465253" at="20,0,23,0" concept="4" trace="logicalAt#(I)Ljetbrains/mps/logic/reactor/logical/MetaLogical;" />
|
||||
<node id="8499880265522563133" at="29,23,32,5" concept="3" />
|
||||
<node id="8897567155608760084" at="24,0,28,0" concept="4" trace="toArray#()[Ljetbrains/mps/logic/reactor/logical/MetaLogical;" />
|
||||
<node id="8499880265522563068" at="10,0,15,0" concept="0" trace="MultiMetaLogical#(Ljava/lang/String;Ljava/lang/Class;I)V" />
|
||||
<node id="8499880265522563131" at="29,0,34,0" concept="4" trace="init#()V" />
|
||||
<scope id="8897567155598413824" at="16,28,17,23" />
|
||||
<scope id="8897567155601465256" at="20,44,21,33" />
|
||||
<scope id="8499880265522563139" at="30,43,31,75" />
|
||||
<scope id="8897567155608760087" at="24,34,26,39">
|
||||
<var name="array" id="8499880265522563117" />
|
||||
</scope>
|
||||
<scope id="8499880265522563071" at="10,72,13,11" />
|
||||
<scope id="8897567155598413823" at="16,0,19,0" />
|
||||
<scope id="8897567155601465253" at="20,0,23,0">
|
||||
<var name="idx" id="8897567155601468783" />
|
||||
</scope>
|
||||
<scope id="8897567155608760084" at="12,0,13,0" />
|
||||
<unit id="8897567155601467909" at="6,0,15,0" name="jetbrains.mps.logic.reactor.logical.MultiLogicalPattern" />
|
||||
<scope id="8499880265522563132" at="29,23,32,5" />
|
||||
<scope id="8499880265522563133" at="29,23,32,5">
|
||||
<var name="i" id="8499880265522563136" />
|
||||
</scope>
|
||||
<scope id="8897567155608760084" at="24,0,28,0" />
|
||||
<scope id="8499880265522563068" at="10,0,15,0">
|
||||
<var name="cardinality" id="8499880265522563088" />
|
||||
<var name="name" id="8499880265522563083" />
|
||||
<var name="type" id="8499880265522563085" />
|
||||
</scope>
|
||||
<scope id="8499880265522563131" at="29,0,34,0" />
|
||||
<unit id="8897567155601467909" at="8,0,38,0" name="jetbrains.mps.logic.reactor.logical.MultiMetaLogical" />
|
||||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:7365f7fe-12e6-4229-8901-f6dc6d5df03f(jetbrains.mps.logic.reactor.logical)/8907901911298493091">
|
||||
<file name="LogicalContext.java">
|
||||
<node id="8907901911298493118" at="8,0,9,0" concept="3" trace="variable#(Ljetbrains/mps/logic/reactor/logical/LogicalPattern;)Ljetbrains/mps/logic/reactor/logical/Logical;" />
|
||||
<node id="8907901911298493118" at="8,0,9,0" concept="4" trace="variable#(Ljetbrains/mps/logic/reactor/logical/MetaLogical;)Ljetbrains/mps/logic/reactor/logical/Logical;" />
|
||||
<scope id="8907901911298493118" at="8,0,9,0">
|
||||
<var name="logicalPattern" id="8907901911298493173" />
|
||||
<var name="metaLogical" id="8907901911298493173" />
|
||||
</scope>
|
||||
<unit id="8907901911298493091" at="6,0,11,0" name="jetbrains.mps.logic.reactor.logical.LogicalContext" />
|
||||
</file>
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
package jetbrains.mps.logic.reactor.program;
|
||||
|
||||
/*Generated by MPS */
|
||||
|
||||
import jetbrains.mps.logic.reactor.evaluation.SessionSolver;
|
||||
|
||||
public abstract class ProgramBuilder {
|
||||
|
||||
public abstract Program program(String name, SessionSolver sessionSolver);
|
||||
|
||||
public abstract void addRule(Rule rule) throws InvalidRuleException;
|
||||
|
||||
public abstract Constraint constraint(ConstraintSymbol symbol, Object... args);
|
||||
|
||||
public abstract Predicate predicate(PredicateSymbol symbol, Object... args);
|
||||
|
||||
}
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
package jetbrains.mps.logic.reactor.program;
|
||||
|
||||
/*Generated by MPS */
|
||||
|
||||
import java.util.Collections;
|
||||
import com.google.common.collect.Iterables;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RuleBuilder {
|
||||
|
||||
public RuleBuilder(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public RuleBuilder appendBody(AndItem... item) {
|
||||
for (int i = 0; i < item.length; i++) {
|
||||
body.add(item[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public RuleBuilder appendGuard(Predicate... pred) {
|
||||
for (int i = 0; i < pred.length; i++) {
|
||||
guard.add(pred[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public RuleBuilder appendHeadReplaced(Constraint... cst) {
|
||||
for (int i = 0; i < cst.length; i++) {
|
||||
headReplaced.add(cst[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public RuleBuilder appendHeadKept(Constraint... cst) {
|
||||
for (int i = 0; i < cst.length; i++) {
|
||||
headKept.add(cst[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasHead() {
|
||||
return !((headKept.isEmpty() && headReplaced.isEmpty()));
|
||||
}
|
||||
|
||||
public boolean hasGuard() {
|
||||
return !(guard.isEmpty());
|
||||
}
|
||||
|
||||
public boolean hasBody() {
|
||||
return !(body.isEmpty());
|
||||
}
|
||||
|
||||
public RuleBuilder merge(RuleBuilder... other) {
|
||||
doMerge(other);
|
||||
return this;
|
||||
}
|
||||
|
||||
public jetbrains.mps.logic.reactor.program.Rule toRule() throws InvalidRuleException {
|
||||
jetbrains.mps.logic.reactor.program.Rule.Kind kind;
|
||||
if (!(headKept.isEmpty()) && !(headReplaced.isEmpty())) {
|
||||
kind = jetbrains.mps.logic.reactor.program.Rule.Kind.SIMPAGATION;
|
||||
|
||||
} else if (!(headReplaced.isEmpty())) {
|
||||
kind = jetbrains.mps.logic.reactor.program.Rule.Kind.SIMPLIFICATION;
|
||||
|
||||
} else if (!(headKept.isEmpty())) {
|
||||
kind = jetbrains.mps.logic.reactor.program.Rule.Kind.PROPAGATION;
|
||||
|
||||
} else {
|
||||
throw new InvalidRuleException("Invalid rule: empty head in " + toString());
|
||||
}
|
||||
|
||||
if (body.isEmpty()) {
|
||||
throw new InvalidRuleException("Invalid rule: empty body in " + toString());
|
||||
}
|
||||
|
||||
headKept = Collections.unmodifiableList(headKept);
|
||||
headReplaced = Collections.unmodifiableList(headReplaced);
|
||||
guard = Collections.unmodifiableList(guard);
|
||||
body = Collections.unmodifiableList(body);
|
||||
|
||||
return new RuleBuilder.Rule(kind, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s (%d,%d,%d,%d)", tag, headKept.size(), headReplaced.size(), guard.size(), body.size());
|
||||
}
|
||||
|
||||
private void doMerge(RuleBuilder... other) {
|
||||
for (int i = 0; i < other.length; i++) {
|
||||
RuleBuilder toMerge = other[i];
|
||||
|
||||
headReplaced.addAll(toMerge.headReplaced);
|
||||
headKept.addAll(toMerge.headKept);
|
||||
guard.addAll(toMerge.guard);
|
||||
body.addAll(toMerge.body);
|
||||
}
|
||||
}
|
||||
|
||||
public class Rule extends jetbrains.mps.logic.reactor.program.Rule {
|
||||
|
||||
private Rule(jetbrains.mps.logic.reactor.program.Rule.Kind kind, String tag) {
|
||||
this.kind = kind;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public jetbrains.mps.logic.reactor.program.Rule.Kind kind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Constraint> headKept() {
|
||||
return headKept;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Constraint> headReplaced() {
|
||||
return headReplaced;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Predicate> guard() {
|
||||
return guard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AndItem> body() {
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AndItem> all() {
|
||||
return Iterables.concat(headKept, headReplaced, guard, body);
|
||||
}
|
||||
|
||||
private jetbrains.mps.logic.reactor.program.Rule.Kind kind;
|
||||
private String tag;
|
||||
}
|
||||
|
||||
private String tag;
|
||||
private List<Constraint> headKept = new ArrayList<Constraint>(4);
|
||||
private List<Constraint> headReplaced = new ArrayList<Constraint>(4);
|
||||
private List<Predicate> guard = new ArrayList<Predicate>(4);
|
||||
private List<AndItem> body = new ArrayList<AndItem>(4);
|
||||
}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<debug-info>
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.BlockStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.ConstructorDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.ExpressionStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.FieldDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.ForStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.IfStatement" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement" />
|
||||
|
|
@ -13,15 +11,14 @@
|
|||
<concept fqn="jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.StaticMethodDeclaration" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.SuperConstructorInvocation" />
|
||||
<concept fqn="jetbrains.mps.baseLanguage.structure.ThrowStatement" />
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/5841747851381496683">
|
||||
<file name="ConstraintSymbol.java">
|
||||
<node id="5841747851381535271" at="11,63,12,43" concept="8" />
|
||||
<node id="6317379717814129922" at="15,49,16,21" concept="12" />
|
||||
<node id="5841747851383361011" at="20,28,21,32" concept="8" />
|
||||
<node id="5841747851381533067" at="11,0,14,0" concept="11" trace="symbol#(Ljava/lang/String;I)Ljetbrains/mps/logic/reactor/program/ConstraintSymbol;" />
|
||||
<node id="5841747851381516224" at="15,0,18,0" concept="1" trace="ConstraintSymbol#(Ljava/lang/String;I)V" />
|
||||
<node id="5841747851383347181" at="19,0,23,0" concept="6" trace="toString#()Ljava/lang/String;" />
|
||||
<node id="5841747851381535271" at="11,63,12,43" concept="6" />
|
||||
<node id="6317379717814129922" at="15,49,16,21" concept="10" />
|
||||
<node id="5841747851383361011" at="20,28,21,32" concept="6" />
|
||||
<node id="5841747851381533067" at="11,0,14,0" concept="9" trace="symbol#(Ljava/lang/String;I)Ljetbrains/mps/logic/reactor/program/ConstraintSymbol;" />
|
||||
<node id="5841747851381516224" at="15,0,18,0" concept="0" trace="ConstraintSymbol#(Ljava/lang/String;I)V" />
|
||||
<node id="5841747851383347181" at="19,0,23,0" concept="4" trace="toString#()Ljava/lang/String;" />
|
||||
<scope id="5841747851381533071" at="11,63,12,43" />
|
||||
<scope id="5841747851381516231" at="15,49,16,21" />
|
||||
<scope id="5841747851383347185" at="20,28,21,32" />
|
||||
|
|
@ -37,38 +34,14 @@
|
|||
<unit id="5841747851381496683" at="9,0,25,0" name="jetbrains.mps.logic.reactor.program.ConstraintSymbol" />
|
||||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/6256062047364762604">
|
||||
<file name="ProgramBuilder.java">
|
||||
<node id="6256062047364914798" at="9,0,10,0" concept="6" trace="program#(Ljava/lang/String;Ljetbrains/mps/logic/reactor/evaluation/SessionSolver;)Ljetbrains/mps/logic/reactor/program/Program;" />
|
||||
<node id="6317379717812928060" at="11,0,12,0" concept="6" trace="addRule#(Ljetbrains/mps/logic/reactor/program/Rule;)V" />
|
||||
<node id="4650394911981102050" at="13,0,14,0" concept="6" trace="constraint#(Ljetbrains/mps/logic/reactor/program/ConstraintSymbol;null)Ljetbrains/mps/logic/reactor/program/Constraint;" />
|
||||
<node id="4650394911981149223" at="15,0,16,0" concept="6" trace="predicate#(Ljetbrains/mps/logic/reactor/program/PredicateSymbol;null)Ljetbrains/mps/logic/reactor/program/Predicate;" />
|
||||
<scope id="6256062047364914798" at="9,0,10,0">
|
||||
<var name="name" id="6256062047364914961" />
|
||||
<var name="sessionSolver" id="6256062047364915075" />
|
||||
</scope>
|
||||
<scope id="6317379717812928060" at="11,0,12,0">
|
||||
<var name="rule" id="6317379717812951187" />
|
||||
</scope>
|
||||
<scope id="4650394911981102050" at="13,0,14,0">
|
||||
<var name="args" id="4650394911981133069" />
|
||||
<var name="symbol" id="4650394911981121116" />
|
||||
</scope>
|
||||
<scope id="4650394911981149223" at="15,0,16,0">
|
||||
<var name="args" id="4650394911981149226" />
|
||||
<var name="symbol" id="4650394911981149224" />
|
||||
</scope>
|
||||
<unit id="6256062047364762604" at="7,0,18,0" name="jetbrains.mps.logic.reactor.program.ProgramBuilder" />
|
||||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/6317379717812926698">
|
||||
<file name="Program.java">
|
||||
<node id="8225968737378322884" at="10,0,11,0" concept="6" trace="name#()Ljava/lang/String;" />
|
||||
<node id="7835819612273967620" at="12,0,13,0" concept="6" trace="sessionSolver#()Ljetbrains/mps/logic/reactor/evaluation/SessionSolver;" />
|
||||
<node id="8225968737376927920" at="14,0,15,0" concept="6" trace="constraintSymbols#()Ljava/lang/Iterable;" />
|
||||
<node id="6317379717812927967" at="16,0,17,0" concept="6" trace="constraintArgumentTypes#(Ljetbrains/mps/logic/reactor/program/ConstraintSymbol;)Ljava/util/List;" />
|
||||
<node id="8225968737376996320" at="18,0,19,0" concept="6" trace="predicateSymbols#()Ljava/lang/Iterable;" />
|
||||
<node id="8225968737378224820" at="20,0,21,0" concept="6" trace="rules#()Ljava/lang/Iterable;" />
|
||||
<node id="8225968737378322884" at="10,0,11,0" concept="4" trace="name#()Ljava/lang/String;" />
|
||||
<node id="7835819612273967620" at="12,0,13,0" concept="4" trace="sessionSolver#()Ljetbrains/mps/logic/reactor/evaluation/SessionSolver;" />
|
||||
<node id="8225968737376927920" at="14,0,15,0" concept="4" trace="constraintSymbols#()Ljava/lang/Iterable;" />
|
||||
<node id="6317379717812927967" at="16,0,17,0" concept="4" trace="constraintArgumentTypes#(Ljetbrains/mps/logic/reactor/program/ConstraintSymbol;)Ljava/util/List;" />
|
||||
<node id="8225968737376996320" at="18,0,19,0" concept="4" trace="predicateSymbols#()Ljava/lang/Iterable;" />
|
||||
<node id="8225968737378224820" at="20,0,21,0" concept="4" trace="rules#()Ljava/lang/Iterable;" />
|
||||
<scope id="8225968737378322884" at="10,0,11,0" />
|
||||
<scope id="7835819612273967620" at="12,0,13,0" />
|
||||
<scope id="8225968737376927920" at="14,0,15,0" />
|
||||
|
|
@ -82,33 +55,33 @@
|
|||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/6317379717814118653">
|
||||
<file name="Symbol.java">
|
||||
<node id="6317379717814129293" at="8,42,9,17" concept="2" />
|
||||
<node id="6317379717814157703" at="9,17,10,23" concept="2" />
|
||||
<node id="5841747851381516257" at="13,22,14,14" concept="8" />
|
||||
<node id="5841747851381516264" at="17,22,18,17" concept="8" />
|
||||
<node id="5841747851381863229" at="22,25,23,20" concept="7" />
|
||||
<node id="5841747851381863242" at="23,20,24,78" concept="2" />
|
||||
<node id="5841747851381863258" at="24,78,25,38" concept="2" />
|
||||
<node id="5841747851381863262" at="25,38,26,18" concept="8" />
|
||||
<node id="5841747851381863158" at="31,20,32,18" concept="8" />
|
||||
<node id="5841747851381863164" at="34,55,35,19" concept="8" />
|
||||
<node id="5841747851381863177" at="36,5,37,0" concept="9" />
|
||||
<node id="5841747851381863178" at="37,0,38,29" concept="7" />
|
||||
<node id="5841747851381863196" at="39,67,40,19" concept="8" />
|
||||
<node id="5841747851381863219" at="42,30,43,19" concept="8" />
|
||||
<node id="5841747851381863221" at="44,5,45,0" concept="9" />
|
||||
<node id="5841747851381863222" at="45,0,46,16" concept="8" />
|
||||
<node id="5841747851381516267" at="49,0,50,0" concept="3" trace="id" />
|
||||
<node id="5841747851381516270" at="50,0,51,0" concept="3" trace="arity" />
|
||||
<node id="5841747851381516253" at="13,0,16,0" concept="6" trace="id#()Ljava/lang/String;" />
|
||||
<node id="5841747851381516260" at="17,0,20,0" concept="6" trace="arity#()I" />
|
||||
<node id="5841747851381863156" at="30,35,33,5" concept="5" />
|
||||
<node id="5841747851381863162" at="33,5,36,5" concept="5" />
|
||||
<node id="5841747851381863194" at="38,29,41,5" concept="5" />
|
||||
<node id="5841747851381863214" at="41,5,44,5" concept="5" />
|
||||
<node id="6317379717814128471" at="8,0,12,0" concept="1" trace="Symbol#(Ljava/lang/String;I)V" />
|
||||
<node id="5841747851381863224" at="21,0,28,0" concept="6" trace="hashCode#()I" />
|
||||
<node id="5841747851381863152" at="29,0,48,0" concept="6" trace="equals#(Ljava/lang/Object;)Z" />
|
||||
<node id="6317379717814129293" at="8,42,9,17" concept="1" />
|
||||
<node id="6317379717814157703" at="9,17,10,23" concept="1" />
|
||||
<node id="5841747851381516257" at="13,22,14,14" concept="6" />
|
||||
<node id="5841747851381516264" at="17,22,18,17" concept="6" />
|
||||
<node id="5841747851381863229" at="22,25,23,20" concept="5" />
|
||||
<node id="5841747851381863242" at="23,20,24,78" concept="1" />
|
||||
<node id="5841747851381863258" at="24,78,25,38" concept="1" />
|
||||
<node id="5841747851381863262" at="25,38,26,18" concept="6" />
|
||||
<node id="5841747851381863158" at="31,20,32,18" concept="6" />
|
||||
<node id="5841747851381863164" at="34,55,35,19" concept="6" />
|
||||
<node id="5841747851381863177" at="36,5,37,0" concept="7" />
|
||||
<node id="5841747851381863178" at="37,0,38,29" concept="5" />
|
||||
<node id="5841747851381863196" at="39,67,40,19" concept="6" />
|
||||
<node id="5841747851381863219" at="42,30,43,19" concept="6" />
|
||||
<node id="5841747851381863221" at="44,5,45,0" concept="7" />
|
||||
<node id="5841747851381863222" at="45,0,46,16" concept="6" />
|
||||
<node id="5841747851381516267" at="49,0,50,0" concept="2" trace="id" />
|
||||
<node id="5841747851381516270" at="50,0,51,0" concept="2" trace="arity" />
|
||||
<node id="5841747851381516253" at="13,0,16,0" concept="4" trace="id#()Ljava/lang/String;" />
|
||||
<node id="5841747851381516260" at="17,0,20,0" concept="4" trace="arity#()I" />
|
||||
<node id="5841747851381863156" at="30,35,33,5" concept="3" />
|
||||
<node id="5841747851381863162" at="33,5,36,5" concept="3" />
|
||||
<node id="5841747851381863194" at="38,29,41,5" concept="3" />
|
||||
<node id="5841747851381863214" at="41,5,44,5" concept="3" />
|
||||
<node id="6317379717814128471" at="8,0,12,0" concept="0" trace="Symbol#(Ljava/lang/String;I)V" />
|
||||
<node id="5841747851381863224" at="21,0,28,0" concept="4" trace="hashCode#()I" />
|
||||
<node id="5841747851381863152" at="29,0,48,0" concept="4" trace="equals#(Ljava/lang/Object;)Z" />
|
||||
<scope id="5841747851381516256" at="13,22,14,14" />
|
||||
<scope id="5841747851381516263" at="17,22,18,17" />
|
||||
<scope id="5841747851381863157" at="31,20,32,18" />
|
||||
|
|
@ -137,10 +110,10 @@
|
|||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/6317379717814173903">
|
||||
<file name="PredicateSymbol.java">
|
||||
<node id="6317379717823619735" at="8,48,9,21" concept="12" />
|
||||
<node id="6317379717814175785" at="13,28,14,34" concept="8" />
|
||||
<node id="6317379717814174713" at="8,0,11,0" concept="1" trace="PredicateSymbol#(Ljava/lang/String;I)V" />
|
||||
<node id="6317379717814175781" at="12,0,16,0" concept="6" trace="toString#()Ljava/lang/String;" />
|
||||
<node id="6317379717823619735" at="8,48,9,21" concept="10" />
|
||||
<node id="6317379717814175785" at="13,28,14,34" concept="6" />
|
||||
<node id="6317379717814174713" at="8,0,11,0" concept="0" trace="PredicateSymbol#(Ljava/lang/String;I)V" />
|
||||
<node id="6317379717814175781" at="12,0,16,0" concept="4" trace="toString#()Ljava/lang/String;" />
|
||||
<scope id="6317379717814174717" at="8,48,9,21" />
|
||||
<scope id="6317379717814175784" at="13,28,14,34" />
|
||||
<scope id="6317379717814174713" at="8,0,11,0">
|
||||
|
|
@ -153,8 +126,8 @@
|
|||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/6317379717814244809">
|
||||
<file name="AndItem.java">
|
||||
<node id="6317379717815747154" at="9,0,10,0" concept="6" trace="symbol#()Ljetbrains/mps/logic/reactor/program/Symbol;" />
|
||||
<node id="6317379717814333446" at="11,0,12,0" concept="6" trace="arguments#()Ljava/util/Collection;" />
|
||||
<node id="6317379717815747154" at="9,0,10,0" concept="4" trace="symbol#()Ljetbrains/mps/logic/reactor/program/Symbol;" />
|
||||
<node id="6317379717814333446" at="11,0,12,0" concept="4" trace="arguments#()Ljava/util/Collection;" />
|
||||
<scope id="6317379717815747154" at="9,0,10,0" />
|
||||
<scope id="6317379717814333446" at="11,0,12,0" />
|
||||
<unit id="6317379717814244809" at="7,0,14,0" name="jetbrains.mps.logic.reactor.program.AndItem" />
|
||||
|
|
@ -162,13 +135,13 @@
|
|||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/6317379717817889711">
|
||||
<file name="JavaPredicateSymbol.java">
|
||||
<node id="1445804513729425338" at="8,0,9,0" concept="10" trace="EXPRESSION0" />
|
||||
<node id="1445804513729425524" at="10,0,11,0" concept="10" trace="EXPRESSION1" />
|
||||
<node id="1445804513729425633" at="12,0,13,0" concept="10" trace="EXPRESSION2" />
|
||||
<node id="1445804513729425764" at="14,0,15,0" concept="10" trace="EXPRESSION3" />
|
||||
<node id="1445804513728312018" at="16,0,17,0" concept="10" trace="EXPRESSION" />
|
||||
<node id="6317379717817889916" at="18,41,19,29" concept="12" />
|
||||
<node id="6317379717817889762" at="18,0,21,0" concept="1" trace="JavaPredicateSymbol#(I)V" />
|
||||
<node id="1445804513729425338" at="8,0,9,0" concept="8" trace="EXPRESSION0" />
|
||||
<node id="1445804513729425524" at="10,0,11,0" concept="8" trace="EXPRESSION1" />
|
||||
<node id="1445804513729425633" at="12,0,13,0" concept="8" trace="EXPRESSION2" />
|
||||
<node id="1445804513729425764" at="14,0,15,0" concept="8" trace="EXPRESSION3" />
|
||||
<node id="1445804513728312018" at="16,0,17,0" concept="8" trace="EXPRESSION" />
|
||||
<node id="6317379717817889916" at="18,41,19,29" concept="10" />
|
||||
<node id="6317379717817889762" at="18,0,21,0" concept="0" trace="JavaPredicateSymbol#(I)V" />
|
||||
<scope id="6317379717817889766" at="18,41,19,29" />
|
||||
<scope id="6317379717817889762" at="18,0,21,0">
|
||||
<var name="arity" id="6317379717817890807" />
|
||||
|
|
@ -178,9 +151,9 @@
|
|||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/7785665572546345623">
|
||||
<file name="Constraint.java">
|
||||
<node id="6317379717814333032" at="14,0,15,0" concept="6" trace="symbol#()Ljetbrains/mps/logic/reactor/program/ConstraintSymbol;" />
|
||||
<node id="8225968737376931639" at="16,0,17,0" concept="6" trace="argumentTypes#()Ljava/util/List;" />
|
||||
<node id="5649815580023740085" at="18,0,19,0" concept="6" trace="occurrenceArguments#(Ljetbrains/mps/logic/reactor/logical/LogicalContext;)Ljava/util/Collection;" />
|
||||
<node id="6317379717814333032" at="14,0,15,0" concept="4" trace="symbol#()Ljetbrains/mps/logic/reactor/program/ConstraintSymbol;" />
|
||||
<node id="8225968737376931639" at="16,0,17,0" concept="4" trace="argumentTypes#()Ljava/util/List;" />
|
||||
<node id="5649815580023740085" at="18,0,19,0" concept="4" trace="occurrenceArguments#(Ljetbrains/mps/logic/reactor/logical/LogicalContext;)Ljava/util/Collection;" />
|
||||
<scope id="6317379717814333032" at="14,0,15,0" />
|
||||
<scope id="8225968737376931639" at="16,0,17,0" />
|
||||
<scope id="5649815580023740085" at="18,0,19,0">
|
||||
|
|
@ -191,8 +164,8 @@
|
|||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/7785665572546359770">
|
||||
<file name="Predicate.java">
|
||||
<node id="7785665572546360338" at="13,0,14,0" concept="6" trace="symbol#()Ljetbrains/mps/logic/reactor/program/PredicateSymbol;" />
|
||||
<node id="5649815580025803455" at="15,0,16,0" concept="6" trace="invocationArguments#(Ljetbrains/mps/logic/reactor/logical/LogicalContext;)Ljava/util/Collection;" />
|
||||
<node id="7785665572546360338" at="13,0,14,0" concept="4" trace="symbol#()Ljetbrains/mps/logic/reactor/program/PredicateSymbol;" />
|
||||
<node id="5649815580025803455" at="15,0,16,0" concept="4" trace="invocationArguments#(Ljetbrains/mps/logic/reactor/logical/LogicalContext;)Ljava/util/Collection;" />
|
||||
<scope id="7785665572546360338" at="13,0,14,0" />
|
||||
<scope id="5649815580025803455" at="15,0,16,0">
|
||||
<var name="logicalContext" id="5649815580025803456" />
|
||||
|
|
@ -202,13 +175,13 @@
|
|||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/8335224865064895074">
|
||||
<file name="Rule.java">
|
||||
<node id="8335224865064895076" at="8,0,9,0" concept="6" trace="kind#()Ljetbrains/mps/logic/reactor/program/Rule/Kind;" />
|
||||
<node id="7303011777414843895" at="10,0,11,0" concept="6" trace="tag#()Ljava/lang/String;" />
|
||||
<node id="8335224865064895081" at="12,0,13,0" concept="6" trace="headKept#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895087" at="14,0,15,0" concept="6" trace="headReplaced#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895093" at="16,0,17,0" concept="6" trace="guard#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895099" at="18,0,19,0" concept="6" trace="body#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865065122390" at="20,0,21,0" concept="6" trace="all#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895076" at="8,0,9,0" concept="4" trace="kind#()Ljetbrains/mps/logic/reactor/program/Rule/Kind;" />
|
||||
<node id="7303011777414843895" at="10,0,11,0" concept="4" trace="tag#()Ljava/lang/String;" />
|
||||
<node id="8335224865064895081" at="12,0,13,0" concept="4" trace="headKept#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895087" at="14,0,15,0" concept="4" trace="headReplaced#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895093" at="16,0,17,0" concept="4" trace="guard#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895099" at="18,0,19,0" concept="4" trace="body#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865065122390" at="20,0,21,0" concept="4" trace="all#()Ljava/lang/Iterable;" />
|
||||
<scope id="8335224865064895076" at="8,0,9,0" />
|
||||
<scope id="7303011777414843895" at="10,0,11,0" />
|
||||
<scope id="8335224865064895081" at="12,0,13,0" />
|
||||
|
|
@ -220,186 +193,12 @@
|
|||
<unit id="8335224865064895074" at="6,0,30,0" name="jetbrains.mps.logic.reactor.program.Rule" />
|
||||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/8335224865064895129">
|
||||
<file name="RuleBuilder.java">
|
||||
<node id="7303011777414773402" at="12,34,13,19" concept="2" />
|
||||
<node id="8335224865064895145" at="17,43,18,24" concept="2" />
|
||||
<node id="8335224865064895162" at="19,5,20,16" concept="8" />
|
||||
<node id="8335224865064895174" at="24,43,25,25" concept="2" />
|
||||
<node id="8335224865064895191" at="26,5,27,16" concept="8" />
|
||||
<node id="8335224865064895200" at="31,42,32,31" concept="2" />
|
||||
<node id="8335224865064895217" at="33,5,34,16" concept="8" />
|
||||
<node id="8335224865064895229" at="38,42,39,27" concept="2" />
|
||||
<node id="8335224865064895246" at="40,5,41,16" concept="8" />
|
||||
<node id="8490564095238015565" at="44,28,45,61" concept="8" />
|
||||
<node id="8490564095238043833" at="48,29,49,30" concept="8" />
|
||||
<node id="8490564095238045470" at="52,28,53,29" concept="8" />
|
||||
<node id="2966490507992344509" at="56,50,57,19" concept="2" />
|
||||
<node id="8207393387016330175" at="57,19,58,16" concept="8" />
|
||||
<node id="8335224865064895256" at="61,88,62,55" concept="7" />
|
||||
<node id="8335224865064895261" at="63,61,64,71" concept="2" />
|
||||
<node id="4340821131296540362" at="64,71,65,0" concept="9" />
|
||||
<node id="8335224865064895276" at="66,43,67,74" concept="2" />
|
||||
<node id="4340821131296540379" at="67,74,68,0" concept="9" />
|
||||
<node id="8335224865064895290" at="69,39,70,71" concept="2" />
|
||||
<node id="4340821131296540396" at="70,71,71,0" concept="9" />
|
||||
<node id="8335224865064895296" at="72,12,73,82" concept="13" />
|
||||
<node id="8335224865064895300" at="74,5,75,0" concept="9" />
|
||||
<node id="8335224865064895303" at="76,25,77,82" concept="13" />
|
||||
<node id="8335224865064895310" at="78,5,79,0" concept="9" />
|
||||
<node id="8335224865064895311" at="79,0,80,54" concept="2" />
|
||||
<node id="8335224865064895316" at="80,54,81,62" concept="2" />
|
||||
<node id="8335224865064895321" at="81,62,82,48" concept="2" />
|
||||
<node id="8335224865064895326" at="82,48,83,46" concept="2" />
|
||||
<node id="8335224865064895331" at="83,46,84,0" concept="9" />
|
||||
<node id="8335224865064895332" at="84,0,85,43" concept="8" />
|
||||
<node id="4340821131296552508" at="89,28,90,115" concept="8" />
|
||||
<node id="2966490507992344455" at="94,44,95,37" concept="7" />
|
||||
<node id="2966490507992344461" at="95,37,96,0" concept="9" />
|
||||
<node id="2966490507992344462" at="96,0,97,48" concept="2" />
|
||||
<node id="2966490507992344469" at="97,48,98,40" concept="2" />
|
||||
<node id="2966490507992344476" at="98,40,99,34" concept="2" />
|
||||
<node id="2966490507992344483" at="99,34,100,32" concept="2" />
|
||||
<node id="8335224865064895343" at="106,82,107,23" concept="2" />
|
||||
<node id="7303011777414821015" at="107,23,108,21" concept="2" />
|
||||
<node id="8335224865064895356" at="111,65,112,18" concept="8" />
|
||||
<node id="7303011777414878706" at="116,25,117,17" concept="8" />
|
||||
<node id="8335224865064895366" at="121,44,122,22" concept="8" />
|
||||
<node id="8335224865064895374" at="126,48,127,26" concept="8" />
|
||||
<node id="8335224865064895382" at="131,40,132,19" concept="8" />
|
||||
<node id="8335224865064895390" at="136,37,137,18" concept="8" />
|
||||
<node id="8335224865065270680" at="141,36,142,67" concept="8" />
|
||||
<node id="8335224865064895393" at="145,0,146,0" concept="3" trace="kind" />
|
||||
<node id="7303011777414821011" at="146,0,147,0" concept="3" trace="tag" />
|
||||
<node id="7303011777414773398" at="149,0,150,0" concept="3" trace="tag" />
|
||||
<node id="8335224865064895397" at="150,0,151,0" concept="3" trace="headKept" />
|
||||
<node id="8335224865064895405" at="151,0,152,0" concept="3" trace="headReplaced" />
|
||||
<node id="8335224865064895413" at="152,0,153,0" concept="3" trace="guard" />
|
||||
<node id="8335224865064895421" at="153,0,154,0" concept="3" trace="body" />
|
||||
<node id="8335224865064895294" at="72,10,74,5" concept="0" />
|
||||
<node id="7303011777414747729" at="12,0,15,0" concept="1" trace="RuleBuilder#(Ljava/lang/String;)V" />
|
||||
<node id="8335224865064895143" at="16,50,19,5" concept="4" />
|
||||
<node id="8335224865064895172" at="23,53,26,5" concept="4" />
|
||||
<node id="8335224865064895198" at="30,60,33,5" concept="4" />
|
||||
<node id="8335224865064895227" at="37,56,40,5" concept="4" />
|
||||
<node id="8490564095237998215" at="44,0,47,0" concept="6" trace="hasHead#()Z" />
|
||||
<node id="8490564095238019402" at="48,0,51,0" concept="6" trace="hasGuard#()Z" />
|
||||
<node id="8490564095238045466" at="52,0,55,0" concept="6" trace="hasBody#()Z" />
|
||||
<node id="8335224865064895301" at="75,0,78,5" concept="5" />
|
||||
<node id="8335224865064895352" at="111,0,114,0" concept="6" trace="kind#()Ljetbrains/mps/logic/reactor/program/Rule/Kind;" />
|
||||
<node id="8207393387016228023" at="56,0,60,0" concept="6" trace="merge#(null)Ljetbrains/mps/logic/reactor/program/RuleBuilder;" />
|
||||
<node id="4340821131296548229" at="88,0,92,0" concept="6" trace="toString#()Ljava/lang/String;" />
|
||||
<node id="8335224865064895339" at="106,0,110,0" concept="1" trace="Rule#(Ljetbrains/mps/logic/reactor/program/Rule/Kind;Ljava/lang/String;)V" />
|
||||
<node id="7303011777414858647" at="115,0,119,0" concept="6" trace="tag#()Ljava/lang/String;" />
|
||||
<node id="8335224865064895361" at="120,0,124,0" concept="6" trace="headKept#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895369" at="125,0,129,0" concept="6" trace="headReplaced#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895377" at="130,0,134,0" concept="6" trace="guard#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895385" at="135,0,139,0" concept="6" trace="body#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865065133958" at="140,0,144,0" concept="6" trace="all#()Ljava/lang/Iterable;" />
|
||||
<node id="8335224865064895136" at="16,0,22,0" concept="6" trace="appendBody#(null)Ljetbrains/mps/logic/reactor/program/RuleBuilder;" />
|
||||
<node id="8335224865064895165" at="23,0,29,0" concept="6" trace="appendGuard#(null)Ljetbrains/mps/logic/reactor/program/RuleBuilder;" />
|
||||
<node id="8335224865064895194" at="30,0,36,0" concept="6" trace="appendHeadReplaced#(null)Ljetbrains/mps/logic/reactor/program/RuleBuilder;" />
|
||||
<node id="8335224865064895223" at="37,0,43,0" concept="6" trace="appendHeadKept#(null)Ljetbrains/mps/logic/reactor/program/RuleBuilder;" />
|
||||
<node id="2966490507992344450" at="93,46,101,5" concept="4" />
|
||||
<node id="2966490507992344504" at="93,0,103,0" concept="6" trace="doMerge#(null)V" />
|
||||
<node id="8335224865064895259" at="62,55,74,5" concept="5" />
|
||||
<node id="8335224865064895252" at="61,0,87,0" concept="6" trace="toRule#()Ljetbrains/mps/logic/reactor/program/Rule;" />
|
||||
<scope id="7303011777414747732" at="12,34,13,19" />
|
||||
<scope id="8335224865064895144" at="17,43,18,24" />
|
||||
<scope id="8335224865064895173" at="24,43,25,25" />
|
||||
<scope id="8335224865064895199" at="31,42,32,31" />
|
||||
<scope id="8335224865064895228" at="38,42,39,27" />
|
||||
<scope id="8490564095237998219" at="44,28,45,61" />
|
||||
<scope id="8490564095238019405" at="48,29,49,30" />
|
||||
<scope id="8490564095238045469" at="52,28,53,29" />
|
||||
<scope id="8335224865064895295" at="72,12,73,82" />
|
||||
<scope id="8335224865064895302" at="76,25,77,82" />
|
||||
<scope id="4340821131296548233" at="89,28,90,115" />
|
||||
<scope id="8335224865064895355" at="111,65,112,18" />
|
||||
<scope id="7303011777414858651" at="116,25,117,17" />
|
||||
<scope id="8335224865064895365" at="121,44,122,22" />
|
||||
<scope id="8335224865064895373" at="126,48,127,26" />
|
||||
<scope id="8335224865064895381" at="131,40,132,19" />
|
||||
<scope id="8335224865064895389" at="136,37,137,18" />
|
||||
<scope id="8335224865065133963" at="141,36,142,67" />
|
||||
<scope id="8207393387016228026" at="56,50,58,16" />
|
||||
<scope id="8335224865064895260" at="63,61,65,0" />
|
||||
<scope id="8335224865064895275" at="66,43,68,0" />
|
||||
<scope id="8335224865064895289" at="69,39,71,0" />
|
||||
<scope id="8335224865064895342" at="106,82,108,21" />
|
||||
<scope id="7303011777414747729" at="12,0,15,0">
|
||||
<var name="tag" id="7303011777414773101" />
|
||||
</scope>
|
||||
<scope id="8335224865064895143" at="16,50,19,5">
|
||||
<var name="i" id="8335224865064895152" />
|
||||
</scope>
|
||||
<scope id="8335224865064895172" at="23,53,26,5">
|
||||
<var name="i" id="8335224865064895181" />
|
||||
</scope>
|
||||
<scope id="8335224865064895198" at="30,60,33,5">
|
||||
<var name="i" id="8335224865064895207" />
|
||||
</scope>
|
||||
<scope id="8335224865064895227" at="37,56,40,5">
|
||||
<var name="i" id="8335224865064895236" />
|
||||
</scope>
|
||||
<scope id="8490564095237998215" at="44,0,47,0" />
|
||||
<scope id="8490564095238019402" at="48,0,51,0" />
|
||||
<scope id="8490564095238045466" at="52,0,55,0" />
|
||||
<scope id="8335224865064895352" at="111,0,114,0" />
|
||||
<scope id="8335224865064895142" at="16,50,20,16" />
|
||||
<scope id="8335224865064895171" at="23,53,27,16" />
|
||||
<scope id="8335224865064895197" at="30,60,34,16" />
|
||||
<scope id="8335224865064895226" at="37,56,41,16" />
|
||||
<scope id="8207393387016228023" at="56,0,60,0">
|
||||
<var name="other" id="8207393387016238232" />
|
||||
</scope>
|
||||
<scope id="4340821131296548229" at="88,0,92,0" />
|
||||
<scope id="8335224865064895339" at="106,0,110,0">
|
||||
<var name="kind" id="8335224865064895349" />
|
||||
<var name="tag" id="7303011777414819208" />
|
||||
</scope>
|
||||
<scope id="7303011777414858647" at="115,0,119,0" />
|
||||
<scope id="8335224865064895361" at="120,0,124,0" />
|
||||
<scope id="8335224865064895369" at="125,0,129,0" />
|
||||
<scope id="8335224865064895377" at="130,0,134,0" />
|
||||
<scope id="8335224865064895385" at="135,0,139,0" />
|
||||
<scope id="8335224865065133958" at="140,0,144,0" />
|
||||
<scope id="8335224865064895136" at="16,0,22,0">
|
||||
<var name="item" id="8335224865064895137" />
|
||||
</scope>
|
||||
<scope id="8335224865064895165" at="23,0,29,0">
|
||||
<var name="pred" id="8335224865064895166" />
|
||||
</scope>
|
||||
<scope id="8335224865064895194" at="30,0,36,0">
|
||||
<var name="cst" id="8335224865064895219" />
|
||||
</scope>
|
||||
<scope id="8335224865064895223" at="37,0,43,0">
|
||||
<var name="cst" id="8335224865064895248" />
|
||||
</scope>
|
||||
<scope id="2966490507992344454" at="94,44,100,32">
|
||||
<var name="toMerge" id="2966490507992344456" />
|
||||
</scope>
|
||||
<scope id="2966490507992344449" at="93,46,101,5" />
|
||||
<scope id="2966490507992344450" at="93,46,101,5">
|
||||
<var name="i" id="2966490507992344451" />
|
||||
</scope>
|
||||
<scope id="2966490507992344504" at="93,0,103,0">
|
||||
<var name="other" id="2966490507992344497" />
|
||||
</scope>
|
||||
<scope id="8335224865064895255" at="61,88,85,43">
|
||||
<var name="kind" id="8335224865064895257" />
|
||||
</scope>
|
||||
<scope id="8335224865064895252" at="61,0,87,0" />
|
||||
<unit id="8335224865064895337" at="104,0,148,0" name="jetbrains.mps.logic.reactor.program.RuleBuilder$Rule" />
|
||||
<unit id="8335224865064895129" at="10,0,155,0" name="jetbrains.mps.logic.reactor.program.RuleBuilder" />
|
||||
</file>
|
||||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/9010599623174261813">
|
||||
<file name="InvalidRuleException.java">
|
||||
<node id="9010599623174265602" at="8,47,9,19" concept="12" />
|
||||
<node id="9010599623174269829" at="12,68,13,30" concept="12" />
|
||||
<node id="9010599623174265548" at="8,0,11,0" concept="1" trace="InvalidRuleException#(Ljava/lang/String;)V" />
|
||||
<node id="9010599623174269823" at="12,0,15,0" concept="1" trace="InvalidRuleException#(Ljava/lang/String;Ljava/lang/Throwable;)V" />
|
||||
<node id="9010599623174265602" at="8,47,9,19" concept="10" />
|
||||
<node id="9010599623174269829" at="12,68,13,30" concept="10" />
|
||||
<node id="9010599623174265548" at="8,0,11,0" concept="0" trace="InvalidRuleException#(Ljava/lang/String;)V" />
|
||||
<node id="9010599623174269823" at="12,0,15,0" concept="0" trace="InvalidRuleException#(Ljava/lang/String;Ljava/lang/Throwable;)V" />
|
||||
<scope id="9010599623174265552" at="8,47,9,19" />
|
||||
<scope id="9010599623174269828" at="12,68,13,30" />
|
||||
<scope id="9010599623174265548" at="8,0,11,0">
|
||||
|
|
@ -414,10 +213,10 @@
|
|||
</root>
|
||||
<root nodeRef="r:f43ee4a0-488a-425a-87a0-594ab3b0d15f(jetbrains.mps.logic.reactor.program)/9010599623176680927">
|
||||
<file name="InvalidConstraintException.java">
|
||||
<node id="9010599623176682194" at="8,53,9,19" concept="12" />
|
||||
<node id="9010599623176682617" at="12,67,13,23" concept="12" />
|
||||
<node id="9010599623176682144" at="8,0,11,0" concept="1" trace="InvalidConstraintException#(Ljava/lang/String;)V" />
|
||||
<node id="9010599623176682613" at="12,0,15,0" concept="1" trace="InvalidConstraintException#(Ljava/lang/String;Ljava/lang/Throwable;)V" />
|
||||
<node id="9010599623176682194" at="8,53,9,19" concept="10" />
|
||||
<node id="9010599623176682617" at="12,67,13,23" concept="10" />
|
||||
<node id="9010599623176682144" at="8,0,11,0" concept="0" trace="InvalidConstraintException#(Ljava/lang/String;)V" />
|
||||
<node id="9010599623176682613" at="12,0,15,0" concept="0" trace="InvalidConstraintException#(Ljava/lang/String;Ljava/lang/Throwable;)V" />
|
||||
<scope id="9010599623176682148" at="8,53,9,19" />
|
||||
<scope id="9010599623176682616" at="12,67,13,23" />
|
||||
<scope id="9010599623176682144" at="8,0,11,0">
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import jetbrains.mps.logic.reactor.evaluation.PredicateInvocation
|
|||
import jetbrains.mps.logic.reactor.evaluation.SessionSolver
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalContext
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.logical.MetaLogical
|
||||
import jetbrains.mps.logic.reactor.program.*
|
||||
import java.util.*
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ class Handler : Matcher.AuxOccurrences {
|
|||
}
|
||||
|
||||
private val noLogicalContext: LogicalContext = object: LogicalContext {
|
||||
override fun <V : Any> variable(logicalPattern: LogicalPattern<V>): Logical<V> = TODO()
|
||||
override fun <V : Any> variable(metaLogical: MetaLogical<V>): Logical<V> = TODO()
|
||||
}
|
||||
|
||||
private fun Predicate.invocation(logicalContext: LogicalContext): PredicateInvocation = object: PredicateInvocation {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
package jetbrains.mps.logic.reactor.core
|
||||
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.logical.NamingContext
|
||||
import jetbrains.mps.logic.reactor.logical.MetaLogical
|
||||
import jetbrains.mps.logic.reactor.logical.SolverLogical
|
||||
import java.util.*
|
||||
|
||||
|
|
@ -29,9 +28,9 @@ fun Logical<*>.removeObserver(observer: LogicalObserver) {
|
|||
(this as MemLogical<*>).parentObservers.removeAll { p -> p.second == observer }
|
||||
}
|
||||
|
||||
fun <V> LogicalPattern<V>.logical(): Logical<V> = MemLogical<V>(name())
|
||||
fun <V> MetaLogical<V>.logical(): Logical<V> = MemLogical<V>(this)
|
||||
|
||||
fun <V> LogicalPattern<V>.logical(value: V): Logical<V> = MemLogical<V>(name(), value)
|
||||
fun <V> MetaLogical<V>.logical(value: V): Logical<V> = MemLogical<V>(name(), value)
|
||||
|
||||
class MemLogical<T> : SolverLogical<T> {
|
||||
|
||||
|
|
@ -41,7 +40,7 @@ class MemLogical<T> : SolverLogical<T> {
|
|||
|
||||
val name: String
|
||||
|
||||
val pattern: LogicalPattern<T>
|
||||
val metaLogical: MetaLogical<T>
|
||||
|
||||
var _parent: MemLogical<T>? = null
|
||||
|
||||
|
|
@ -55,24 +54,24 @@ class MemLogical<T> : SolverLogical<T> {
|
|||
|
||||
constructor(value: T) {
|
||||
this.name = "$${++lastIdx}"
|
||||
this.pattern = DefaultLogicalPattern<T>(name)
|
||||
this.metaLogical = DefaultMetaLogical<T>(name)
|
||||
this._value = value
|
||||
}
|
||||
|
||||
constructor(name: String) {
|
||||
this.name = "${name}_${++lastIdx}"
|
||||
this.pattern = DefaultLogicalPattern<T>(name)
|
||||
this.metaLogical = DefaultMetaLogical<T>(name)
|
||||
}
|
||||
|
||||
constructor(name: String, value: T) {
|
||||
this.name = "${name}_${++lastIdx}"
|
||||
this.pattern = DefaultLogicalPattern<T>(name)
|
||||
this.metaLogical = DefaultMetaLogical<T>(name)
|
||||
this._value = value
|
||||
}
|
||||
|
||||
constructor(pattern: LogicalPattern<T>) {
|
||||
this.pattern = pattern
|
||||
this.name = "${pattern.name()}_${++lastIdx}"
|
||||
constructor(metaLogical: MetaLogical<T>) {
|
||||
this.metaLogical = metaLogical
|
||||
this.name = "${metaLogical.name()}_${++lastIdx}"
|
||||
}
|
||||
|
||||
override fun name(): String = name
|
||||
|
|
@ -83,7 +82,7 @@ class MemLogical<T> : SolverLogical<T> {
|
|||
|
||||
override fun isWildcard(): Boolean = TODO()
|
||||
|
||||
override fun pattern(): LogicalPattern<T> = pattern
|
||||
override fun metaLogical(): MetaLogical<T> = metaLogical
|
||||
|
||||
override fun findRoot(): SolverLogical<T> = find()
|
||||
|
||||
|
|
@ -187,16 +186,12 @@ class MemLogical<T> : SolverLogical<T> {
|
|||
|
||||
}
|
||||
|
||||
data class DefaultLogicalPattern<V> (val name: String) : LogicalPattern<V> {
|
||||
class DefaultMetaLogical<V> (val name: String) : MetaLogical<V>(name, Object::class.java as Class<V>) {
|
||||
|
||||
override fun name(): String? {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun name(namingContext: NamingContext?): String? {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun isWildcard(): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
|
@ -205,7 +200,4 @@ data class DefaultLogicalPattern<V> (val name: String) : LogicalPattern<V> {
|
|||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun instance(): Logical<V>? {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
|||
import jetbrains.mps.logic.reactor.evaluation.MatchRule
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalContext
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.logical.MetaLogical
|
||||
import jetbrains.mps.logic.reactor.program.Constraint
|
||||
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
|
||||
import jetbrains.mps.logic.reactor.program.Rule
|
||||
|
|
@ -78,11 +78,11 @@ class RuleTerm(rule: Rule) :
|
|||
Function(rule.tag(), (rule.headKept() + rule.headReplaced()).map { c -> ConstraintTerm(c) }) {}
|
||||
|
||||
/** Function term with arguments == constraint arguments converted to terms.
|
||||
* LogicalPattern arguments are term variables.
|
||||
* MetaLogical arguments are term variables.
|
||||
* Everything else is either a term or a constant wrapping the value. */
|
||||
class ConstraintTerm(constraint: Constraint) :
|
||||
Function(constraint.symbol(),
|
||||
constraint.arguments().map { arg -> if (arg is LogicalPattern<*>) Variable(arg) else asTerm(arg) }) {}
|
||||
constraint.arguments().map { arg -> if (arg is MetaLogical<*>) Variable(arg) else asTerm(arg) }) {}
|
||||
|
||||
/** Function term with arguments == terms corresponding to constraint occurrences. Never contains variables. */
|
||||
class PartialMatchTerm(pm : PartialMatch) :
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import com.github.andrewoma.dexx.collection.ConsList
|
|||
import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalContext
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.program.Constraint
|
||||
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
|
||||
import java.util.*
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
|||
import jetbrains.mps.logic.reactor.evaluation.MatchRule
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalContext
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.logical.MetaLogical
|
||||
import jetbrains.mps.logic.reactor.program.Constraint
|
||||
import jetbrains.mps.logic.reactor.program.Rule
|
||||
import jetbrains.mps.unification.Unification
|
||||
|
|
@ -23,7 +23,7 @@ class PartialMatch(val rule: Rule, val profiler: Profiler? = null) : MatchRule {
|
|||
private set
|
||||
var discarded = emptyConsList<Pair<Constraint, ConstraintOccurrence>>()
|
||||
private set
|
||||
var pattern2logical = Maps.of<LogicalPattern<*>, PersSet<Logical<*>>>()
|
||||
var meta2logical = Maps.of<MetaLogical<*>, PersSet<Logical<*>>>()
|
||||
private set
|
||||
private lateinit var logicalContext : LogicalContext
|
||||
|
||||
|
|
@ -35,12 +35,12 @@ class PartialMatch(val rule: Rule, val profiler: Profiler? = null) : MatchRule {
|
|||
this.kept = if (keep != null) original.kept.prepend(keep) else original.kept
|
||||
this.discarded = if (discard != null) original.discarded.prepend(discard) else original.discarded
|
||||
|
||||
this.pattern2logical = original.pattern2logical
|
||||
this.meta2logical = original.meta2logical
|
||||
val pair = keep ?: discard!!
|
||||
for ((ptr, log) in pair.first.arguments().zip(pair.second.arguments())) {
|
||||
if (ptr is LogicalPattern<*> && log is Logical<*>) {
|
||||
val logSet = pattern2logical.get(ptr)
|
||||
this.pattern2logical = pattern2logical.put(ptr, logSet?.add(log.findRoot()) ?: Sets.of(log.findRoot()))
|
||||
if (ptr is MetaLogical<*> && log is Logical<*>) {
|
||||
val logSet = meta2logical.get(ptr)
|
||||
this.meta2logical = meta2logical.put(ptr, logSet?.add(log.findRoot()) ?: Sets.of(log.findRoot()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -72,8 +72,8 @@ class PartialMatch(val rule: Rule, val profiler: Profiler? = null) : MatchRule {
|
|||
val values = HashSet<Any>()
|
||||
|
||||
for (arg in cst.arguments()) {
|
||||
if (arg is LogicalPattern<*>)
|
||||
pattern2logical.get(arg)?.let { logSet -> logicals.addAll(logSet) }
|
||||
if (arg is MetaLogical<*>)
|
||||
meta2logical.get(arg)?.let { logSet -> logicals.addAll(logSet) }
|
||||
else
|
||||
values.add(arg!!)
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ class PartialMatch(val rule: Rule, val profiler: Profiler? = null) : MatchRule {
|
|||
return false
|
||||
}
|
||||
|
||||
// variables come from LogicalPattern instances in rules
|
||||
// variables come from MetaLogical instances in rules
|
||||
// any successful binding results in either new Logical with associated value,
|
||||
// or a new value for a Logical already existing in this context
|
||||
|
||||
|
|
@ -128,24 +128,24 @@ class PartialMatch(val rule: Rule, val profiler: Profiler? = null) : MatchRule {
|
|||
// thus triangular form never has variables on the right hand side
|
||||
this.logicalContext = object: LogicalContext {
|
||||
|
||||
// invariant: the variables in substitution bindings can only be instances of LogicalPattern
|
||||
val ptr2val: MutableMap<LogicalPattern<*>, Any?> = HashMap(subst.bindings().map { b ->
|
||||
(b.`var`().symbol() as LogicalPattern<Any>).to(b.term().toValue())
|
||||
// invariant: the variables in substitution bindings can only be instances of MetaLogical
|
||||
val ptr2val: MutableMap<MetaLogical<*>, Any?> = HashMap(subst.bindings().map { b ->
|
||||
(b.`var`().symbol() as MetaLogical<Any>).to(b.term().toValue())
|
||||
}.toMap())
|
||||
|
||||
val ptr2log: MutableMap<LogicalPattern<*>, Logical<*>> = HashMap()
|
||||
val ptr2log: MutableMap<MetaLogical<*>, Logical<*>> = HashMap()
|
||||
|
||||
override fun <V : Any> variable(logicalPattern: LogicalPattern<V>): Logical<V> {
|
||||
if (!ptr2log.containsKey(logicalPattern)) {
|
||||
if (ptr2val.containsKey(logicalPattern)) {
|
||||
val value = ptr2val[logicalPattern]
|
||||
ptr2log[logicalPattern] = if (value is Logical<*>) value else MemLogical(value)
|
||||
override fun <V : Any> variable(metaLogical: MetaLogical<V>): Logical<V> {
|
||||
if (!ptr2log.containsKey(metaLogical)) {
|
||||
if (ptr2val.containsKey(metaLogical)) {
|
||||
val value = ptr2val[metaLogical]
|
||||
ptr2log[metaLogical] = if (value is Logical<*>) value else MemLogical(value)
|
||||
}
|
||||
else {
|
||||
ptr2log[logicalPattern] = logicalPattern.logical()
|
||||
ptr2log[metaLogical] = metaLogical.logical()
|
||||
}
|
||||
}
|
||||
return ptr2log[logicalPattern] as Logical<V>
|
||||
return ptr2log[metaLogical] as Logical<V>
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package jetbrains.mps.logic.reactor.core
|
||||
|
||||
import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.program.Constraint
|
||||
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
|
||||
import jetbrains.mps.logic.reactor.program.Rule
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package program
|
|||
|
||||
import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalContext
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.logical.MetaLogical
|
||||
import jetbrains.mps.logic.reactor.program.Constraint
|
||||
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
|
||||
import java.util.*
|
||||
|
|
@ -18,7 +18,7 @@ data class MemConstraint(val symbol: ConstraintSymbol, val arguments: List<Any>)
|
|||
override fun arguments(): List<Any> = arguments
|
||||
|
||||
override fun occurrenceArguments(logicalContext: LogicalContext): Collection<*> = arguments.map { a ->
|
||||
if (a is LogicalPattern<*>) logicalContext.variable(a)
|
||||
if (a is MetaLogical<*>) logicalContext.variable(a)
|
||||
else a
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
package program
|
||||
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.logical.NamingContext
|
||||
|
||||
/**
|
||||
* @author Fedor Isakov
|
||||
*/
|
||||
|
||||
data class MemLogicalPattern<V>(val name: String, val type: Class<V>, val wildcard: Boolean) : LogicalPattern<V> {
|
||||
|
||||
constructor(name: String, type: Class<V>) : this(name, type, false) {}
|
||||
|
||||
override fun name(): String = name
|
||||
|
||||
override fun name(namingContext: NamingContext): String = TODO()
|
||||
|
||||
override fun isWildcard(): Boolean = wildcard
|
||||
|
||||
override fun type(): Class<V> = type
|
||||
|
||||
override fun instance(): Logical<V> {
|
||||
// FIXME wrong
|
||||
throw UnsupportedOperationException("fixme")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,25 +9,70 @@ import program.MemConstraint
|
|||
import java.util.*
|
||||
import java.util.Collections.*
|
||||
|
||||
class MemProgramBuilder(val sessionSolver: SessionSolver) : ProgramBuilder() {
|
||||
class MemProgramBuilder(val sessionSolver: SessionSolver) {
|
||||
|
||||
private val rules = ArrayList<Rule>()
|
||||
|
||||
private val registry = ConstraintRegistry(sessionSolver)
|
||||
|
||||
override fun program(name: String, sessionSolver: SessionSolver): Program = MemProgram(name, ArrayList(rules), sessionSolver, registry)
|
||||
fun program(name: String, sessionSolver: SessionSolver): Program = MemProgram(name, ArrayList(rules), sessionSolver, registry)
|
||||
|
||||
override fun addRule(rule: Rule) {
|
||||
fun addRule(rule: Rule) {
|
||||
registry.update(rule)
|
||||
rules.add(rule)
|
||||
}
|
||||
|
||||
override fun constraint(symbol: ConstraintSymbol, vararg args: Any): Constraint = MemConstraint(symbol, listOf(* args))
|
||||
fun constraint(symbol: ConstraintSymbol, vararg args: Any): Constraint = MemConstraint(symbol, listOf(* args))
|
||||
|
||||
override fun predicate(symbol: PredicateSymbol, vararg args: Any?): Predicate = TODO()
|
||||
fun predicate(symbol: PredicateSymbol, vararg args: Any?): Predicate = TODO()
|
||||
|
||||
}
|
||||
|
||||
open class RuleBuilder(val tag: String) {
|
||||
val kept = ArrayList<Constraint>()
|
||||
val replaced = ArrayList<Constraint>()
|
||||
val guard = ArrayList<Predicate>()
|
||||
val body = ArrayList<AndItem>()
|
||||
|
||||
fun appendHeadKept(vararg cst: Constraint) {
|
||||
kept.addAll(cst)
|
||||
}
|
||||
fun appendHeadReplaced(vararg cst: Constraint) {
|
||||
replaced.addAll(cst)
|
||||
}
|
||||
fun appendGuard(vararg prd: Predicate) {
|
||||
guard.addAll(prd)
|
||||
}
|
||||
fun appendBody(vararg andItem: AndItem) {
|
||||
body.addAll(andItem)
|
||||
}
|
||||
fun toRule(): Rule = MemRule(tag, kept, replaced, guard, body)
|
||||
}
|
||||
|
||||
class MemRule(
|
||||
val tag: String,
|
||||
val kept: Collection<Constraint>,
|
||||
val replaced: Collection<Constraint>,
|
||||
val guard: Collection<Predicate>,
|
||||
val body: Collection<AndItem>) : Rule() {
|
||||
|
||||
override fun kind(): Kind = TODO()
|
||||
|
||||
override fun tag(): String = tag
|
||||
|
||||
override fun headKept(): Iterable<Constraint> = kept
|
||||
|
||||
override fun headReplaced(): Iterable<Constraint> = replaced
|
||||
|
||||
override fun guard(): Iterable<Predicate> = guard
|
||||
|
||||
override fun body(): Iterable<AndItem> = body
|
||||
|
||||
override fun all(): Iterable<AndItem> =
|
||||
if (body.isEmpty()) throw InvalidRuleException("no body")
|
||||
else (kept + replaced).map { it as AndItem } + guard + body
|
||||
}
|
||||
|
||||
class MemProgram(val name: String, val myRules : List<Rule>, val sessionSolver: SessionSolver, val registry: ConstraintRegistry) : Program() {
|
||||
|
||||
override fun name(): String = name
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import jetbrains.mps.logic.reactor.evaluation.PredicateInvocation
|
|||
import jetbrains.mps.logic.reactor.evaluation.Queryable
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalContext
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.logical.MetaLogical
|
||||
import jetbrains.mps.logic.reactor.program.*
|
||||
import java.util.*
|
||||
|
||||
|
|
@ -15,20 +15,20 @@ fun expression(body: () -> Boolean): ConjBuilder.() -> Unit = {
|
|||
add(JavaPredicateSymbol(1).withCode(body))
|
||||
}
|
||||
|
||||
fun <X, LX: Logical<X>, LPX: LogicalPattern<X>>
|
||||
fun <X, LX: Logical<X>, LPX: MetaLogical<X>>
|
||||
expression(body: (LX) -> Boolean, x: LPX): ConjBuilder.() -> Unit = {
|
||||
add(JavaPredicateSymbol(2).withCode(body, x))
|
||||
}
|
||||
|
||||
fun <X, LX: Logical<X>, LPX: LogicalPattern<X>,
|
||||
Y, LY: Logical<Y>, LPY: LogicalPattern<Y>>
|
||||
fun <X, LX: Logical<X>, LPX: MetaLogical<X>,
|
||||
Y, LY: Logical<Y>, LPY: MetaLogical<Y>>
|
||||
expression(body: (LX, LY) -> Boolean, x: LPX, y: LPY): ConjBuilder.() -> Unit = {
|
||||
add(JavaPredicateSymbol(3).withCode(body, x, y))
|
||||
}
|
||||
|
||||
fun <X, LX: Logical<X>, LPX: LogicalPattern<X>,
|
||||
Y, LY: Logical<Y>, LPY: LogicalPattern<Y>,
|
||||
Z, LZ: Logical<Z>, LPZ: LogicalPattern<Z>>
|
||||
fun <X, LX: Logical<X>, LPX: MetaLogical<X>,
|
||||
Y, LY: Logical<Y>, LPY: MetaLogical<Y>,
|
||||
Z, LZ: Logical<Z>, LPZ: MetaLogical<Z>>
|
||||
expression(body: (LX, LY, LZ) -> Boolean, x: LPX, y: LPY, z: LPZ): ConjBuilder.() -> Unit = {
|
||||
add(JavaPredicateSymbol(4).withCode(body, x, y, z))
|
||||
}
|
||||
|
|
@ -37,21 +37,21 @@ fun statement(body: () -> Unit): ConjBuilder.() -> Unit = {
|
|||
add(JavaPredicateSymbol(1).withCode { body.invoke(); true })
|
||||
}
|
||||
|
||||
fun <X, LPX: LogicalPattern<X>>
|
||||
fun <X, LPX: MetaLogical<X>>
|
||||
statement(
|
||||
body: (Logical<X>) -> Unit, x: LPX): ConjBuilder.() -> Unit = {
|
||||
add(JavaPredicateSymbol(2).withCode({ x -> body.invoke(x); true }, x))
|
||||
}
|
||||
|
||||
fun <X, LPX: LogicalPattern<X>,
|
||||
Y, LPY: LogicalPattern<Y>>
|
||||
fun <X, LPX: MetaLogical<X>,
|
||||
Y, LPY: MetaLogical<Y>>
|
||||
statement(body: (Logical<X>, Logical<Y>) -> Unit, x: LPX, y: LPY): ConjBuilder.() -> Unit = {
|
||||
add(JavaPredicateSymbol(3).withCode({ x, y -> body.invoke(x, y); true }, x, y))
|
||||
}
|
||||
|
||||
fun <X, LPX: LogicalPattern<X>,
|
||||
Y, LPY: LogicalPattern<Y>,
|
||||
Z, LPZ: LogicalPattern<Z>>
|
||||
fun <X, LPX: MetaLogical<X>,
|
||||
Y, LPY: MetaLogical<Y>,
|
||||
Z, LPZ: MetaLogical<Z>>
|
||||
statement(body: (Logical<X>, Logical<Y>, Logical<Z>) -> Unit, x: LPX, y: LPY, z: LPZ): ConjBuilder.() -> Unit = {
|
||||
add(JavaPredicateSymbol(4).withCode({ x, y, z -> body.invoke(x, y, z); true }, x, y, z))
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ data class TestJavaPredicate(val symbol: JavaPredicateSymbol, val expr: JavaExpr
|
|||
override fun symbol(): PredicateSymbol = symbol
|
||||
|
||||
override fun invocationArguments(logicalContext: LogicalContext): Collection<*> = args.map { a ->
|
||||
if (a is LogicalPattern<*>) logicalContext.variable(a)
|
||||
if (a is MetaLogical<*>) logicalContext.variable(a)
|
||||
else a
|
||||
}
|
||||
}
|
||||
|
|
@ -108,18 +108,18 @@ data class TestJavaPredicate(val symbol: JavaPredicateSymbol, val expr: JavaExpr
|
|||
private fun JavaPredicateSymbol.withCode(code: () -> Boolean) =
|
||||
TestJavaPredicate(this, JavaExpression0(code), listOf(System.identityHashCode(code)))
|
||||
|
||||
private fun <X, LX: Logical<X>, LPX: LogicalPattern<X>>
|
||||
private fun <X, LX: Logical<X>, LPX: MetaLogical<X>>
|
||||
JavaPredicateSymbol.withCode(code: (LX) -> Boolean, x: LPX) =
|
||||
TestJavaPredicate(this, JavaExpression1(code), listOf(System.identityHashCode(code), x))
|
||||
|
||||
private fun <X, LX: Logical<X>, LPX: LogicalPattern<X>,
|
||||
Y, LY: Logical<Y>, LPY: LogicalPattern<Y>>
|
||||
private fun <X, LX: Logical<X>, LPX: MetaLogical<X>,
|
||||
Y, LY: Logical<Y>, LPY: MetaLogical<Y>>
|
||||
JavaPredicateSymbol.withCode(code: (LX, LY) -> Boolean, x: LPX, y: LPY) =
|
||||
TestJavaPredicate(this, JavaExpression2(code), listOf(System.identityHashCode(code), x, y))
|
||||
|
||||
private fun <X, LX: Logical<X>, LPX: LogicalPattern<X>,
|
||||
Y, LY: Logical<Y>, LPY: LogicalPattern<Y>,
|
||||
Z, LZ: Logical<Z>, LPZ: LogicalPattern<Z>>
|
||||
private fun <X, LX: Logical<X>, LPX: MetaLogical<X>,
|
||||
Y, LY: Logical<Y>, LPY: MetaLogical<Y>,
|
||||
Z, LZ: Logical<Z>, LPZ: MetaLogical<Z>>
|
||||
JavaPredicateSymbol.withCode(code: (LX, LY, LZ) -> Boolean, x: LPX, y: LPY, z: LPZ) =
|
||||
TestJavaPredicate(this, JavaExpression3(code), listOf(System.identityHashCode(code), x, y, z))
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import jetbrains.mps.logic.reactor.evaluation.PredicateInvocation
|
|||
import jetbrains.mps.logic.reactor.logical.*
|
||||
import jetbrains.mps.logic.reactor.program.Predicate
|
||||
import jetbrains.mps.logic.reactor.program.PredicateSymbol
|
||||
import program.MemLogicalPattern
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
|
|
@ -21,16 +20,16 @@ fun <T: Any> logical(name1: String, name2: String) = Pair(MemLogical<T>(name1),
|
|||
fun <T: Any> logical(name1: String, name2: String, name3: String) =
|
||||
Triple(MemLogical<T>(name1), MemLogical<T>(name2), MemLogical<T>(name3))
|
||||
|
||||
inline fun <reified T: Any> logicalPattern(name: String) = MemLogicalPattern<T>(name, T::class.java)
|
||||
inline fun <reified T: Any> metaLogical(name: String) = MetaLogical<T>(name, T::class.java)
|
||||
|
||||
inline fun <reified T: Any> logicalPattern(name1: String, name2: String) =
|
||||
Pair(MemLogicalPattern<T>(name1, T::class.java), MemLogicalPattern<T>(name2, T::class.java))
|
||||
inline fun <reified T: Any> metaLogical(name1: String, name2: String) =
|
||||
Pair(MetaLogical<T>(name1, T::class.java), MetaLogical<T>(name2, T::class.java))
|
||||
|
||||
inline fun <reified T: Any> logicalPattern(name1: String, name2: String, name3: String) =
|
||||
inline fun <reified T: Any> metaLogical(name1: String, name2: String, name3: String) =
|
||||
Triple(
|
||||
MemLogicalPattern<T>(name1, T::class.java),
|
||||
MemLogicalPattern<T>(name2, T::class.java),
|
||||
MemLogicalPattern<T>(name3, T::class.java))
|
||||
MetaLogical<T>(name1, T::class.java),
|
||||
MetaLogical<T>(name2, T::class.java),
|
||||
MetaLogical<T>(name3, T::class.java))
|
||||
|
||||
fun <T: Any> Logical<T>.get(): T = findRoot().value()
|
||||
|
||||
|
|
@ -71,7 +70,7 @@ data class TestEqPredicate(val left: Any, val right: Any) : Predicate {
|
|||
override fun symbol(): PredicateSymbol = PredicateSymbol("equals", 2)
|
||||
|
||||
override fun invocationArguments(logicalContext: LogicalContext): Collection<*> = listOf(left, right).map { a ->
|
||||
if (a is LogicalPattern<*>) logicalContext.variable(a)
|
||||
if (a is MetaLogical<*>) logicalContext.variable(a)
|
||||
else a
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalContext
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.program.*
|
||||
import program.MemConstraint
|
||||
import TestConstraintOccurrence
|
||||
|
|
@ -15,7 +14,7 @@ import java.util.*
|
|||
class Builder(val env: Environment, val rules: List<Rule>) {
|
||||
}
|
||||
|
||||
class Environment(val programBuilder: ProgramBuilder? = null) {
|
||||
class Environment(val programBuilder: MemProgramBuilder? = null) {
|
||||
val equalsSolver = EqualsSolver()
|
||||
val expressionSolver = ExpressionSolver()
|
||||
}
|
||||
|
|
@ -24,7 +23,7 @@ fun program(vararg ruleBuilders : Environment.() -> Rule): Builder {
|
|||
return builder(Environment(), ruleBuilders)
|
||||
}
|
||||
|
||||
fun program(pb: ProgramBuilder, vararg ruleBuilders : Environment.() -> Rule): Builder {
|
||||
fun program(pb: MemProgramBuilder, vararg ruleBuilders : Environment.() -> Rule): Builder {
|
||||
return builder(Environment(pb), ruleBuilders)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
|||
import jetbrains.mps.logic.reactor.evaluation.Queryable
|
||||
import jetbrains.mps.logic.reactor.evaluation.SessionSolver
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import solver.MemSessionSolver
|
||||
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
|
||||
import jetbrains.mps.logic.reactor.program.JavaPredicateSymbol
|
||||
|
|
@ -207,8 +206,8 @@ class TestHandler {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun basicLogicalPattern() {
|
||||
val (X, Y) = logicalPattern<String>("X", "Y")
|
||||
fun basicMetaLogical() {
|
||||
val (X, Y) = metaLogical<String>("X", "Y")
|
||||
program(
|
||||
rule("rule1",
|
||||
headReplaced(
|
||||
|
|
@ -285,7 +284,7 @@ class TestHandler {
|
|||
|
||||
@Test
|
||||
fun occurrenceReactivated() {
|
||||
val X = logicalPattern<Int>("X")
|
||||
val X = metaLogical<Int>("X")
|
||||
program(
|
||||
rule("zeroth",
|
||||
headKept( constraint("foo") ), body( statement({ x -> x.set(999) }, X),
|
||||
|
|
@ -327,7 +326,7 @@ class TestHandler {
|
|||
|
||||
@Test
|
||||
fun occurrenceReactivatedAfterUnion() {
|
||||
val (X, Y) = logicalPattern<Int>("X", "Y")
|
||||
val (X, Y) = metaLogical<Int>("X", "Y")
|
||||
var handler : Handler? = null
|
||||
program(
|
||||
rule("first",
|
||||
|
|
@ -368,7 +367,7 @@ class TestHandler {
|
|||
|
||||
@Test
|
||||
fun occurrenceReactivatedAfterUnionUnbound() {
|
||||
val (X, Y) = logicalPattern<Int>("X", "Y")
|
||||
val (X, Y) = metaLogical<Int>("X", "Y")
|
||||
var handler : Handler? = null
|
||||
program(
|
||||
rule("first",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import jetbrains.mps.logic.reactor.core.logical
|
|||
import jetbrains.mps.logic.reactor.core.matches
|
||||
import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalPattern
|
||||
import jetbrains.mps.logic.reactor.program.Constraint
|
||||
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
|
||||
import org.junit.Assert.*
|
||||
|
|
@ -188,8 +187,8 @@ class TestMatcher {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun logicalPattern() {
|
||||
val (A, B, C) = logicalPattern<String>("A", "B", "C")
|
||||
fun metaLogical() {
|
||||
val (A, B, C) = metaLogical<String>("A", "B", "C")
|
||||
val b = B.logical()
|
||||
|
||||
program(
|
||||
|
|
@ -204,14 +203,14 @@ class TestMatcher {
|
|||
).matcher().lookupMatches(occurrence("foo", "blah", b)).first().run {
|
||||
assertEquals("blah", logicalContext().variable(A).findRoot().value())
|
||||
assertSame(b, logicalContext().variable(B))
|
||||
assertEquals(C.logical().pattern(), logicalContext().variable(C).pattern())
|
||||
assertEquals(C.logical().metaLogical(), logicalContext().variable(C).metaLogical())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun matchLogicalPattern() {
|
||||
val (M, N) = logicalPattern<Int>("M", "N")
|
||||
fun matchMetaLogical() {
|
||||
val (M, N) = metaLogical<Int>("M", "N")
|
||||
|
||||
program(
|
||||
rule("main1",
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class TestProgram {
|
|||
|
||||
@Test
|
||||
fun logicalValue() {
|
||||
val (X, Y, Z) = logicalPattern<Int>("X", "Y", "Z")
|
||||
val (X, Y, Z) = metaLogical<Int>("X", "Y", "Z")
|
||||
program(
|
||||
rule("main",
|
||||
headReplaced(
|
||||
|
|
@ -89,7 +89,7 @@ class TestProgram {
|
|||
|
||||
@Test
|
||||
fun simpleProgram() {
|
||||
val (X, Y) = logicalPattern<Int>("X", "Y")
|
||||
val (X, Y) = metaLogical<Int>("X", "Y")
|
||||
|
||||
program(
|
||||
rule("main",
|
||||
|
|
@ -113,7 +113,7 @@ class TestProgram {
|
|||
|
||||
@Test
|
||||
fun gcd() {
|
||||
val (M, N, TMP) = logicalPattern<Int>("M", "N", "TMP")
|
||||
val (M, N, TMP) = metaLogical<Int>("M", "N", "TMP")
|
||||
program(
|
||||
rule("main",
|
||||
headReplaced( constraint("main") ), body( statement({ m, n -> m.set(21); n.set(35) }, M, N),
|
||||
|
|
@ -142,7 +142,7 @@ class TestProgram {
|
|||
|
||||
@Test
|
||||
fun primes() {
|
||||
val (M, N) = logicalPattern<Int>("M", "N")
|
||||
val (M, N) = metaLogical<Int>("M", "N")
|
||||
program(
|
||||
rule("main",
|
||||
headReplaced( constraint("main") ), body( statement({ n -> n.set(10) }, N),
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ class TestProgramBuilder {
|
|||
programBuilder = MemProgramBuilder(sessionSolver)
|
||||
}
|
||||
|
||||
lateinit var programBuilder: ProgramBuilder
|
||||
lateinit var programBuilder: MemProgramBuilder
|
||||
|
||||
private fun ProgramBuilder.addRules(rules: List<Rule>) {
|
||||
private fun MemProgramBuilder.addRules(rules: List<Rule>) {
|
||||
rules.forEach { r -> addRule(r) }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue