]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java
(refs #7567) Added throw function to builtins
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / java / Builtins.java
index 334cb4560cc488e2ae2a9101dc245f64c0f10c04..631ef2ddc6d7ac874ca073c6b5c6b4363579a488 100644 (file)
@@ -9,7 +9,6 @@ import org.simantics.scl.compiler.common.precedence.Associativity;
 import org.simantics.scl.compiler.common.precedence.Precedence;
 import org.simantics.scl.compiler.constants.BooleanConstant;
 import org.simantics.scl.compiler.constants.Constant;
-import org.simantics.scl.compiler.constants.JavaConstructor;
 import org.simantics.scl.compiler.constants.JavaStaticField;
 import org.simantics.scl.compiler.constants.JavaStaticMethod;
 import org.simantics.scl.compiler.constants.NoRepConstant;
@@ -19,6 +18,7 @@ import org.simantics.scl.compiler.constants.singletons.BindingConstant;
 import org.simantics.scl.compiler.constants.singletons.FailFunction;
 import org.simantics.scl.compiler.constants.singletons.JustConstant;
 import org.simantics.scl.compiler.constants.singletons.NothingConstant;
+import org.simantics.scl.compiler.constants.singletons.ThrowFunction;
 import org.simantics.scl.compiler.constants.singletons.TypeOfConstant;
 import org.simantics.scl.compiler.constants.singletons.TypeOfProxyConstant;
 import org.simantics.scl.compiler.constants.singletons.TypeProxyConstant;
@@ -53,10 +53,10 @@ import org.simantics.scl.runtime.profiling.BranchPoint;
 
 public class Builtins extends ConcreteModule {
 
-    public static SCLValue[] TUPLE_CONSTRUCTORS = new SCLValue[Constants.MAX_TUPLE_LENGTH+1];
-    public static SCLValue[] LIST_CONSTRUCTORS = new SCLValue[Constants.MAX_LIST_LITERAL_LENGTH+1];
+    public static final SCLValue[] TUPLE_CONSTRUCTORS = new SCLValue[Constants.MAX_TUPLE_LENGTH+1];
+    public static final SCLValue[] LIST_CONSTRUCTORS = new SCLValue[Constants.MAX_LIST_LITERAL_LENGTH+1];
     
-    public static final Builtins INSTANCE = new Builtins();       
+    public static Builtins INSTANCE = new Builtins();
     
     public static SCLValue Nothing;
     public static SCLValue Just;
@@ -104,6 +104,7 @@ public class Builtins extends ConcreteModule {
         addTypeDescriptor("Variant", new StandardTypeConstructor(Types.VARIANT, Kinds.STAR, TypeDesc.forClass(Variant.class)));
         
         addEffectConstructor("Proc", new EffectConstructor(Types.PROC));
+        addEffectConstructor("Exception", new EffectConstructor(Types.EXCEPTION));
         
         //addTypeDescriptor("->", new StandardTypeConstructor(Kinds.STAR_TO_STAR_TO_STAR, Constants.FUNCTION));
         addTypeDescriptor("[]", new StandardTypeConstructor(Types.LIST, Kinds.STAR_TO_STAR, Constants.LIST));        
@@ -178,6 +179,10 @@ public class Builtins extends ConcreteModule {
                 new Constructor(Locations.NO_LOCATION, MaybeType.INSTANCE, Just.getName(), new Type[] {MaybeType.INSTANCE.parameters[0]}, null)
                 );
 
+        // *** Dynamic ***
+        
+        addValue("Dynamic", DynamicConstructor.INSTANCE);
+        
         // *** Vector ***
         
         TypeClass VecCompC = new TypeClass(Locations.NO_LOCATION, 
@@ -205,6 +210,8 @@ public class Builtins extends ConcreteModule {
         
         addValue("fail", FailFunction.INSTANCE).documentation =
                 "Throws a runtime exeception with the given string as a description.";
+        addValue("throw", ThrowFunction.INSTANCE).documentation =
+                "Throws a given exception.";
                 
         // *** runProc ***
         
@@ -363,4 +370,8 @@ public class Builtins extends ConcreteModule {
         return documentation;
     }
 
+       public static void flush() {
+               INSTANCE = new Builtins();
+       }
+
 }