From c07a8f3914123e9b75a11290994a8b78bd3f01f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Fri, 9 Mar 2018 23:39:05 +0200 Subject: [PATCH] (refs #7809) Added builtin Pure type to indicate no effects Change-Id: I7068a4932be87afaa254cd9b1eecce712fb83d9c --- .../simantics/scl/compiler/elaboration/java/Builtins.java | 2 ++ .../scl/compiler/elaboration/modules/TypeAlias.java | 6 ++++++ .../org/simantics/scl/compiler/module/ConcreteModule.java | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java index 4846f75a1..e23e378ef 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java @@ -100,6 +100,8 @@ public class Builtins extends ConcreteModule { addEffectConstructor("Proc", new EffectConstructor(Types.PROC)); addEffectConstructor("Exception", new EffectConstructor(Types.EXCEPTION)); + addTypeAlias("Pure", TVar.EMPTY_ARRAY, Types.NO_EFFECTS); + //addTypeDescriptor("->", new StandardTypeConstructor(Kinds.STAR_TO_STAR_TO_STAR, Constants.FUNCTION)); addTypeDescriptor("[]", new StandardTypeConstructor(Types.LIST, Kinds.STAR_TO_STAR, Constants.LIST)); addTypeDescriptor("@", new StandardTypeConstructor(Types.PUNIT, Kinds.STAR, Constants.TUPLE[0])); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/TypeAlias.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/TypeAlias.java index 13ac5ea24..ce8d780c8 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/TypeAlias.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/TypeAlias.java @@ -16,6 +16,12 @@ public class TypeAlias extends TypeDescriptor { this.parameters = new TVar[arity]; } + public TypeAlias(TCon name, TVar[] parameters, Type body) { + super(name); + this.parameters = parameters; + this.body = body; + } + public int getArity() { return parameters.length; } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/ConcreteModule.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/ConcreteModule.java index 8a83e5f35..31ef0dc5a 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/ConcreteModule.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/ConcreteModule.java @@ -12,6 +12,7 @@ import org.simantics.scl.compiler.constants.Constant; import org.simantics.scl.compiler.elaboration.chr.CHRRuleset; import org.simantics.scl.compiler.elaboration.modules.Documentation; import org.simantics.scl.compiler.elaboration.modules.SCLValue; +import org.simantics.scl.compiler.elaboration.modules.TypeAlias; import org.simantics.scl.compiler.elaboration.modules.TypeClass; import org.simantics.scl.compiler.elaboration.modules.TypeClassInstance; import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor; @@ -25,6 +26,9 @@ import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor; import org.simantics.scl.compiler.module.debug.ModuleDebugInfo; import org.simantics.scl.compiler.top.ModuleInitializer; import org.simantics.scl.compiler.types.TCon; +import org.simantics.scl.compiler.types.TVar; +import org.simantics.scl.compiler.types.Type; +import org.simantics.scl.compiler.types.Types; import org.simantics.scl.runtime.profiling.BranchPoint; import gnu.trove.map.hash.THashMap; @@ -79,6 +83,10 @@ public class ConcreteModule implements Module { return effectConstructors.put(name, effectConstructor) != null; } + public void addTypeAlias(String name, TVar[] parameters, Type body) { + typeDescriptors.put(name, new TypeAlias(Types.con(moduleName, name), parameters, body)); + } + public boolean addTypeClass(String name, TypeClass typeClass) { return typeClasses.put(name, typeClass) != null; } -- 2.47.1