Commit Graph

14 Commits

Author SHA1 Message Date
Chris Lattner
a792065c57 continue rvalue world domination. Switch get-only subscript expressions to produce
rvalues instead of non-modifiable lvalues.


Swift SVN r11634
2013-12-25 21:34:52 +00:00
Chris Lattner
b92c57fd3e Extend MemberRefExpr in a fairly substantial way: now it is ok, when applied to a
struct rvalue, to produce a struct element directly, without converting the rvalue
to an lvalue.

This means that it no longer materializes an lvalue when applied to a let declaration
or other rvalue.  For example, this testcase:

struct X { var a,b : Int} 
func g() -> X { return X(1,2) }

func f() {
  let a = g().a
}

used to sema into:

       (load_expr implicit type='Int'
          (member_ref_expr type='@inout (implicit, nonsettable)Int' decl=t.(file).X.a@t.swift:2:16
            (materialize_expr implicit type='@inout (implicit)X'
              (call_expr type='X'

and silgen into:

  %1 = function_ref @_TF1t1gFT_VS_1X : $@thin () -> X // user: %2
  %2 = apply %1() : $@thin () -> X                // user: %4
  %3 = alloc_stack $X                             // users: %7, %5, %4
  store %2 to %3#1 : $*X                          // id: %4
  %5 = struct_element_addr %3#1 : $*X, #a         // user: %6
  %6 = load %5 : $*Int64

It now sema's into:
        (member_ref_expr type='Int' decl=t.(file).X.a@t.swift:1:16
          (call_expr type='X'

and silgens into:

  %1 = function_ref @_TF1t1gFT_VS_1X : $@thin () -> X // user: %2
  %2 = apply %1() : $@thin () -> X                // user: %3
  %3 = struct_extract %2 : $X, #a

I think I'm finally starting to grok Doug's crazy typechecker magic.



Swift SVN r11599
2013-12-23 06:24:55 +00:00
Doug Gregor
256b946a83 Record protocol conformance when we start checking, rather than at the end.
As part of this, take away the poor attempt at recovering by adding an
explicit protocol conformance. The recovery mode isn't all that useful
in a system with only explicit conformance, and it messes with
diagnostics further down the line. We can bring it back later once
we're happy with explicit conformance checking.


Swift SVN r11503
2013-12-20 15:46:31 +00:00
Chris Lattner
31ca8889cd eliminate TypeChecker::transformType, replacing it with Type::transform.
Swift SVN r11502
2013-12-20 05:43:26 +00:00
Chris Lattner
b29748a6be remove the ASTContext argument from Type::transform,
(various) FunctionType::get's, ArrayType::get,
ArraySliceType::get, OptionalType::get, and a few
other places.

There is more to be done here, but this is all I plan to do
for now.


Swift SVN r11497
2013-12-20 02:23:21 +00:00
Chris Lattner
1472e4d914 Remove the ASTContext argument from LValueType::get(). It is already
only two loads away from the type argument passed in.



Swift SVN r11496
2013-12-20 01:28:50 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
Doug Gregor
07c0793e30 Construct the type witnesses of SpecializedProtocolConformance lazily.
A SpecializedProtocolConformance intentionally contains all of the
information we need to synthesize the type witnesses from the
underlying (generic) conformance. Do so lazily rather than eagerly,
because we won't always need all of them.

As a nice side effect, we no longer need to serialize the witnesses of
these specialized protocol conformances, so we can save some space in
the Swift module file.


Swift SVN r11303
2013-12-14 06:20:44 +00:00
Doug Gregor
6fb1860f45 Replace multiple generated constraint sets with a single vector.
Swift SVN r11078
2013-12-10 16:46:46 +00:00
Doug Gregor
3755e6d556 Replace worklist deque with Active/Inactive constraint lists.
Swift SVN r11077
2013-12-10 16:36:36 +00:00
Doug Gregor
2d61bd31f8 Always use the constraint graph and worklist.
Since it takes the code in <rdar://problem/15476050> from > 10 minutes
to 4 seconds.


Swift SVN r11064
2013-12-10 01:25:56 +00:00
Doug Gregor
3040f2195b Factor our the selection of "alternative" literal type suggestions.
Swift SVN r11035
2013-12-09 19:19:21 +00:00
Doug Gregor
79f8175e0b Solver: Keep track of a solution's score as we're computing it.
No functionality change here; just staging for some future optimizations.


Swift SVN r11028
2013-12-09 17:12:07 +00:00
Doug Gregor
a6bd190b7c Split the core implementation of ConstraintSystem into its own file.
Swift SVN r11014
2013-12-09 14:05:35 +00:00