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;
@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();
@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));
}
}
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;
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;
@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:
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();
}
@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));
}
}
continue;
DecomposedExpression decomposed =
- DecomposedExpression.decompose(expression);
+ DecomposedExpression.decompose(errorLog, expression);
CodeWriter w = mw.createFunction((SCLConstant)value.getValue(),
decomposed.typeParameters,
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)
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);
@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);
@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);
}
@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));
}
}
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);
@Override
public void generateCode(CompilationContext context, PlanContext planContext, CodeWriter w) {
- expression.toVal(context.environment, w);
+ expression.toVal(context, w);
planContext.nextOp(w);
}
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()])));
@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);
}
}
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())
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
throw new InternalCompilerError("Cannot generate code for " + getClass().getSimpleName() + ".");
}
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;
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;
}
@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);
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;
}
@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);
}
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
throw new InternalCompilerError("EAsPattern allowed only in patterns.");
}
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
throw new InternalCompilerError("EBind should be eliminated.");
}
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;
@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)) {
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;
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) {
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;
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
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;
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;
}
@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);
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;
}
@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
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
throw new UnsupportedOperationException();
}
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
ModuleWriter mw = w.getModuleWriter();
return mw.getExternalConstant(value, getType());
}
};
}
accessorExpression = new EAmbiguous(alternatives);
+ accessorExpression.location = location;
}
return new EApply(location, accessorExpression, parent).checkType(context, requiredType);
}
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;
}
@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);
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
- return lambdaToVal(env, w);
+ public IVal toVal(CompilationContext context, CodeWriter w) {
+ return lambdaToVal(context, w);
}
@Override
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;
}
@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) {
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,
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) {
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
return value;
}
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;
}
@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];
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
- return lambdaToVal(env, w);
+ public IVal toVal(CompilationContext context, CodeWriter w) {
+ return lambdaToVal(context, w);
}
@Override
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;
}
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;
}
@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
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
return variable.getVal();
}
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;
}
@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.");
}
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;
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;
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)
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;
}
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;
}
@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;
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];
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));
}
}
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;
}
@Override
- public IVal toVal(Environment env, CodeWriter w) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
throw new InternalCompilerError("Cannot generate code for " + getClass().getSimpleName() + ".");
}
}
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;
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;
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) {
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;
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;
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>();
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 {
} 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)
}
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];
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)
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;
}
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));
}
}
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;
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;
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>();
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 {
} 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)
}
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;
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)
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;
}
// 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),
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());
package org.simantics.scl.compiler.tests;
+import org.junit.Test;
+
public class ActiveTests extends TestBase {
public ActiveTests() { super("scl"); }
*/
//@Test public void Bug6989() { test(); }
-
}
@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(); }
@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(); }
--- /dev/null
+main = do
+--
+1:8-1:10: Block should not be empty.
\ No newline at end of file
--- /dev/null
+import "StandardLibrary"
+
+main = do
+ runProc (\_ -> print (randomN 10))
+ 0
+--
+0
\ No newline at end of file