X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEGetConstraint.java;h=95948d45c391e17841a64244576a6b8f6bb1271a;hp=ef5412c7bb093f8e275adb984f8ee8c7faba7e5f;hb=a8d72a172fdc815c8a9f0f584f010f7e35286f92;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java old mode 100755 new mode 100644 index ef5412c7b..95948d45c --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java @@ -1,101 +1,80 @@ -package org.simantics.scl.compiler.elaboration.expressions; - -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.THashSet; -import gnu.trove.set.hash.TIntHashSet; - -import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext; -import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; -import org.simantics.scl.compiler.elaboration.contexts.TypingContext; -import org.simantics.scl.compiler.errors.Locations; -import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator; -import org.simantics.scl.compiler.types.TPred; -import org.simantics.scl.compiler.types.Type; -import org.simantics.scl.compiler.types.exceptions.MatchException; - -public class EGetConstraint extends SimplifiableExpression { - TPred constraint; - EVariable evidence; - - public EGetConstraint(long loc, TPred constraint) { - super(loc); - this.constraint = constraint; - } - - @Override - public void collectRefs(TObjectIntHashMap allRefs, - TIntHashSet refs) { - } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - if(evidence != null) - evidence.collectVars(allVars, vars); - } - - @Override - public Expression inferType(TypingContext context) { - Variable variable = new Variable("evidence"); - variable.setType(constraint); - evidence = new EVariable(getLocation(), variable); - evidence.setType(variable.getType()); - context.addConstraintDemand(evidence); - return this; - } - - @Override - protected void updateType() throws MatchException { - setType(constraint); - } - - @Override - public void collectFreeVariables(THashSet vars) { - if(evidence != null) - evidence.collectFreeVariables(vars); - } - - @Override - public Expression simplify(SimplificationContext context) { - return evidence.simplify(context); - } - - @Override - public Expression resolve(TranslationContext context) { - return this; - } - - @Override - public Expression decorate(ExpressionDecorator decorator) { - return decorator.decorate(this); - } - - @Override - public void collectEffects(THashSet effects) { - } - - @Override - public void setLocationDeep(long loc) { - if(location == Locations.NO_LOCATION) { - location = loc; - if(evidence != null) - evidence.setLocationDeep(loc); - } - } - - @Override - public void accept(ExpressionVisitor visitor) { - visitor.visit(this); - } - - @Override - public void forVariables(VariableProcedure procedure) { - evidence.forVariables(procedure); - } - - @Override - public Expression accept(ExpressionTransformer transformer) { - return transformer.transform(this); - } - -} +package org.simantics.scl.compiler.elaboration.expressions; + +import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext; +import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; +import org.simantics.scl.compiler.elaboration.contexts.TypingContext; +import org.simantics.scl.compiler.errors.Locations; +import org.simantics.scl.compiler.types.TPred; +import org.simantics.scl.compiler.types.exceptions.MatchException; + +import gnu.trove.map.hash.TObjectIntHashMap; +import gnu.trove.set.hash.THashSet; +import gnu.trove.set.hash.TIntHashSet; + +public class EGetConstraint extends SimplifiableExpression { + TPred constraint; + EVariable evidence; + + public EGetConstraint(long loc, TPred constraint) { + super(loc); + this.constraint = constraint; + } + + @Override + public void collectVars(TObjectIntHashMap allVars, + TIntHashSet vars) { + if(evidence != null) + evidence.collectVars(allVars, vars); + } + + @Override + public Expression inferType(TypingContext context) { + Variable variable = new Variable("evidence"); + variable.setType(constraint); + evidence = new EVariable(getLocation(), variable); + evidence.setType(variable.getType()); + context.addConstraintDemand(evidence); + return this; + } + + @Override + protected void updateType() throws MatchException { + setType(constraint); + } + + @Override + public void collectFreeVariables(THashSet vars) { + if(evidence != null) + evidence.collectFreeVariables(vars); + } + + @Override + public Expression simplify(SimplificationContext context) { + return evidence.simplify(context); + } + + @Override + public Expression resolve(TranslationContext context) { + return this; + } + + @Override + public void setLocationDeep(long loc) { + if(location == Locations.NO_LOCATION) { + location = loc; + if(evidence != null) + evidence.setLocationDeep(loc); + } + } + + @Override + public void accept(ExpressionVisitor visitor) { + visitor.visit(this); + } + + @Override + public Expression accept(ExpressionTransformer transformer) { + return transformer.transform(this); + } + +}