mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -1645,12 +1645,7 @@ void ConstraintSystem::generateConstraints(Expr *expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto &outerBound = expr->getBounds()[0];
|
auto &outerBound = expr->getBounds()[0];
|
||||||
resultTy = tc.getArraySliceType(outerBound.Brackets.Start, resultTy);
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Type visitNewReferenceExpr(NewReferenceExpr *expr) {
|
Type visitNewReferenceExpr(NewReferenceExpr *expr) {
|
||||||
@@ -3485,12 +3480,7 @@ Expr *ConstraintSystem::applySolution(Expr *expr) {
|
|||||||
|
|
||||||
Expr *visitDeclRefExpr(DeclRefExpr *expr) {
|
Expr *visitDeclRefExpr(DeclRefExpr *expr) {
|
||||||
// FIXME: Introduce SpecializeExpr here if needed.
|
// FIXME: Introduce SpecializeExpr here if needed.
|
||||||
|
return visitExpr(expr);
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr *visitApplyExpr(ApplyExpr *expr) {
|
Expr *visitApplyExpr(ApplyExpr *expr) {
|
||||||
@@ -3529,6 +3519,11 @@ Expr *ConstraintSystem::applySolution(Expr *expr) {
|
|||||||
return CS.getTypeChecker().typeCheckNewReferenceExpr(expr);
|
return CS.getTypeChecker().typeCheckNewReferenceExpr(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Expr *visitNewArrayExpr(NewArrayExpr *expr) {
|
||||||
|
// FIXME: Actually implement this here.
|
||||||
|
return CS.getTypeChecker().typeCheckNewArrayExpr(expr);
|
||||||
|
}
|
||||||
|
|
||||||
Expr *visitExplicitClosureExpr(ExplicitClosureExpr *expr) {
|
Expr *visitExplicitClosureExpr(ExplicitClosureExpr *expr) {
|
||||||
auto type = CS.simplifyType(expr->getType());
|
auto type = CS.simplifyType(expr->getType());
|
||||||
|
|
||||||
|
|||||||
@@ -1664,6 +1664,10 @@ Expr *TypeChecker::typeCheckNewReferenceExpr(NewReferenceExpr *expr) {
|
|||||||
return SemaExpressionTree(*this).visitNewReferenceExpr(expr);
|
return SemaExpressionTree(*this).visitNewReferenceExpr(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Expr *TypeChecker::typeCheckNewArrayExpr(NewArrayExpr *expr) {
|
||||||
|
return SemaExpressionTree(*this).visitNewArrayExpr(expr);
|
||||||
|
}
|
||||||
|
|
||||||
bool TypeChecker::typeCheckExpression(Expr *&E, Type ConvertType) {
|
bool TypeChecker::typeCheckExpression(Expr *&E, Type ConvertType) {
|
||||||
// If we're using the constraint solver, we take a different path through
|
// If we're using the constraint solver, we take a different path through
|
||||||
// the type checker. Handle it here.
|
// the type checker. Handle it here.
|
||||||
|
|||||||
@@ -393,6 +393,11 @@ public:
|
|||||||
/// solver's application.
|
/// solver's application.
|
||||||
Expr *typeCheckNewReferenceExpr(NewReferenceExpr *expr);
|
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());
|
bool typeCheckExpression(Expr *&E, Type ConvertType = Type());
|
||||||
Expr *typeCheckExpressionConstraints(Expr *expr, Type convertType = Type());
|
Expr *typeCheckExpressionConstraints(Expr *expr, Type convertType = Type());
|
||||||
|
|
||||||
|
|||||||
@@ -315,8 +315,8 @@ void swift::REPL(ASTContext &Context) {
|
|||||||
if (llvm::sys::Process::StandardInIsUserInput())
|
if (llvm::sys::Process::StandardInIsUserInput())
|
||||||
printf("%s", "Welcome to swift. Type ':help' for assistance.\n");
|
printf("%s", "Welcome to swift. Type ':help' for assistance.\n");
|
||||||
|
|
||||||
bool useConstraintSolver = false;
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
bool useConstraintSolver = false;
|
||||||
bool debugConstraints = false;
|
bool debugConstraints = false;
|
||||||
|
|
||||||
// Read one line.
|
// Read one line.
|
||||||
@@ -432,7 +432,6 @@ void swift::REPL(ASTContext &Context) {
|
|||||||
CurBufferOffset,
|
CurBufferOffset,
|
||||||
CurBufferEndOffset);
|
CurBufferEndOffset);
|
||||||
if (useConstraintSolver) {
|
if (useConstraintSolver) {
|
||||||
useConstraintSolver = false;
|
|
||||||
ShouldRun = false;
|
ShouldRun = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user