]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7278, refs #7279) Small fixes to InternalCompilerExceptions 01/601/2
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 5 Jun 2017 10:50:33 +0000 (13:50 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 5 Jun 2017 20:17:10 +0000 (23:17 +0300)
Change-Id: I771fb27ecc98a7cd4f05aaf5e23a4763a6a0ca52

45 files changed:
bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphPropertyRelation.java
bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphRelation.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/CodeGeneration.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRuleset.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/AccessFactOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/AssignOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/CheckOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/ClaimOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/ExecuteOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/IterateConstraintOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/IterateListOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/MatchOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/DecoratingExpression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApplyType.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAsPattern.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECoveringBranchPoint.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EError.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EExternalConstant.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EFieldAccess.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambdaType.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELet.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELiteral.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLambda.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLet.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EViewPattern.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/GuardedExpressionGroup.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/SimplifiableExpression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/decomposed/DecomposedExpression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/matching/PatternMatchingCompiler.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/matching2/PatternMatchingCompiler2.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/top/ExpressionEvaluator.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ActiveTests.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/EmptyDo.scl [new file with mode: 0644]
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/InvalidRunProc.scl [new file with mode: 0644]

index a6009426f36d7422473128b5be520f90ae7eefbd..307a32cccb1c6664cc7cc4dbf3fd96ea70f9a639 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.modeling.scl;
 import org.simantics.db.Resource;
 import org.simantics.scl.compiler.common.names.Name;
 import org.simantics.scl.compiler.common.names.Names;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.chr.plan.PlanContext;
 import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.EExternalConstant;
@@ -120,22 +121,22 @@ public class GraphPropertyRelation implements SCLRelation {
     @Override
     public void generateIterate(PlanContext context, CodeWriter w, long location, int boundMask, Variable[] variables,
             Expression[] expressions, Expression[] typeConstraintEvidenceParameters) {
-        Environment env = context.context.environment;
+        CompilationContext compilationContext = context.context;
         switch(boundMask) {
         case BF:
             context.iterateMaybe(location, w, variables[1],
                     w.apply(location,
-                            env.getValue(POSSIBLE_RELATED_VALUE).getValue().createSpecialization(valueType),
-                            typeConstraintEvidenceParameters[0].toVal(env, w),
-                            expressions[0].toVal(env, w),
+                            compilationContext.environment.getValue(POSSIBLE_RELATED_VALUE).getValue().createSpecialization(valueType),
+                            typeConstraintEvidenceParameters[0].toVal(compilationContext, w),
+                            expressions[0].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(propertyRelation, Types.RESOURCE)));
             break;
         case BB:
-            context.checkEqualsJust(location, w, expressions[1].toVal(env, w),
+            context.checkEqualsJust(location, w, expressions[1].toVal(compilationContext, w),
                     w.apply(location,
-                            env.getValue(POSSIBLE_RELATED_VALUE).getValue().createSpecialization(valueType),
-                            typeConstraintEvidenceParameters[0].toVal(env, w),
-                            expressions[0].toVal(env, w),
+                            compilationContext.environment.getValue(POSSIBLE_RELATED_VALUE).getValue().createSpecialization(valueType),
+                            typeConstraintEvidenceParameters[0].toVal(compilationContext, w),
+                            expressions[0].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(propertyRelation, Types.RESOURCE)));
             break;
         default: throw new IllegalArgumentException();
@@ -144,12 +145,12 @@ public class GraphPropertyRelation implements SCLRelation {
 
     @Override
     public void generateEnforce(PlanContext context, CodeWriter w, long location, Expression[] parameters, Expression[] typeConstraintEvidenceParameters) {
-        Environment env = context.context.environment;
+        CompilationContext compilationContext = context.context;
         w.apply(location,
-                env.getValue(CLAIM_RELATED_VALUE).getValue().createSpecialization(valueType),
-                typeConstraintEvidenceParameters[0].toVal(env, w),
-                parameters[0].toVal(env, w),
+                compilationContext.environment.getValue(CLAIM_RELATED_VALUE).getValue().createSpecialization(valueType),
+                typeConstraintEvidenceParameters[0].toVal(compilationContext, w),
+                parameters[0].toVal(compilationContext, w),
                 w.getModuleWriter().getExternalConstant(propertyRelation, Types.RESOURCE),
-                parameters[1].toVal(env, w));
+                parameters[1].toVal(compilationContext, w));
     }
 }
index da08a2a38d2087d7993eca98991bd1316f2ad730..331cef2cb280b282260754cc0a0427747f606e21 100644 (file)
@@ -2,6 +2,7 @@ package org.simantics.modeling.scl;
 
 import org.simantics.db.Resource;
 import org.simantics.scl.compiler.common.names.Name;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.chr.plan.PlanContext;
 import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.EExternalConstant;
@@ -11,7 +12,6 @@ import org.simantics.scl.compiler.elaboration.expressions.Variable;
 import org.simantics.scl.compiler.elaboration.query.compilation.EnforcingContext;
 import org.simantics.scl.compiler.elaboration.query.compilation.QueryCompilationContext;
 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
 import org.simantics.scl.compiler.types.TVar;
@@ -139,13 +139,13 @@ public class GraphRelation implements SCLRelation {
     @Override
     public void generateIterate(PlanContext context, CodeWriter w, long location, int boundMask, Variable[] variables,
             Expression[] expressions, Expression[] typeConstraintEvidenceParameters) {
-        Environment env = context.context.environment;
+        CompilationContext compilationContext = context.context;
         switch(boundMask) {
         case BF:
             context.iterateList(location, w, variables[1],
                     w.apply(location,
-                            env.getValue(GET_OBJECTS).getValue(),
-                            expressions[0].toVal(env, w),
+                            compilationContext.environment.getValue(GET_OBJECTS).getValue(),
+                            expressions[0].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(relation, Types.RESOURCE)));
             break;
         case FB:
@@ -153,21 +153,21 @@ public class GraphRelation implements SCLRelation {
                 throw new IllegalArgumentException();
             context.iterateList(location, w, variables[0],
                     w.apply(location,
-                            env.getValue(GET_OBJECTS).getValue(),
-                            expressions[1].toVal(env, w),
+                            compilationContext.environment.getValue(GET_OBJECTS).getValue(),
+                            expressions[1].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(inverseRelation, Types.RESOURCE)));
             break;
         case BB:
             context.check(location, w, 
                     inverseRelation == null || relationSelectivity <= inverseRelationSelectivity
-                    ? w.apply(location, env.getValue(HAS_STATEMENT).getValue(), 
-                            expressions[0].toVal(env, w),
+                    ? w.apply(location, compilationContext.environment.getValue(HAS_STATEMENT).getValue(), 
+                            expressions[0].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(relation, Types.RESOURCE),
-                            expressions[1].toVal(env, w))
-                    : w.apply(location, env.getValue(HAS_STATEMENT).getValue(), 
-                            expressions[1].toVal(env, w),
+                            expressions[1].toVal(compilationContext, w))
+                    : w.apply(location, compilationContext.environment.getValue(HAS_STATEMENT).getValue(), 
+                            expressions[1].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(inverseRelation, Types.RESOURCE),
-                            expressions[0].toVal(env, w)));
+                            expressions[0].toVal(compilationContext, w)));
             break;
         default: throw new IllegalArgumentException();
         }
@@ -176,11 +176,11 @@ public class GraphRelation implements SCLRelation {
     @Override
     public void generateEnforce(PlanContext context, CodeWriter w, long location, Expression[] parameters,
             Expression[] typeConstraintEvidenceParameters) {
-        Environment env = context.context.environment;
+        CompilationContext compilationContext = context.context;
         w.apply(location,
-                env.getValue(CLAIM).getValue(),
-                parameters[0].toVal(env, w),
+                compilationContext.environment.getValue(CLAIM).getValue(),
+                parameters[0].toVal(compilationContext, w),
                 w.getModuleWriter().getExternalConstant(relation, Types.RESOURCE),
-                parameters[1].toVal(env, w));
+                parameters[1].toVal(compilationContext, w));
     }
 }
index 5d258dd9e2b819c9d2ea4576718c65522586c384..68c5847082d96e7f1db80a1a83f9d4d2d9bcdbb7 100644 (file)
@@ -160,7 +160,7 @@ public class CodeGeneration {
                     continue;
      
                 DecomposedExpression decomposed = 
-                        DecomposedExpression.decompose(expression);
+                        DecomposedExpression.decompose(errorLog, expression);
     
                 CodeWriter w = mw.createFunction((SCLConstant)value.getValue(),
                         decomposed.typeParameters,
@@ -172,7 +172,7 @@ public class CodeGeneration {
                 IVal[] parameterVals = w.getParameters();
                 for(int i=0;i<decomposed.parameters.length;++i)
                     decomposed.parameters[i].setVal(parameterVals[i]);
-                w.return_(decomposed.body.toVal(compilationContext.environment, w));            
+                w.return_(decomposed.body.toVal(compilationContext, w));            
             } catch(RuntimeException e) {
                 long location = value.getExpression().location;
                 if(location == Locations.NO_LOCATION)
index 13eb8491b529bdeb2943d6b15eb996195d4014ff..d670300cbe1a4253758ee5731a766ddc42cac0aa 100644 (file)
@@ -263,7 +263,7 @@ public class CHRRuleset extends Symbol {
     
     public IVal generateCode(CodeWriter w) {
         for(IncludeStatement include : includes) {
-            include.storeVar = include.value.toVal(cachedContext.environment, w);
+            include.storeVar = include.value.toVal(cachedContext, w);
             initialPriorityNumber = Math.max(initialPriorityNumber, include.ruleset.initialPriorityNumber + include.ruleset.priorityCount);
         }
         CHRRulesetObject object = new CHRRulesetObject(runtimeRulesetVariable, this);
index d2379d7c01c591879e44a0510b65f836ecd8d6a0..4874c14fe57f4c71533045e8484549f3a11f98cd 100644 (file)
@@ -37,7 +37,7 @@ public class AccessFactOp extends PlanOp {
 
     @Override
     public void generateCode(CompilationContext context, PlanContext planContext, CodeWriter w) {
-        IVal inputVal = inputFact.toVal(context.environment, w);
+        IVal inputVal = inputFact.toVal(context, w);
         for(int i=0;i<variables.length;++i)
             variables[i].setVal(constraint.accessComponent(location, w, inputVal, i));
         IVal activeId = w.apply(location, constraint.accessId, inputVal);
index 00368a252f0a28f33163ea10603b691d3a313593..5ef54ea82ac414b071e516d0e6308317ee342769 100644 (file)
@@ -22,7 +22,7 @@ public class AssignOp extends PlanOp {
 
     @Override
     public void generateCode(CompilationContext context, PlanContext planContext, CodeWriter w) {
-        variable.setVal(expression.toVal(context.environment, w));
+        variable.setVal(expression.toVal(context, w));
         planContext.nextOp(w);
     }
 
index 74896d84ee401190eb16f267acf81c6700f6497b..70e92845ae79df11f7ff73d711275405562cf067 100644 (file)
@@ -19,6 +19,6 @@ public class CheckOp extends PlanOp {
 
     @Override
     public void generateCode(CompilationContext context, PlanContext planContext, CodeWriter w) {
-        planContext.check(location, w, condition.toVal(context.environment, w));
+        planContext.check(location, w, condition.toVal(context, w));
     }
 }
index 5b7f81664770503a81b70ed59ac29804f602ece7..41a851aa75bff2bcd743ee0bc4b69d00dfa44dc6 100644 (file)
@@ -29,7 +29,7 @@ public class ClaimOp extends PlanOp {
         IVal[] parameterVars = new IVal[parameters.length+1];
         parameterVars[0] = planContext.generateNewId(location, w);
         for(int i=0;i<parameters.length;++i)
-            parameterVars[i+1] = parameters[i].toVal(context.environment, w);
+            parameterVars[i+1] = parameters[i].toVal(context, w);
         IVal newFact = w.apply(location, constraint.constructor, parameterVars);
         w.apply(location, constraint.addProcedure, planContext.getStoreVar(constraint), planContext.contextVar, newFact);
         planContext.nextOp(w);
index 5426ae00dc3a69570b7d980e5c737ce1ff0ae2f2..5494753d99d86c56fc8363bb227a7498c56154fc 100644 (file)
@@ -20,7 +20,7 @@ public class ExecuteOp extends PlanOp {
 
     @Override
     public void generateCode(CompilationContext context, PlanContext planContext, CodeWriter w) {
-        expression.toVal(context.environment, w);
+        expression.toVal(context, w);
         planContext.nextOp(w);
     }
 
index 95c341e9f369ecce5558f4ea0a1013da94a0c378..035ccd624a134f8942e3d19a8908fca2ddda75a5 100644 (file)
@@ -58,7 +58,7 @@ public class IterateConstraintOp extends PlanOp {
         parameters.add(planContext.getStoreVar(constraint));
         for(int i=0;i<expressions.length;++i)
             if(((boundMask>>i)&1)==1)
-                parameters.add(expressions[i].toVal(context.environment, w));
+                parameters.add(expressions[i].toVal(context, w));
         w.jump(bodyContinuation, w.apply(location,
                 constraint.fetchFromIndex(context, boundMask), parameters.toArray(new IVal[parameters.size()])));
 
index aa87378738bc4ef27205ea239d80ca1fe0a3d222..3c574b54d178f2aa26e2a5f4ed97f757769bd276 100644 (file)
@@ -24,7 +24,7 @@ public class IterateListOp extends PlanOp {
 
     @Override
     public void generateCode(CompilationContext context, PlanContext planContext, CodeWriter w) {
-        IVal listValue = list.toVal(context.environment, w);
+        IVal listValue = list.toVal(context, w);
         planContext.iterateList(location, w, variable, listValue);
     }
 }
index 97fa2e7403191412bddff37e4214c2ccedfef9e4..cde56694999a1cff36708b866add77e1d790f09c 100644 (file)
@@ -30,12 +30,12 @@ public class MatchOp extends PlanOp {
         CodeWriter end = w.createBlock();
         
         IVal[] scrutineeVals = new IVal[1];
-        scrutineeVals[0] = scrutinee.toVal(context.environment, w);
+        scrutineeVals[0] = scrutinee.toVal(context, w);
 
         ArrayList<Row2> rows = new ArrayList<Row2>(1);
         rows.add(new Row2(new Expression[] {pattern}, body.getContinuation()));
 
-        PatternMatchingCompiler2.split(w, context.environment, scrutineeVals, end.getContinuation(), rows);
+        PatternMatchingCompiler2.split(w, context, scrutineeVals, end.getContinuation(), rows);
         
         planContext.nextOp(body);
         if(body.isUnfinished())
index 398d86762d3e8f102075d7051057e1fe878139e5..3d2031ee5af6154cb9a1f89b071358a4c91410b3 100644 (file)
@@ -3,12 +3,12 @@ package org.simantics.scl.compiler.elaboration.expressions;
 import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.errors.NotPatternException;
 import org.simantics.scl.compiler.elaboration.expressions.lhstype.LhsType;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -113,7 +113,7 @@ public abstract class DecoratingExpression extends SimplifiableExpression {
     }
 
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         throw new InternalCompilerError("Cannot generate code for " + getClass().getSimpleName() + ".");
     }
     
index 501c7f95d3db2c4c52fbba2caa630ee1716bb1f1..c7bce466759d62eaf154c4a0a415b634249903cf 100644 (file)
@@ -4,6 +4,7 @@ import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.names.Name;
 import org.simantics.scl.compiler.common.names.Names;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.constants.NoRepConstant;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
@@ -15,7 +16,6 @@ import org.simantics.scl.compiler.elaboration.expressions.lhstype.PatternMatchin
 import org.simantics.scl.compiler.elaboration.java.ListConstructor;
 import org.simantics.scl.compiler.elaboration.macros.MacroRule;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -101,11 +101,11 @@ public class EApply extends Expression {
        }
 
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
-        IVal functionVal = function.toVal(env, w);
+       public IVal toVal(CompilationContext context, CodeWriter w) {
+        IVal functionVal = function.toVal(context, w);
         IVal[] parameterVals = new IVal[parameters.length];
         for(int i=0;i<parameters.length;++i)
-            parameterVals[i] = parameters[i].toVal(env, w);
+            parameterVals[i] = parameters[i].toVal(context, w);
         Type type = getType();
         effect = Types.simplifyFinalEffect(effect);
         return w.applyWithEffect(location, effect, type, functionVal, parameterVals);
index a8177c21f3fb633be1fba6bb121d35e9e6720f95..d07b6d13bc17d6f6702c2ca7050f9e0916c69272 100644 (file)
@@ -1,11 +1,11 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -65,8 +65,8 @@ public class EApplyType extends Expression {
        }
        
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
-        IVal val = expression.toVal(env, w);
+       public IVal toVal(CompilationContext context, CodeWriter w) {
+        IVal val = expression.toVal(context, w);
         return val.createSpecialization(parameter);
     }
 
index 0c1f895481bb6f8931356f44d70cd293f982cba9..62cea76d8fbcfc8e7d8b3591f1d529fc7c0e010b 100644 (file)
@@ -1,11 +1,11 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -92,7 +92,7 @@ public class EAsPattern extends Expression {
     }
 
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         throw new InternalCompilerError("EAsPattern allowed only in patterns.");
     }
     
index a6364789c3df2d82ed6efa5409da5862a59330de..d950e7b738eb07124ae4e6549437c7b9ffb7dfb1 100644 (file)
@@ -1,11 +1,11 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -91,7 +91,7 @@ public class EBind extends SimplifiableExpression {
     }
 
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         throw new InternalCompilerError("EBind should be eliminated.");
     }
 
index a509616bbb4bf669e08e1ece55584d58355309a3..2c70bd90742ef6562d8c9f141bd705838264dc82 100644 (file)
@@ -3,7 +3,6 @@ package org.simantics.scl.compiler.elaboration.expressions;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
 import org.simantics.scl.compiler.elaboration.chr.translation.CHRTranslation;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
@@ -47,8 +46,10 @@ public class EBlock extends ASTExpression {
 
     @Override
     public Expression resolve(TranslationContext context) {
-        if(statements.isEmpty())
-            throw new InternalCompilerError();
+        if(statements.isEmpty()) {
+            context.getErrorLog().log(location, "Block should not be empty.");
+            return new EError(location);
+        }
         int i = statements.size()-1;
         Statement last = statements.get(i);
         if(!(last instanceof GuardStatement)) {
index be447b7a270808ca7e68a626822ca7780d7fd496..9a8aa78b929199b8e6aad3b4db405d4e9e2e2b15 100644 (file)
@@ -1,10 +1,10 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -47,9 +47,9 @@ public class ECHRRuleset extends Expression {
         setType(in.getType());
     }
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         ruleset.generateCode(w);
-        return in.toVal(env, w);
+        return in.toVal(context, w);
     }
     @Override
     public void collectFreeVariables(THashSet<Variable> vars) {
index e8a5cb81beb4300b29f69a35af5bfc31af83bd90..7965b50114c7b9f31a6f0c625f6ed7fdadab4abf 100644 (file)
@@ -1,11 +1,11 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -43,7 +43,7 @@ public class ECHRRulesetConstructor extends Expression {
         throw new InternalCompilerError("Type of ECHRRulesetConstructor should be already given.");
     }
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         return ruleset.generateCode(w);
     }
     @Override
index 502c4f3695e466e8e44ffe0260e85b53f01077ee..6b99e6d37f4ad320077cd91a4735103ff9e86b7b 100644 (file)
@@ -4,6 +4,7 @@ import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.names.Name;
 import org.simantics.scl.compiler.common.precedence.Precedence;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.constants.Constant;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
@@ -13,7 +14,6 @@ import org.simantics.scl.compiler.elaboration.errors.NotPatternException;
 import org.simantics.scl.compiler.elaboration.expressions.lhstype.LhsType;
 import org.simantics.scl.compiler.elaboration.expressions.lhstype.PatternMatchingLhs;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -114,7 +114,7 @@ public class EConstant extends Expression {
     }
     
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
+       public IVal toVal(CompilationContext context, CodeWriter w) {
            IVal val = value.getValue();                
            if(typeParameters.length > 0) {
                val = val.createSpecialization(typeParameters);
index 7f1b7ac20f3a5ff54a920c43ce8107fde87dcbd8..db675d4147c6229473f9d6c3f4ae55a1d2c496b3 100644 (file)
@@ -1,9 +1,9 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.constants.Constant;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.java.VisitBranchPoint;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
 import org.simantics.scl.compiler.internal.codegen.writer.ModuleWriter;
@@ -29,11 +29,11 @@ public class ECoveringBranchPoint extends DecoratingExpression {
     }
     
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         ModuleWriter mw = w.getModuleWriter();
         Constant constant = mw.getExternalConstant(branchPoint, Types.BRANCH_POINT);
         w.applyWithEffect(location, Types.PROC, Types.UNIT, VisitBranchPoint.INSTANCE, constant);
-        return expression.toVal(env, w);
+        return expression.toVal(context, w);
     }
 
     @Override
index 8395391fa9e4d5c6172e6dadada1d71d08d8b684..b329beb1937e636a2d0f44dc445b1a5317fd3d63 100644 (file)
@@ -1,10 +1,10 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -46,7 +46,7 @@ public class EError extends Expression {
        }
        
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
+       public IVal toVal(CompilationContext context, CodeWriter w) {
         throw new UnsupportedOperationException();
     }
 
index d7038438b66833cb99e892172c212bcc357062a8..4777b2dfb670650ecff46e9b258a3c271ab419b1 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.scl.compiler.elaboration.expressions;
 import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
@@ -54,7 +55,7 @@ public class EExternalConstant extends Expression {
        }
        
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
+       public IVal toVal(CompilationContext context, CodeWriter w) {
                ModuleWriter mw = w.getModuleWriter();
                return mw.getExternalConstant(value, getType());
     }
index c05b15409bf8976d6a95c386d7a714085c7c5d01..0d3e2eeaf3600e32aa1ca5206293f40d4182006d 100644 (file)
@@ -89,6 +89,7 @@ public class EFieldAccess extends SimplifiableExpression {
                 };
             }
             accessorExpression = new EAmbiguous(alternatives);
+            accessorExpression.location = location;
         }
         return new EApply(location, accessorExpression, parent).checkType(context, requiredType);
     }
index e3bb2fe0a313d86e24c3b82d1a32d04eb0e47a65..661de4261e260c09b1cd543f3ac5e2dc97df7339 100644 (file)
@@ -1,10 +1,10 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -62,21 +62,21 @@ public class EIf extends Expression {
        }
        
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
-        IVal conditionVal = condition.toVal(env, w); 
+       public IVal toVal(CompilationContext context, CodeWriter w) {
+        IVal conditionVal = condition.toVal(context, w); 
         CodeWriter joinPoint = w.createBlock(getType());
         CodeWriter thenBlock = w.createBlock();
         if(else_ != null) {
             CodeWriter elseBlock = w.createBlock();        
             w.if_(conditionVal, thenBlock.getContinuation(), elseBlock.getContinuation());
                 
-            IVal elseVal = else_.toVal(env, elseBlock);
+            IVal elseVal = else_.toVal(context, elseBlock);
             elseBlock.jump(joinPoint.getContinuation(), elseVal);
         }
         else {
             w.if_(conditionVal, thenBlock.getContinuation(), joinPoint.getContinuation());
         }
-        IVal thenVal = then_.toVal(env, thenBlock);
+        IVal thenVal = then_.toVal(context, thenBlock);
         thenBlock.jump(joinPoint.getContinuation(), thenVal);
         w.continueAs(joinPoint);
         
index 08e47bf95f78d3fd0b75299e897f69ee42608832..23733bac61165c31e178d2e960af9dcc92e38d3d 100644 (file)
@@ -1,11 +1,11 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -47,8 +47,8 @@ public class ELambdaType extends Expression {
        }
 
        @Override
-    public IVal toVal(Environment env, CodeWriter w) {
-        return lambdaToVal(env, w);
+    public IVal toVal(CompilationContext context, CodeWriter w) {
+        return lambdaToVal(context, w);
     }
 
     @Override
index d10066f90047a303bb2462089ae2a5d987c217f6..2b9e8e2c0d9cc71a71f59ff3f37d798f199a5167 100644 (file)
@@ -3,11 +3,11 @@ package org.simantics.scl.compiler.elaboration.expressions;
 import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.BoundVar;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
@@ -147,7 +147,7 @@ public class ELet extends Expression {
     }
     
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         // Create bound variables
         BoundVar[] vars = new BoundVar[assignments.length];
         for(int i=0;i<assignments.length;++i) {
@@ -168,7 +168,7 @@ public class ELet extends Expression {
         rdw.setLocation(range);
         for(int i=0;i<assignments.length;++i) {
             DecomposedExpression decomposed = 
-                    DecomposedExpression.decompose(assignments[i].value);
+                    DecomposedExpression.decompose(context.errorLog, assignments[i].value);
             CodeWriter newW = rdw.createFunction(vars[i], 
                     decomposed.typeParameters,
                     decomposed.effect,
@@ -177,9 +177,9 @@ public class ELet extends Expression {
             IVal[] parameters = newW.getParameters();
             for(int j=0;j<parameters.length;++j)
                 decomposed.parameters[j].setVal(parameters[j]);
-            newW.return_(decomposed.body.toVal(env, newW));
+            newW.return_(decomposed.body.toVal(context, newW));
         }
-        return in.toVal(env, w);
+        return in.toVal(context, w);
     }
         
     private void checkAssignments(TypingContext context) {
index 5b9d15ed048e55916b320e4ce0ea3d9546f26441..b11c0d66746ffd328d095cc0ae763de7fbc701d9 100644 (file)
@@ -2,12 +2,12 @@ package org.simantics.scl.compiler.elaboration.expressions;
 
 import java.util.ArrayList;
 
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.constants.Constant;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -58,7 +58,7 @@ public class ELiteral extends Expression {
        }
 
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
+       public IVal toVal(CompilationContext context, CodeWriter w) {
         return value;
     }
 
index d1a96d04a36696f214a16b626e8ba83f788ad41f..eef72f9de4f192f4ca44725a519024fb3add2bda 100644 (file)
@@ -2,11 +2,11 @@ package org.simantics.scl.compiler.elaboration.expressions;
 
 import java.util.ArrayList;
 
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.ssa.exits.Throw;
@@ -64,18 +64,18 @@ public class EMatch extends Expression {
        }
 
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
+       public IVal toVal(CompilationContext context, CodeWriter w) {
            ArrayList<Row> rows = new ArrayList<Row>(cases.length);
            for(Case case_ : cases)
                rows.add(new Row(case_.patterns, case_.value));
            
            IVal[] scrutineeVals = new IVal[scrutinee.length];
            for(int i=0;i<scrutinee.length;++i)
-               scrutineeVals[i] = scrutinee[i].toVal(env, w);
+               scrutineeVals[i] = scrutinee[i].toVal(context, w);
            
            CodeWriter joinPoint = w.createBlock(getType());
            CodeWriter failurePoint = w.createBlock(); // TODO generate only one failurePoint per function
-           PatternMatchingCompiler.split(w, env, scrutineeVals, joinPoint.getContinuation(), failurePoint.getContinuation(), rows);
+           PatternMatchingCompiler.split(w, context, scrutineeVals, joinPoint.getContinuation(), failurePoint.getContinuation(), rows);
            failurePoint.throw_(location, Throw.MatchingException, "Matching failure at: " + toString());
            w.continueAs(joinPoint);
            return w.getParameters()[0];
index 29eff29103dc6a8e2c257c7857b3125c2ccd2982..2e5d4c364c743ab24345141e8752a5227e11f990 100644 (file)
@@ -3,11 +3,11 @@ package org.simantics.scl.compiler.elaboration.expressions;
 import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -78,8 +78,8 @@ public class ESimpleLambda extends Expression {
        }
        
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
-           return lambdaToVal(env, w);
+       public IVal toVal(CompilationContext context, CodeWriter w) {
+           return lambdaToVal(context, w);
     }
 
     @Override
@@ -180,11 +180,10 @@ public class ESimpleLambda extends Expression {
             return this;
         }
         
-        effect = mfun.effect;
         context.pushEffectUpperBound(location, mfun.effect);
         parameter.setType(mfun.parameterTypes[0]);
         value = value.checkType(context, mfun.returnType);
-        context.popEffectUpperBound();
+        effect = context.popEffectUpperBound();
         return this;
     }
     
index 047d77a47cc4b76bccb7288128b88e01a5722ff6..e8fd9cf940b1b3f41dfa34cfc6cf800de3c887e9 100644 (file)
@@ -1,10 +1,10 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -64,11 +64,11 @@ public class ESimpleLet extends Expression {
     }
     
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
-           IVal valueVal = value.toVal(env, w);
+       public IVal toVal(CompilationContext context, CodeWriter w) {
+           IVal valueVal = value.toVal(context, w);
            if(variable != null)
                variable.setVal(valueVal);
-        return in.toVal(env, w);
+        return in.toVal(context, w);
     }
 
     @Override
index a4010303ca75ed20a23cb12f7780cf3e70f2fad6..5311de2f17b4dcc7c9edf2c5ed68e0f2346c0593 100644 (file)
@@ -3,11 +3,11 @@ package org.simantics.scl.compiler.elaboration.expressions;
 import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -68,7 +68,7 @@ public class EVariable extends Expression {
        }
        
        @Override
-       public IVal toVal(Environment env, CodeWriter w) {
+       public IVal toVal(CompilationContext context, CodeWriter w) {
         return variable.getVal();
     }
 
index ac987ed8102fe0ff14c87f49fbc5d27263b9925d..a08ed3923570719faccb76eb06690d8d1dec24a7 100644 (file)
@@ -1,10 +1,10 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
@@ -69,7 +69,7 @@ public class EViewPattern extends Expression {
     }
 
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         throw new InternalCompilerError(location, "EViewPattern.toVal should not be invoked.");
     }
 
index a0f28d190bf7340234ae5a052675f572f6275c10..2b75f61cd0c236a2d37a5f7dae20e26224281362 100644 (file)
@@ -4,6 +4,7 @@ import java.util.ArrayList;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
 import org.simantics.scl.compiler.common.precedence.Precedence;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.constants.NoRepConstant;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
@@ -15,7 +16,6 @@ import org.simantics.scl.compiler.elaboration.expressions.lhstype.PatternMatchin
 import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
 import org.simantics.scl.compiler.elaboration.query.QAtom;
 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
 import org.simantics.scl.compiler.internal.elaboration.decomposed.DecomposedExpression;
@@ -196,7 +196,7 @@ public abstract class Expression extends Symbol implements Typed {
             throw new TypeValidationException(loc);
     }
 
-       public abstract IVal toVal(Environment env, CodeWriter w);
+       public abstract IVal toVal(CompilationContext context, CodeWriter w);
                
        public Expression closure(TVar ... vars) {
            if(vars.length == 0)
@@ -303,14 +303,14 @@ public abstract class Expression extends Symbol implements Typed {
         throw new NotPatternException(this);
     }
     
-    public IVal lambdaToVal(Environment env, CodeWriter w) {
-        DecomposedExpression decomposed = DecomposedExpression.decompose(this);
+    public IVal lambdaToVal(CompilationContext context, CodeWriter w) {
+        DecomposedExpression decomposed = DecomposedExpression.decompose(context.errorLog, this);
         CodeWriter newW = w.createFunction(decomposed.typeParameters, decomposed.effect, decomposed.returnType, decomposed.parameterTypes);
         IVal[] parameters = newW.getParameters();
         IVal functionVal = newW.getFunction().getTarget();
         for(int i=0;i<parameters.length;++i)
             decomposed.parameters[i].setVal(parameters[i]);
-        newW.return_(decomposed.body.toVal(env, newW));
+        newW.return_(decomposed.body.toVal(context, newW));
         return functionVal;
     }
     
index 890d11f8c7a2dc084611786332159f4a3ec48dd5..23b2f62246478fe44758d65cc0bf8c5301031c00 100644 (file)
@@ -1,10 +1,10 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.continuations.ICont;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
@@ -52,11 +52,11 @@ public class GuardedExpressionGroup extends Expression {
     }
 
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         CodeWriter success = w.createBlock(getType());
         IVal result = success.getParameters()[0];
         CodeWriter failure = w.createBlock();
-        compile(env, w, success.getContinuation(), failure.getContinuation());
+        compile(context, w, success.getContinuation(), failure.getContinuation());
         w.continueAs(success);
         failure.throw_(location, Throw.MatchingException, "Matching failure at: " + toString());
         return result;
@@ -102,7 +102,7 @@ public class GuardedExpressionGroup extends Expression {
         return this;
     }
     
-    public void compile(Environment env, CodeWriter firstWriter, ICont success,
+    public void compile(CompilationContext context, CodeWriter firstWriter, ICont success,
             ICont lastFailure) {
         // Create all code blocks
         CodeWriter[] writers = new CodeWriter[expressions.length];                
@@ -122,11 +122,11 @@ public class GuardedExpressionGroup extends Expression {
             
             for(Expression guard : expressions[i].guards) {
                 CodeWriter nextW = w.createBlock();
-                w.if_(guard.toVal(env, w), nextW.getContinuation(), failure);
+                w.if_(guard.toVal(context, w), nextW.getContinuation(), failure);
                 w = nextW;
             }
             
-            w.jump(success, expressions[i].value.toVal(env, w));
+            w.jump(success, expressions[i].value.toVal(context, w));
         }
     }
     
index ef59b7d174953328ca7f1b44ec4ff54215aac7be..3d2604da423fc725cd3c3396603bbfd7647cb3e9 100644 (file)
@@ -1,7 +1,7 @@
 package org.simantics.scl.compiler.elaboration.expressions;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
-import org.simantics.scl.compiler.environment.Environment;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
 
@@ -15,7 +15,7 @@ public abstract class SimplifiableExpression extends Expression {
     }
 
     @Override
-    public IVal toVal(Environment env, CodeWriter w) {
+    public IVal toVal(CompilationContext context, CodeWriter w) {
         throw new InternalCompilerError("Cannot generate code for " + getClass().getSimpleName() + ".");
     }
 }
index 0ad3096b237a9c0d3279af6295f87f7b9c15f2a7..64e859253d39e16cbe62282b7f39355dd4f0553f 100644 (file)
@@ -7,6 +7,7 @@ import org.simantics.scl.compiler.elaboration.expressions.ELambdaType;
 import org.simantics.scl.compiler.elaboration.expressions.ESimpleLambda;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
+import org.simantics.scl.compiler.errors.ErrorLog;
 import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
 import org.simantics.scl.compiler.types.TVar;
 import org.simantics.scl.compiler.types.Type;
@@ -34,7 +35,7 @@ public class DecomposedExpression {
         this.body = body;
     }
 
-    public static DecomposedExpression decompose(Expression expression) {
+    public static DecomposedExpression decompose(ErrorLog errorLog, Expression expression) {
         ArrayList<TVar> typeParameterList = new ArrayList<TVar>();
         ArrayList<Variable> parameterList = new ArrayList<Variable>();
         Type effect = Types.NO_EFFECTS;
@@ -42,9 +43,9 @@ public class DecomposedExpression {
             if(expression instanceof ESimpleLambda) {
                 ESimpleLambda lambda = (ESimpleLambda)expression;
                 parameterList.add(lambda.parameter);
-                expression = lambda.value;
                 if(Types.canonical(effect) != Types.NO_EFFECTS)
-                    throw new InternalCompilerError();
+                    errorLog.logWarning(expression.location, "Encountered nested lambdas where outermost lambda contains effects. The reason is probably in the subsumption solver and code should be OK.");
+                expression = lambda.value;
                 effect = Types.simplifyFinalEffect(lambda.getLocalEffect());
             } 
             else if(expression instanceof ELambdaType) {
index 9bf056bef825fe3a6c3db4e0cbef0fed1572c6eb..12bf42e5bed980910034d3aa661938341a743247 100644 (file)
@@ -5,6 +5,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.constants.Constant;
 import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.EApplyType;
@@ -18,7 +19,6 @@ import org.simantics.scl.compiler.elaboration.expressions.Expression;
 import org.simantics.scl.compiler.elaboration.expressions.GuardedExpressionGroup;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.internal.codegen.continuations.Branch;
 import org.simantics.scl.compiler.internal.codegen.continuations.ICont;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
@@ -54,7 +54,7 @@ public class PatternMatchingCompiler {
         return newVals;
     }
 
-    private static void splitByConstructors(CodeWriter w, final Environment env, IVal[] scrutinee, final ICont success, ICont failure, List<Row> rows, int columnId) {
+    private static void splitByConstructors(CodeWriter w, final CompilationContext context, IVal[] scrutinee, final ICont success, ICont failure, List<Row> rows, int columnId) {
         THashMap<Object, ExpressionMatrix> matrixMap = new THashMap<Object, ExpressionMatrix>();
         ArrayList<Branch> branches = new ArrayList<Branch>();
         ArrayList<ExpressionMatrix> matrices = new ArrayList<ExpressionMatrix>();
@@ -167,7 +167,7 @@ public class PatternMatchingCompiler {
             CodeWriter newW = w.createBlock();
             ICont cont = newW.getContinuation();
             branches.add(new Branch(null, cont));
-            split(newW, env, scrutinee, success, failure, rows.subList(i, rows.size()));
+            split(newW, context, scrutinee, success, failure, rows.subList(i, rows.size()));
             failure = cont;
         }
         else {
@@ -177,7 +177,7 @@ public class PatternMatchingCompiler {
             } catch (MatchException e) {
                 throw new InternalCompilerError();
             }
-            TypeConstructor cons = (TypeConstructor)env.getTypeDescriptor(con);
+            TypeConstructor cons = (TypeConstructor)context.environment.getTypeDescriptor(con);
             int maxBranchCount = cons.isOpen ? Integer.MAX_VALUE 
                     : cons.constructors.length;
             if(branches.size() < maxBranchCount)
@@ -185,11 +185,11 @@ public class PatternMatchingCompiler {
         }
 
         for(ExpressionMatrix mx : matrices)
-            split(mx.w, env, mx.scrutinee, success, failure, mx.rows);
+            split(mx.w, context, mx.scrutinee, success, failure, mx.rows);
         w.switch_(scrutinee[columnId], branches.toArray(new Branch[branches.size()]));
     }
 
-    private static void splitByViewPattern(CodeWriter w, Environment env, IVal[] scrutinee, ICont success,
+    private static void splitByViewPattern(CodeWriter w, CompilationContext context, IVal[] scrutinee, ICont success,
             ICont failure, List<Row> rows, int viewPatternColumn) {
         Row firstRow = rows.get(0);
         EViewPattern firstViewPattern = (EViewPattern)firstRow.patterns[viewPatternColumn];
@@ -221,19 +221,19 @@ public class PatternMatchingCompiler {
         IVal[] newScrutinee = Arrays.copyOf(scrutinee, scrutinee.length);
         newScrutinee[viewPatternColumn] =
                 w.apply(firstViewPattern.location,
-                        firstViewPattern.expression.toVal(env, w),
+                        firstViewPattern.expression.toVal(context, w),
                         scrutinee[viewPatternColumn]);
         if(i == rows.size()) {
-            split(w, env, newScrutinee, success, failure, rows);
+            split(w, context, newScrutinee, success, failure, rows);
         }
         else {
             CodeWriter cont = w.createBlock();
-            split(w, env, newScrutinee, success, cont.getContinuation(), rows.subList(0, i));
-            split(cont, env, scrutinee, success, failure, rows.subList(i, rows.size()));
+            split(w, context, newScrutinee, success, cont.getContinuation(), rows.subList(0, i));
+            split(cont, context, scrutinee, success, failure, rows.subList(i, rows.size()));
         }
     }
 
-    public static void split(CodeWriter w, Environment env, IVal[] scrutinee, ICont success, ICont failure, List<Row> rows) {
+    public static void split(CodeWriter w, CompilationContext context, IVal[] scrutinee, ICont success, ICont failure, List<Row> rows) {
         Row firstRow = rows.get(0);
         Expression[] patterns = firstRow.patterns;
         if(scrutinee.length != patterns.length)
@@ -248,13 +248,13 @@ public class PatternMatchingCompiler {
                     viewPatternColumn = i;
             }
             else if(!(pattern instanceof EVariable)) {
-                splitByConstructors(w, env, scrutinee, success, failure, rows, i);
+                splitByConstructors(w, context, scrutinee, success, failure, rows, i);
                 return;
             }
         }
         
         if(viewPatternColumn >= 0) {
-            splitByViewPattern(w, env, scrutinee, success, failure, rows, viewPatternColumn);
+            splitByViewPattern(w, context, scrutinee, success, failure, rows, viewPatternColumn);
             return;
         }
 
@@ -264,16 +264,16 @@ public class PatternMatchingCompiler {
         if(firstRow.value instanceof GuardedExpressionGroup) {
             GuardedExpressionGroup group = (GuardedExpressionGroup)firstRow.value;
             if(rows.size() == 1) {
-                group.compile(env, w, success, failure);
+                group.compile(context, w, success, failure);
             }
             else {
                 CodeWriter newW = w.createBlock();            
                 ICont cont = newW.getContinuation();
-                group.compile(env, w, success, cont);
-                split(newW, env, scrutinee, success, failure, rows.subList(1, rows.size()));
+                group.compile(context, w, success, cont);
+                split(newW, context, scrutinee, success, failure, rows.subList(1, rows.size()));
             }
         }
         else
-            w.jump(success, firstRow.value.toVal(env, w));
+            w.jump(success, firstRow.value.toVal(context, w));
     }
 }
index bd904cf28ef52bbc5e7ddc058a1a9fe28978a672..8ca51b275f900a439d5b7a5025ab3d2e96444588 100644 (file)
@@ -5,6 +5,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.constants.Constant;
 import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.EApplyType;
@@ -17,7 +18,6 @@ import org.simantics.scl.compiler.elaboration.expressions.EViewPattern;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.internal.codegen.continuations.Branch;
 import org.simantics.scl.compiler.internal.codegen.continuations.ICont;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
@@ -53,7 +53,7 @@ public class PatternMatchingCompiler2 {
         return newVals;
     }
 
-    private static void splitByConstructors(CodeWriter w, final Environment env, IVal[] scrutinee, ICont failure, List<Row2> rows, int columnId) {
+    private static void splitByConstructors(CodeWriter w, final CompilationContext context, IVal[] scrutinee, ICont failure, List<Row2> rows, int columnId) {
         THashMap<Object, ExpressionMatrix> matrixMap = new THashMap<Object, ExpressionMatrix>();
         ArrayList<Branch> branches = new ArrayList<Branch>();
         ArrayList<ExpressionMatrix> matrices = new ArrayList<ExpressionMatrix>();
@@ -166,7 +166,7 @@ public class PatternMatchingCompiler2 {
             CodeWriter newW = w.createBlock();
             ICont cont = newW.getContinuation();
             branches.add(new Branch(null, cont));
-            split(newW, env, scrutinee, failure, rows.subList(i, rows.size()));
+            split(newW, context, scrutinee, failure, rows.subList(i, rows.size()));
             failure = cont;
         }
         else {
@@ -176,7 +176,7 @@ public class PatternMatchingCompiler2 {
             } catch (MatchException e) {
                 throw new InternalCompilerError(e);
             }
-            TypeConstructor cons = (TypeConstructor)env.getTypeDescriptor(con);
+            TypeConstructor cons = (TypeConstructor)context.environment.getTypeDescriptor(con);
             int maxBranchCount = cons.isOpen ? Integer.MAX_VALUE 
                     : cons.constructors.length;
             if(branches.size() < maxBranchCount)
@@ -184,11 +184,11 @@ public class PatternMatchingCompiler2 {
         }
 
         for(ExpressionMatrix mx : matrices)
-            split(mx.w, env, mx.scrutinee, failure, mx.rows);
+            split(mx.w, context, mx.scrutinee, failure, mx.rows);
         w.switch_(scrutinee[columnId], branches.toArray(new Branch[branches.size()]));
     }
 
-    private static void splitByViewPattern(CodeWriter w, Environment env, IVal[] scrutinee, ICont failure, List<Row2> rows, int viewPatternColumn) {
+    private static void splitByViewPattern(CodeWriter w, CompilationContext context, IVal[] scrutinee, ICont failure, List<Row2> rows, int viewPatternColumn) {
         Row2 firstRow = rows.get(0);
         EViewPattern firstViewPattern = (EViewPattern)firstRow.patterns[viewPatternColumn];
         firstRow.patterns[viewPatternColumn] = firstViewPattern.pattern;
@@ -219,19 +219,19 @@ public class PatternMatchingCompiler2 {
         IVal[] newScrutinee = Arrays.copyOf(scrutinee, scrutinee.length);
         newScrutinee[viewPatternColumn] =
                 w.apply(firstViewPattern.location,
-                        firstViewPattern.expression.toVal(env, w),
+                        firstViewPattern.expression.toVal(context, w),
                         scrutinee[viewPatternColumn]);
         if(i == rows.size()) {
-            split(w, env, newScrutinee, failure, rows);
+            split(w, context, newScrutinee, failure, rows);
         }
         else {
             CodeWriter cont = w.createBlock();
-            split(w, env, newScrutinee, cont.getContinuation(), rows.subList(0, i));
-            split(cont, env, scrutinee, failure, rows.subList(i, rows.size()));
+            split(w, context, newScrutinee, cont.getContinuation(), rows.subList(0, i));
+            split(cont, context, scrutinee, failure, rows.subList(i, rows.size()));
         }
     }
 
-    public static void split(CodeWriter w, Environment env, IVal[] scrutinee, ICont failure, List<Row2> rows) {
+    public static void split(CodeWriter w, CompilationContext context, IVal[] scrutinee, ICont failure, List<Row2> rows) {
         Row2 firstRow = rows.get(0);
         Expression[] patterns = firstRow.patterns;
         if(scrutinee.length != patterns.length)
@@ -246,13 +246,13 @@ public class PatternMatchingCompiler2 {
                     viewPatternColumn = i;
             }
             else if(!(pattern instanceof EVariable)) {
-                splitByConstructors(w, env, scrutinee, failure, rows, i);
+                splitByConstructors(w, context, scrutinee, failure, rows, i);
                 return;
             }
         }
         
         if(viewPatternColumn >= 0) {
-            splitByViewPattern(w, env, scrutinee, failure, rows, viewPatternColumn);
+            splitByViewPattern(w, context, scrutinee, failure, rows, viewPatternColumn);
             return;
         }
 
index a5b9a65417e79e095acc83149f49d40ffa47690d..a1724428303502e3de48030bf7545e853735ce3f 100644 (file)
@@ -367,7 +367,7 @@ public class ExpressionEvaluator {
         // Convert to SSA
         ModuleWriter mw = new ModuleWriter(namingPolicy.getModuleClassName());
         DecomposedExpression decomposed = 
-                DecomposedExpression.decompose(expression);
+                DecomposedExpression.decompose(errorLog, expression);
 
         SCLConstant constant = new SCLConstant(
                 Name.create(moduleName, COMPUTATION_METHOD_NAME),
@@ -388,7 +388,7 @@ public class ExpressionEvaluator {
             IVal[] parameterVals = w.getParameters();
             for(int i=0;i<decomposed.parameters.length;++i)
                 decomposed.parameters[i].setVal(parameterVals[i]);
-            w.return_(decomposed.body.toVal(environment, w));
+            w.return_(decomposed.body.toVal(compilationContext, w));
         } catch(RuntimeException e) {
             errorLog.setExceptionPosition(expression.location);
             throw new SCLExpressionCompilationException(errorLog.getErrors());
index fe18da61d1fdc215fe3c7a5f342cf96a47eaed96..c4d1c6f235f40f8758cc6570812b909b450e793a 100644 (file)
@@ -1,5 +1,7 @@
 package org.simantics.scl.compiler.tests;
 
+import org.junit.Test;
+
 public class ActiveTests extends TestBase {
     
     public ActiveTests() { super("scl"); }
@@ -17,5 +19,4 @@ public class ActiveTests extends TestBase {
   */  
     
     //@Test public void Bug6989() { test(); }
-
 }
index f065b765e7ce871bb91882e9edcdecf8d28ee1c6..a5975932b2fdc142ab952229c29f93c9ade7c7bf 100644 (file)
@@ -52,11 +52,13 @@ public class ModuleRegressionTests extends TestBase {
     @Test public void Effects4() { test(); }
     @Test public void Effects5() { test(); }
     @Test public void Effects6() { test(); }
+    @Test public void EmptyDo() { test(); }
     @Test public void EmptyLet() { test(); }
     @Test(expected=ValueNotFound.class) 
     public void EmptyModule() throws ValueNotFound {
         test(new String[]{"EmptyModule"}, new String[]{""});
     }
+    
     @Test public void Equality() { test(); }
     @Test public void ExistentialData() { test(); }
     @Test public void ExistentialData2() { test(); }
@@ -113,6 +115,7 @@ public class ModuleRegressionTests extends TestBase {
     @Test public void InvalidPattern2() { test(); }
     @Test public void InvalidPattern3() { test(); }
     @Test public void InvalidPattern4() { test(); }
+    @Test public void InvalidRunProc() { test(); }
     @Test public void InvalidTypeClassInstance1() { test(); }
     @Test public void JavaAccess1() { test(); }
     @Test public void JavaConstructors() { test(); }
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/EmptyDo.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/EmptyDo.scl
new file mode 100644 (file)
index 0000000..43692b2
--- /dev/null
@@ -0,0 +1,3 @@
+main = do
+--
+1:8-1:10: Block should not be empty.
\ No newline at end of file
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/InvalidRunProc.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/InvalidRunProc.scl
new file mode 100644 (file)
index 0000000..2460cfb
--- /dev/null
@@ -0,0 +1,7 @@
+import "StandardLibrary"
+
+main = do
+    runProc (\_ -> print (randomN 10))
+    0
+--
+0
\ No newline at end of file