Commit Graph

718 Commits

Author SHA1 Message Date
Doug Gregor
00c8099fe6 [Constraint solver] Initial work on a less horrible solver.
This solver handles most of what the old solver does (enabling it by
default only causes 9 test failures), but is radically simpler and
already significantly faster (~50% slower than the old-old type
checker on swift.swift). There are some egregious hacks here to still
be eliminated (see FIXMEs), but it's a start.


Swift SVN r5272
2013-05-22 20:01:32 +00:00
Doug Gregor
d8152fe3a7 [Constraint application] Handle substitution/conformance computation for member access directly.
This eliminates the use of
TypeChecker::substBaseForGenericTypeMember() from constraint
application, which relies on the existing type checker's
isCoercibleToType(). The standalone version is a bit cleaner.


Swift SVN r5156
2013-05-13 17:21:02 +00:00
Doug Gregor
87d2a580a6 Use the ArrayBound protocol for type-checking array bounds.
This only applies to the new type checker. The old type checker still
uses the informal protocol.


Swift SVN r5144
2013-05-10 17:46:58 +00:00
Doug Gregor
d6ca87b614 [Constraint checker] Implement typeCheckCondition() with a constraint system.
Introduce the LogicValue protocol, which is used to establish when a
particular type can be used as a logical value in a condition. Make
Bool conform to this protocol.

Rename the Builtin.i1-returning Bool.getLogicValue() to
_getBuiltinLogicValue(), because this is meant to be a builtin hook
for the compiler. We can add more underscores here if needed to hide
this further from users. 

Move the implementation of _getBool() into C code. It was performing
an 'if' on a Builtin.i1, which does not (and should not!) conform to
the LogicValue protocol. Once more oneof IR generation comes online,
we'll be able to write both this and _getBuiltinLogicValue in Swift
directly.



Swift SVN r5140
2013-05-10 15:42:41 +00:00
Doug Gregor
25e67b2792 FunctionConversionExpr supports arbitrary conversions, not just subtyping.
Fixes regression introduced in r5126.


Swift SVN r5129
2013-05-09 22:31:49 +00:00
Doug Gregor
543c1d36f3 Use the constraint system to determine subtyping relationships.
Eliminates another tie to the old type checker.


Swift SVN r5128
2013-05-09 22:18:37 +00:00
Doug Gregor
1db6dcd8c4 [Constraint application] Remove the now-unused isAssignment flag.
Swift SVN r5115
2013-05-09 17:19:26 +00:00
Doug Gregor
5349f9e551 [Constraint application] Thread more locators through constraint application.
As part of exercising this, tighten up the handling of user-defined
conversions: we always need to find an overload choice in the solution
that tells us what conversion function to use. Fix some
locator-synchronization issues between constraint generation and
constraint application; these need to match up exactly.


Swift SVN r5104
2013-05-08 23:07:29 +00:00
Doug Gregor
c1039b3e55 [Constraint application] Move coerceToType() into ExprRewriter.
We need more of the facilities of ExprRewriter to handle user-defined
conversions. This is a step in that direction. No functionality
change.


Swift SVN r5098
2013-05-08 20:12:33 +00:00
Doug Gregor
376089190d [Constraint application] Thread locators through coercions.
No functionality change, yet.


Swift SVN r5097
2013-05-08 18:39:20 +00:00
Doug Gregor
22859a119b [Constraint checker] A solution should know about the constraint system it solves.
No functionality change here. As a drive-by, fix the locator for
user-defined conversions.


Swift SVN r5091
2013-05-08 17:56:31 +00:00
Doug Gregor
e114abe21c [Constraint application] Coerce tuples to tuples.
Start factoring out the logic that computes the mapping from one tuple
type to another. We're only using it in one place now (the
tuple-to-tuple coercion), but it should be picked up by the constraint
checker's type-matching code.

Also, fix the temporary statistics covering how much is going through
the old coercion code. With this change, we're only missing 40 of 4548
of the coercions in swift.swift (all of which appear to be string
interpolations, function type conversions, or user-defined
conversions).


Swift SVN r5087
2013-05-08 04:03:53 +00:00
Doug Gregor
7b03a4dfed Move the constraint checker's type-coercion logic into Solution.
No functionality change (yet).


Swift SVN r5067
2013-05-06 22:52:01 +00:00
Joe Groff
635b84a228 Sema: Get metatypes for type member constraints inside addTypeMemberConstraint.
This eliminates some boilerplate from the call sites where addTypeMemberConstraint is used correctly, fixes bugs where it isn't (viz. in openType, where we were matching secondary archetypes to the metatype types of the associated types rather than to the associated types themselves), and should prevent the same class of bug from being introduced by new type member constraint generators.

Swift SVN r5041
2013-05-05 17:29:22 +00:00
Doug Gregor
2c85604e14 Remove the T(x)-as-coercion syntax from the type checker.
Swift SVN r5008
2013-05-01 04:17:21 +00:00
Doug Gregor
9b4757b288 Minor formatting cleanups.
Swift SVN r4640
2013-04-09 21:43:36 +00:00
Joe Groff
4923acce2b Use C++11 alignof(T) instead of llvm::AlignOf<T>.
Swift SVN r4583
2013-04-03 02:41:29 +00:00
Doug Gregor
be66b4546f Split the constraint-based type checker into five parts.
The five parts are:
  - Support code and high-level entry points
  - Constraint generation
  - Constraint solving
  - Constraint application
  - Diagnostics

No functionality change.


Swift SVN r4447
2013-03-19 16:04:31 +00:00