import org.simantics.scl.compiler.elaboration.chr.relations.ExternalCHRRelation;
import org.simantics.scl.compiler.elaboration.chr.relations.SpecialCHRRelation;
import org.simantics.scl.compiler.elaboration.chr.relations.UnresolvedCHRRelation;
+import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
import org.simantics.scl.compiler.elaboration.contexts.TranslationContext.ExistentialFrame;
import org.simantics.scl.compiler.types.kinds.Kinds;
import gnu.trove.map.hash.TObjectIntHashMap;
-import gnu.trove.set.hash.THashSet;
import gnu.trove.set.hash.TIntHashSet;
public class CHRLiteral extends Symbol {
public boolean negated;
public boolean passive = true;
- public CHRLiteral(long location, CHRRelation relation, Expression[] parameters, boolean remove, boolean negated) {
+ public CHRLiteral(long location, CHRRelation relation, Expression[] parameters, boolean killAfterMatch, boolean negated) {
this.location = location;
this.relation = relation;
this.parameters = parameters;
- this.killAfterMatch = remove;
+ this.killAfterMatch = killAfterMatch;
this.negated = negated;
}
}
}
- public void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
- for(Expression parameter : parameters)
- parameter.collectRefs(allRefs, refs);
- if(typeConstraintEvidenceParameters != null)
- for(Expression parameter : typeConstraintEvidenceParameters)
- parameter.collectRefs(allRefs, refs);
- }
-
public void checkType(TypingContext context) {
if(relation == SpecialCHRRelation.EXECUTE) {
if(parameters.length != 1)
parameter.collectVars(allVars, vars);
}
- public void collectFreeVariables(THashSet<Variable> vars) {
- if(relation == SpecialCHRRelation.ASSIGN) {
- parameters[1].collectFreeVariables(vars);
- }
- else {
- for(Expression parameter : parameters)
- parameter.collectFreeVariables(vars);
- if(typeConstraintEvidenceParameters != null)
- for(Expression parameter : typeConstraintEvidenceParameters)
- parameter.collectFreeVariables(vars);
- }
- }
-
public void setLocationDeep(long loc) {
if(location == Locations.NO_LOCATION) {
this.location = loc;
return b.toString();
}
- public void collectQueryEffects(THashSet<Type> effects) {
- // TODO
- }
-
- public void collectEnforceEffects(THashSet<Type> effects) {
- // TODO
+ public CHRLiteral replace(ReplaceContext context) {
+ CHRLiteral copy = new CHRLiteral(location, relation, context.replace(parameters), killAfterMatch, negated);
+ for(int i=0;i<parameters.length;++i)
+ copy.parameters[i] = copy.parameters[i].replace(context);
+ copy.passive = passive;
+ copy.typeConstraintEvidenceParameters = context.replace(typeConstraintEvidenceParameters);
+ copy.typeParameters = context.replace(typeParameters);
+ copy.fields = context.replace(fields);
+ return copy;
}
}