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%2Finternal%2Fparsing%2Ftypes%2FTPlainEffectAst.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fparsing%2Ftypes%2FTPlainEffectAst.java;h=bda01769e9f82ba3bc9f1622f9aedebdb364704f;hp=0000000000000000000000000000000000000000;hb=3d043320cdee8dda92758f4ea1c324a82c7d9094;hpb=e3ee31da93393a7338ebfbc71620d124eedea946 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TPlainEffectAst.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TPlainEffectAst.java new file mode 100644 index 000000000..bda01769e --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TPlainEffectAst.java @@ -0,0 +1,61 @@ +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.kinds.Kind; + +import gnu.trove.map.hash.TObjectIntHashMap; +import gnu.trove.set.hash.TIntHashSet; + + + +public class TPlainEffectAst extends TypeAst { + public final TypeAst[] effects; + + public TPlainEffectAst(TypeAst[] effects) { + this.effects = effects; + } + + public TPlainEffectAst(ArrayList effects) { + this(effects.toArray(new TypeAst[effects.size()])); + } + + @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(">>"); + } + + @Override + public Type toType(TypeTranslationContext context, Kind expectedKind) { + return TFunctionAst.toEffect(context, effects); + } + + @Override + public Type toType(TypeElaborationContext context) { + return TFunctionAst.toEffect(context, effects); + } + + @Override + public int getPrecedence() { + return 0; + } + + @Override + public void collectReferences(TObjectIntHashMap typeNameMap, + TIntHashSet set) { + for(TypeAst effect : effects) + effect.collectReferences(typeNameMap, set); + } +}