Add a few more hacks to layer the application of a solved constraint system to an expression tree on the existing type checker.

Swift SVN r2838
This commit is contained in:
Doug Gregor
2012-09-12 20:43:05 +00:00
parent 39b9f431ee
commit f059cfd22d
4 changed files with 17 additions and 14 deletions

View File

@@ -1645,12 +1645,7 @@ void ConstraintSystem::generateConstraints(Expr *expr) {
}
auto &outerBound = expr->getBounds()[0];
resultTy = tc.getArraySliceType(outerBound.Brackets.Start, resultTy);
// FIXME: Will need to find/set the injection function, probably as
// part of applying the results of a constraint system to an expression.
// FIXME: Also set the element type.
return resultTy;
return tc.getArraySliceType(outerBound.Brackets.Start, resultTy);
}
Type visitNewReferenceExpr(NewReferenceExpr *expr) {
@@ -3485,12 +3480,7 @@ Expr *ConstraintSystem::applySolution(Expr *expr) {
Expr *visitDeclRefExpr(DeclRefExpr *expr) {
// FIXME: Introduce SpecializeExpr here if needed.
// Simplify the type of this expression, replacing all of the type
// variables with their determined types.
auto type = CS.simplifyType(expr->getType());
expr->setType(type);
return expr;
return visitExpr(expr);
}
Expr *visitApplyExpr(ApplyExpr *expr) {
@@ -3529,6 +3519,11 @@ Expr *ConstraintSystem::applySolution(Expr *expr) {
return CS.getTypeChecker().typeCheckNewReferenceExpr(expr);
}
Expr *visitNewArrayExpr(NewArrayExpr *expr) {
// FIXME: Actually implement this here.
return CS.getTypeChecker().typeCheckNewArrayExpr(expr);
}
Expr *visitExplicitClosureExpr(ExplicitClosureExpr *expr) {
auto type = CS.simplifyType(expr->getType());

View File

@@ -1664,6 +1664,10 @@ Expr *TypeChecker::typeCheckNewReferenceExpr(NewReferenceExpr *expr) {
return SemaExpressionTree(*this).visitNewReferenceExpr(expr);
}
Expr *TypeChecker::typeCheckNewArrayExpr(NewArrayExpr *expr) {
return SemaExpressionTree(*this).visitNewArrayExpr(expr);
}
bool TypeChecker::typeCheckExpression(Expr *&E, Type ConvertType) {
// If we're using the constraint solver, we take a different path through
// the type checker. Handle it here.

View File

@@ -393,6 +393,11 @@ public:
/// solver's application.
Expr *typeCheckNewReferenceExpr(NewReferenceExpr *expr);
/// \brief Type-check a NewArrayExpr.
/// FIXME: This is temporary; the logic will move into the constraint
/// solver's application.
Expr *typeCheckNewArrayExpr(NewArrayExpr *expr);
bool typeCheckExpression(Expr *&E, Type ConvertType = Type());
Expr *typeCheckExpressionConstraints(Expr *expr, Type convertType = Type());

View File

@@ -315,8 +315,8 @@ void swift::REPL(ASTContext &Context) {
if (llvm::sys::Process::StandardInIsUserInput())
printf("%s", "Welcome to swift. Type ':help' for assistance.\n");
bool useConstraintSolver = false;
while (1) {
bool useConstraintSolver = false;
bool debugConstraints = false;
// Read one line.
@@ -432,7 +432,6 @@ void swift::REPL(ASTContext &Context) {
CurBufferOffset,
CurBufferEndOffset);
if (useConstraintSolver) {
useConstraintSolver = false;
ShouldRun = false;
}