(refs #7809) Added builtin Pure type to indicate no effects 48/1548/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 9 Mar 2018 21:39:05 +0000 (23:39 +0200)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 9 Mar 2018 21:39:05 +0000 (23:39 +0200)
Change-Id: I7068a4932be87afaa254cd9b1eecce712fb83d9c

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/modules/TypeAlias.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/ConcreteModule.java

index 4846f75a13b2b605297807d11fe5c60a9fd800be..e23e378efd668e6c1fbafa87c8ed26c527ea7865 100644 (file)
@@ -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]));
index 13ac5ea2439d6d8e95263facf3388d5481a7d59e..ce8d780c8d422f31829e87cbf42794b8dc50b28a 100644 (file)
@@ -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;
     }
index 8a83e5f35644631bdc58c568dd70c275a264109d..31ef0dc5a0cb9863874d042858aec59d451adadd 100644 (file)
@@ -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;
     }