X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fchr%2FCHRLiteral.java;h=6bea58310c73b24dd8a0e841793252e09d926c53;hb=21eae91e860f9f3cdb9cd0ee6fded24cdb8ca2f5;hp=e8bb00a6e1b7a7a66dca38f7e7e3a28bf8a9cb77;hpb=2f63e7a58e49a233b28c6968b848281060117c43;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRLiteral.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRLiteral.java index e8bb00a6e..6bea58310 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRLiteral.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRLiteral.java @@ -5,6 +5,7 @@ import org.simantics.scl.compiler.elaboration.chr.relations.CHRConstraint; 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; @@ -23,7 +24,6 @@ import org.simantics.scl.compiler.types.Types; 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 { @@ -37,11 +37,11 @@ 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; } @@ -93,7 +93,7 @@ public class CHRLiteral extends Symbol { context.getErrorLog().log(location, "Relation " + relation + " does not define field names."); return; } - parameters = ERecord.translateFieldsToFunctionParameters(context, fields, fieldNames); + parameters = ERecord.translateFieldsToFunctionParameters(context, fields, fieldNames, true); if(parameters == null) return; for(int i=0;i 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) @@ -156,19 +148,6 @@ public class CHRLiteral extends Symbol { parameter.collectVars(allVars, vars); } - public void collectFreeVariables(THashSet 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; @@ -192,11 +171,14 @@ public class CHRLiteral extends Symbol { return b.toString(); } - public void collectQueryEffects(THashSet effects) { - // TODO - } - - public void collectEnforceEffects(THashSet effects) { - // TODO + public CHRLiteral replace(ReplaceContext context) { + CHRLiteral copy = new CHRLiteral(location, relation, context.replace(parameters), killAfterMatch, negated); + for(int i=0;i