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%2FEListLiteral.java;h=0f9ae5a15327da2fe4329c7760c8ebb234b5f22f;hp=4cdcc6f847f237038bccf8732d3688ffce700a53;hb=666ee533a3cfa9f59e79215a269f8342227cdbda;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java old mode 100755 new mode 100644 index 4cdcc6f84..0f9ae5a15 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java @@ -1,181 +1,137 @@ -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.ReplaceContext; -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.elaboration.java.Builtins; -import org.simantics.scl.compiler.elaboration.java.ListConstructor; -import org.simantics.scl.compiler.errors.Locations; -import org.simantics.scl.compiler.internal.codegen.utils.Constants; -import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator; -import org.simantics.scl.compiler.internal.interpreted.IExpression; -import org.simantics.scl.compiler.internal.interpreted.IListLiteral; -import org.simantics.scl.compiler.top.ExpressionInterpretationContext; -import org.simantics.scl.compiler.types.Type; -import org.simantics.scl.compiler.types.Types; -import org.simantics.scl.compiler.types.exceptions.MatchException; - -public class EListLiteral extends SimplifiableExpression { - - Expression[] components; - Type componentType; - - public EListLiteral(Expression[] components) { - this.components = components; - } - - private EListLiteral(Expression[] components, Type componentType) { - this.components = components; - this.componentType = componentType; - } - - public Expression[] getComponents() { - return components; - } - - @Override - public void collectRefs(TObjectIntHashMap allRefs, - TIntHashSet refs) { - for(Expression component : components) - component.collectRefs(allRefs, refs); - } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(Expression component : components) - component.collectVars(allVars, vars); - } - - @Override - public void collectFreeVariables(THashSet vars) { - for(Expression component : components) - component.collectFreeVariables(vars); - } - - @Override - public Expression simplify(SimplificationContext context) { - context.pushLocation(location); - try { - for(int i=0;i 0) - result = new EApply(location, result, components); - return result; - } - else { - Expression result = new EApplyType(new ELiteral(location, new ListConstructor(components.length)), componentType); - result = new EApply(location, result, components); - return result; - } - } finally { - context.popLocation(); - } - } - - @Override - public Expression resolve(TranslationContext context) { - for(int i=0;i effects) { - for(Expression component : components) - component.collectEffects(effects); - } - - @Override - public void setLocationDeep(long loc) { - if(location == Locations.NO_LOCATION) { - location = loc; - for(Expression component : components) - component.setLocationDeep(loc); - } - } - - @Override - public void accept(ExpressionVisitor visitor) { - visitor.visit(this); - } - - @Override - public IExpression toIExpression(ExpressionInterpretationContext target) { - IExpression[] componentExpressions = new IExpression[components.length]; - for(int i=0;i 0) + result = new EApply(location, result, components); + return result; + } + else { + Expression result = new EApplyType(new ELiteral(location, new ListConstructor(components.length)), componentType); + result = new EApply(location, result, components); + return result; + } + } finally { + context.popLocation(); + } + } + + @Override + public Expression resolve(TranslationContext context) { + for(int i=0;i