X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fcompilation%2FTypeChecking.java;h=667c089c3e24fe58561a674622f053a0ed6d9662;hp=554a360811b69b2312151b9c4f8fe503d131c790;hb=a8758de5bc19e5adb3f618d3038743a164f09912;hpb=12d9af17384d960b75d58c3935d2b7b46d93e87b diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/TypeChecking.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/TypeChecking.java index 554a36081..667c089c3 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/TypeChecking.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/TypeChecking.java @@ -25,7 +25,6 @@ import org.simantics.scl.compiler.elaboration.relations.SCLRelation; import org.simantics.scl.compiler.elaboration.rules.MappingRelation; import org.simantics.scl.compiler.elaboration.rules.TransformationRule; import org.simantics.scl.compiler.environment.Environment; -import org.simantics.scl.compiler.errors.ErrorLog; import org.simantics.scl.compiler.internal.elaboration.constraints.Constraint; import org.simantics.scl.compiler.internal.elaboration.constraints.ConstraintEnvironment; import org.simantics.scl.compiler.internal.elaboration.constraints.ConstraintSolver; @@ -45,17 +44,16 @@ import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.TIntHashSet; public class TypeChecking { - final ErrorLog errorLog; + final CompilationContext compilationContext; final Environment environment; final ConcreteModule module; ConstraintEnvironment ce; TypeCheckingScheduler scheduler; - public TypeChecking(ErrorLog errorLog, Environment environment, - ConcreteModule module) { - this.errorLog = errorLog; - this.environment = environment; + public TypeChecking(CompilationContext compilationContext, ConcreteModule module) { + this.compilationContext = compilationContext; + this.environment = compilationContext.environment; this.module = module; } @@ -100,7 +98,7 @@ public class TypeChecking { expression = expression.checkType(context, value.getType()); context.popEffectUpperBound(); for(EAmbiguous overloaded : context.overloadedExpressions) - overloaded.assertResolved(errorLog); + overloaded.assertResolved(compilationContext.errorLog); value.setExpression(expression); ArrayList constraintDemand = context.getConstraintDemand(); @@ -129,7 +127,7 @@ public class TypeChecking { for(Constraint c : red.unsolvedConstraints) if(c.constraint.isGround()) - errorLog.log(c.getDemandLocation(), "There is no instance for <"+c.constraint+">."); + compilationContext.errorLog.log(c.getDemandLocation(), "There is no instance for <"+c.constraint+">."); ArrayList fe = new ArrayList(red.unsolvedConstraints.size()); for(Constraint c : red.unsolvedConstraints) @@ -212,12 +210,12 @@ public class TypeChecking { ArrayList givenConstraints = new ArrayList(); type = Types.removePred(type, givenConstraints); - TypingContext context = new TypingContext(errorLog, environment); + TypingContext context = new TypingContext(compilationContext); context.pushEffectUpperBound(expression.location, Types.PROC); expression = expression.checkType(context, type); context.popEffectUpperBound(); for(EAmbiguous overloaded : context.overloadedExpressions) - overloaded.assertResolved(errorLog); + overloaded.assertResolved(compilationContext.errorLog); expression.getType().addPolarity(Polarity.POSITIVE); context.solveSubsumptions(expression.getLocation()); ArrayList demands = context.getConstraintDemand(); @@ -226,10 +224,10 @@ public class TypeChecking { ConstraintSolver.solve(ce, givenConstraints, demands, true); givenConstraints.clear(); for(Constraint c : red.unsolvedConstraints) { - errorLog.log(c.getDemandLocation(), + compilationContext.errorLog.log(c.getDemandLocation(), "Constraint <"+c.constraint+"> is not given and cannot be derived."); } - if(errorLog.isEmpty()) { // To prevent exceptions + if(compilationContext.errorLog.isEmpty()) { // To prevent exceptions expression = ExpressionAugmentation.augmentSolved( red.solvedConstraints, expression); @@ -239,13 +237,13 @@ public class TypeChecking { } } else { - if(errorLog.isEmpty()) // To prevent exceptions + if(compilationContext.errorLog.isEmpty()) // To prevent exceptions expression = expression.decomposeMatching(); } expression = expression.closure(vars.toArray(new TVar[vars.size()])); value.setExpression(expression); } catch(Exception e) { - errorLog.log(expression.location, e); + compilationContext.errorLog.log(expression.location, e); } } }); @@ -336,7 +334,7 @@ public class TypeChecking { public void typeCheck() { ce = new ConstraintEnvironment(environment); - scheduler = new TypeCheckingScheduler(errorLog, environment); + scheduler = new TypeCheckingScheduler(compilationContext); typeCheckValues(); typeCheckRelations(); @@ -424,7 +422,7 @@ public class TypeChecking { for(MappingRelation mappingRelation : module.getMappingRelations()) for(Type parameterType : mappingRelation.parameterTypes) if(!parameterType.isGround()) { - errorLog.log(mappingRelation.location, "Parameter types of the mapping relation are not completely determined."); + compilationContext.errorLog.log(mappingRelation.location, "Parameter types of the mapping relation are not completely determined."); break; } }