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=e0921dc106fa67f50944ef6ebd9c14c3080972bf;hb=b9a57b81dd1311b0297c7d856380618b7fc049a4;hp=918dd9fb309ef25d4d9dfd3f156e60b7d4b097e5;hpb=e83a15c556c27b56e856dc26fa4e2d792cf959be;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 918dd9fb3..e0921dc10 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; @@ -12,7 +13,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext; import org.simantics.scl.compiler.elaboration.expressions.ERecord; import org.simantics.scl.compiler.elaboration.expressions.Expression; import org.simantics.scl.compiler.elaboration.expressions.Variable; -import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure; import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor; import org.simantics.scl.compiler.elaboration.expressions.records.FieldAssignment; import org.simantics.scl.compiler.elaboration.relations.SCLRelation; @@ -24,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 { @@ -38,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; } @@ -113,14 +112,6 @@ public class CHRLiteral extends Symbol { } } - public void collectRefs(TObjectIntHashMap 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) @@ -157,27 +148,6 @@ public class CHRLiteral extends Symbol { parameter.collectVars(allVars, vars); } - public void forVariables(VariableProcedure procedure) { - for(Expression parameter : parameters) - parameter.forVariables(procedure); - if(typeConstraintEvidenceParameters != null) - for(Expression parameter : typeConstraintEvidenceParameters) - parameter.forVariables(procedure); - } - - 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; @@ -201,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