X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fparsing%2Ftypes%2FTEffectAst.java;h=f2a19cb60ea89c2e9058835621a7b2241dec69da;hb=292e64ba21f8044df19884dc3e61fe5e292a82df;hp=094fa14defea99307d608bc468fa34a2317e8e3e;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TEffectAst.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TEffectAst.java index 094fa14de..f2a19cb60 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TEffectAst.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TEffectAst.java @@ -1,79 +1,79 @@ -package org.simantics.scl.compiler.internal.parsing.types; - -import java.util.ArrayList; - -import org.simantics.scl.compiler.elaboration.contexts.TypeTranslationContext; -import org.simantics.scl.compiler.internal.types.TypeElaborationContext; -import org.simantics.scl.compiler.types.Type; -import org.simantics.scl.compiler.types.Types; -import org.simantics.scl.compiler.types.kinds.Kind; -import org.simantics.scl.compiler.types.kinds.Kinds; - -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - - - -public class TEffectAst extends TypeAst { - public final TypeAst[] effects; - public final TypeAst type; - - public TEffectAst(TypeAst effect, TypeAst type) { - this.effects = new TypeAst[] {effect}; - this.type = type; - } - - public TEffectAst(TypeAst[] effects, TypeAst type) { - this.effects = effects; - this.type = type; - } - - public TEffectAst(ArrayList effects, TypeAst type) { - this(effects.toArray(new TypeAst[effects.size()]), type); - } - - @Override - public void toString(StringBuilder b) { - b.append('<'); - boolean first = true; - for(TypeAst effect : effects) { - if(first) - first = false; - else - b.append(","); - effect.toString(b); - } - b.append("> "); - b.append(type); - } - - @Override - public Type toType(TypeTranslationContext context, Kind expectedKind) { - context.unify(location, Kinds.STAR, expectedKind); - return Types.functionE( - Types.PUNIT, - TFunctionAst.toEffect(context, effects), - type.toType(context, Kinds.STAR)); - } - - @Override - public Type toType(TypeElaborationContext context) { - return Types.functionE( - Types.PUNIT, - TFunctionAst.toEffect(context, effects), - type.toType(context)); - } - - @Override - public int getPrecedence() { - return 0; - } - - @Override - public void collectReferences(TObjectIntHashMap typeNameMap, - TIntHashSet set) { - for(TypeAst effect : effects) - effect.collectReferences(typeNameMap, set); - type.collectReferences(typeNameMap, set); - } -} +package org.simantics.scl.compiler.internal.parsing.types; + +import java.util.ArrayList; + +import org.simantics.scl.compiler.elaboration.contexts.TypeTranslationContext; +import org.simantics.scl.compiler.internal.types.TypeElaborationContext; +import org.simantics.scl.compiler.types.Type; +import org.simantics.scl.compiler.types.Types; +import org.simantics.scl.compiler.types.kinds.Kind; +import org.simantics.scl.compiler.types.kinds.Kinds; + +import gnu.trove.map.hash.TObjectIntHashMap; +import gnu.trove.set.hash.TIntHashSet; + + + +public class TEffectAst extends TypeAst { + public final TypeAst[] effects; + public final TypeAst type; + + public TEffectAst(TypeAst effect, TypeAst type) { + this.effects = new TypeAst[] {effect}; + this.type = type; + } + + public TEffectAst(TypeAst[] effects, TypeAst type) { + this.effects = effects; + this.type = type; + } + + public TEffectAst(ArrayList effects, TypeAst type) { + this(effects.toArray(new TypeAst[effects.size()]), type); + } + + @Override + public void toString(StringBuilder b) { + b.append('<'); + boolean first = true; + for(TypeAst effect : effects) { + if(first) + first = false; + else + b.append(","); + effect.toString(b); + } + b.append("> "); + b.append(type); + } + + @Override + public Type toType(TypeTranslationContext context, Kind expectedKind) { + context.unify(location, Kinds.STAR, expectedKind); + return Types.functionE( + Types.PUNIT, + TFunctionAst.toEffect(context, effects), + type.toType(context, Kinds.STAR)); + } + + @Override + public Type toType(TypeElaborationContext context) { + return Types.functionE( + Types.PUNIT, + TFunctionAst.toEffect(context, effects), + type.toType(context)); + } + + @Override + public int getPrecedence() { + return 0; + } + + @Override + public void collectReferences(TObjectIntHashMap typeNameMap, + TIntHashSet set) { + for(TypeAst effect : effects) + effect.collectReferences(typeNameMap, set); + type.collectReferences(typeNameMap, set); + } +}