Commit Graph

12816 Commits

Author SHA1 Message Date
Chris Lattner
cd3f362faf revert r2364, which introduced the swift_allocClass entrypoint. The optimization that it was
trying to block has since been reverted, and I think there are other approachs that will work.


Swift SVN r2547
2012-08-03 23:27:15 +00:00
John McCall
9106aa6254 Rewrite the function-call infrastructure. This gets us
a lot closer to successfully emitting the polymorphic-min-over-ranges
example;  the main blocker right now seems to be that the witness
for a static member function is not, in fact, a static member
function at al, but a freestanding function.  That's legitimate,
but it probably needs some shepherding through the witness
system.

Swift SVN r2532
2012-08-03 08:10:47 +00:00
Eli Friedman
0bfcfbfb8a Change the type of ConstructorDecls to be of the form metatype<T> -> () -> (). Change a bunch of stuff to compensate. Get rid of ConstructorRefExpr, which is no longer used.
Swift SVN r2526
2012-08-03 03:58:44 +00:00
Eli Friedman
3d0d23b3ce Stop use OneOfElementDecls to represent constructors in structs.
Swift SVN r2518
2012-08-03 00:53:36 +00:00
Eli Friedman
519a683557 Shuffle around code to avoid a crash after IRGen errors.
Swift SVN r2510
2012-08-02 21:51:19 +00:00
Eli Friedman
a87d83b7b8 Work-in-progress towards getting generic new array expressions working.
Swift SVN r2509
2012-08-02 21:36:33 +00:00
Eli Friedman
76e6aa41b0 Change the computed type for OneOfElementDecls in OneOfs: for an Optional<T>, the OneOfElementDecl for Some now has type <T>(metatype<Optional<T>>) -> (T) -> Optional<T>, and the OneOfElementDecl for None has type <T>(metatype<Optional<T>>) -> Optional<T>.
The IRGen test is turned off because of another call-related IRGen crash (specifically, an indirect call of an indirect call crashes).



Swift SVN r2497
2012-07-30 23:31:23 +00:00
Ted Kremenek
4e121919d7 Remove redundant assignment. 'Changed' is unconditional set a few lines later.
Swift SVN r2490
2012-07-30 18:30:23 +00:00
Eli Friedman
84e858da4e Fix static member functions so a member of type T has type "metatype<T> -> () -> ()" instead of "() -> ()".
This is much more convenient for IRGen, and gives us a reasonable representation for a static
polymorphic function on a polymorphic type.

I had to hack up irgen::emitArrayInjectionCall a bit to make the rest of this patch work; John, please
revert those bits once emitCallee is fixed.



Swift SVN r2488
2012-07-28 06:47:25 +00:00
Eli Friedman
bd6ff42df2 A couple misc fixes for a testcase John and I were looking at (array new over a generic type). Not committing the testcase because it's still broken.
Swift SVN r2487
2012-07-27 22:20:36 +00:00
John McCall
f21d83aede Fix the standard library to use uitofp instead of sitofp
when turning integer constants into floating-point values.
Teach IR-gen to fold stdlib convertFromIntegerLiteral and
convertFromFloatLiteral calls.
Update a bunch of tests.

Swift SVN r2485
2012-07-27 21:03:17 +00:00
John McCall
011df45944 Fix the emission of member functions on generic types.
Swift SVN r2482
2012-07-27 18:37:09 +00:00
Eli Friedman
cfa9f4c101 Fix thunk generation for abstract return types in witness tables.
Swift SVN r2465
2012-07-26 21:28:45 +00:00
Doug Gregor
9e8633ac41 Encode and pass all of the archetypes, including derived archetypes,
in SpecializeExpr, so that we have complete substitution and
protocol-conformance information. On the IR generation side, pass
witness tables for all of the archetypes (again, including derived
archetypes) into generic functions, so that we have witness tables for
all of the associated types.

There are at least two major issues:

  (1) This is a terribly inefficient way to pass witness tables for
  associated types. The witness tables for associated types should be
  accessible via the witness tables of their parent. However, we need
  more information in the ASTs here, because there may be additional
  witness tables that will need to be passed for requirements that are
  placed on the associated type by the generic function itself.

  (2) Something about my test triggers a void/non-void verification failure
  in the witness build for an instance function whose abstracted form
  returns an associated type archetype and whose concrete form returns
  an empty struct. See the FIXME in the test.



Swift SVN r2464
2012-07-26 17:52:04 +00:00
John McCall
6e5cdeadaa Fix a mangling ambiguity by ensuring that manglings never end
in a digit.  This penalizes the manglings of things using
builtin types but is kinder to the manglings of tuples.

Also, invent a not-unreasonable mangling for generic function
types and archtypes within them.

Swift SVN r2461
2012-07-26 07:03:17 +00:00
Eli Friedman
5419c62e9f Add missing Scope in logical &&/|| IRGen. <rdar://problem/11959537>.
Swift SVN r2459
2012-07-26 00:21:46 +00:00
John McCall
d076d5fc04 Mangling for BoundGenericType.
Swift SVN r2458
2012-07-25 22:54:15 +00:00
Eli Friedman
688138482d Complete the implementation of a basic Vector<T>.
Swift SVN r2457
2012-07-25 22:51:46 +00:00
John McCall
04a10f08bb Fix the mangling of generic types, change the mangling of
non-generic nominal types to encode the type kind, and add
substitutions for certain very common standard types while
we're at it.  Sorry, Howard.

Swift SVN r2455
2012-07-25 22:42:13 +00:00
John McCall
f7aca3f7fb Progress towards generic types.
Swift SVN r2454
2012-07-25 22:42:07 +00:00
Eli Friedman
83a29c9cff Fix a small FIXME related to static methods in witness tables.
Swift SVN r2451
2012-07-25 21:27:59 +00:00
Doug Gregor
64130a82ad When checking protocol conformance for an operator requirement,
perform global operator lookup and match those operators. We can now
type-check a proper 'min' function that uses '<'.


Swift SVN r2449
2012-07-25 21:10:48 +00:00
Eli Friedman
ea6348f446 Make NewReferenceExpr inherit from ApplyExpr; this lets us delete some redundant code.
Swift SVN r2447
2012-07-25 20:55:51 +00:00
Doug Gregor
511dbfea25 When applying an operator found in a protocol, compute the effetive
base type (e.g., the archetype type, when we're in a generic function)
used to refer to that operator as a member, e.g., given

  func min<T : Ord>(x : T, y : T) {
    if y < x { return y } else { return x }
  }

'<' is found in the Ord protocol, and is referenced as

  archetype_member_ref_expr type='(lhs : T, rhs : T) -> Bool' decl=<
    (typeof_expr type='metatype<T>'))

using a new expression kind, TypeOfExpr, that simply produces a value
of metatype type for use as the base.

This solves half of the problem with operators in protocols; the other
half of the problem involves matching up operator requirements
appropriately when checking protocol conformance.


Swift SVN r2443
2012-07-25 16:04:30 +00:00
Eli Friedman
2834352a73 Fix a bug emitting the definition of a generic constructor on a class.
NewReferenceExprs referencing generic constructors still don't work;
I'm having trouble following how the code is supposed to work.



Swift SVN r2441
2012-07-25 01:23:30 +00:00
Eli Friedman
30d1f22bfb Rewrite the representation of NewReferenceExpr to make it more friendly to generics.
Generic constructors on classes should be working with this commit.



Swift SVN r2440
2012-07-25 00:49:03 +00:00
Eli Friedman
235255cdc8 A couple minor tweaks to my last commit.
Swift SVN r2439
2012-07-24 23:53:25 +00:00
Eli Friedman
751c463a2e Rewrite the way we represent construction of value types so that it looks
more like a call.  This should be enough to get generic constructors working.



Swift SVN r2437
2012-07-24 23:43:43 +00:00
Eli Friedman
28d9744843 Fix mangling for local functions in a getter/setter.
Swift SVN r2435
2012-07-24 21:01:53 +00:00
Eli Friedman
58247ec603 Fix IRGen bug with local functions. <rdar://problem/11935459>.
Swift SVN r2434
2012-07-24 20:47:13 +00:00
John McCall
1be602a010 The return type passed to the call emitter needs to be the substituted
return type, not the original.  We were getting away with it
as long as we had a final address, but we won't always have
a final address, as in this test case, where we're ignoring the
result.

Swift SVN r2421
2012-07-24 02:38:57 +00:00
Eli Friedman
fec6ff2d07 Disable performStoreOnlyObjectElimination because it's causing leaks (and the leaks are blocking Howard's work).
Swift SVN r2412
2012-07-23 21:21:27 +00:00
Doug Gregor
b405157742 Fix comment
Swift SVN r2406
2012-07-23 15:42:35 +00:00
John McCall
7426712f74 Split out the cases for BoundGenericType, but keep punting
for now.

Swift SVN r2404
2012-07-23 07:35:29 +00:00
John McCall
ed38caaa04 Support generic return types, as long as they don't differ
by abstraction from the concrete return type.

This basically gets generic calls working totally as long
as there's no remapping required.

Swift SVN r2402
2012-07-23 07:06:28 +00:00
John McCall
555aa807b6 Dig into the formal type of a generic callee for the
call sites, since that's what we want to target for
substitution and witness-argument emission.

Swift SVN r2401
2012-07-22 10:05:24 +00:00
John McCall
a9b9c9c7f0 Collect CallSites in the CalleeSource. Closing in
actually getting a generic call to work.

Swift SVN r2400
2012-07-22 10:05:18 +00:00
John McCall
f16898b0e4 Extract the rvalue-under-substitutions code out into its own file.
Swift SVN r2399
2012-07-22 08:00:16 +00:00
John McCall
536ac7b01e Restructure differsByAbstraction to use SubstTypeVisitor.
Swift SVN r2398
2012-07-22 08:00:11 +00:00
John McCall
83505931f3 Basic argument passing as long as re-mapping isn't required.
Swift SVN r2397
2012-07-22 08:00:06 +00:00
John McCall
baae407f27 New kind of visitor for visiting substituted types.
Swift SVN r2396
2012-07-22 07:59:57 +00:00
John McCall
f254c4abb4 Add a little checker for whether something is a dependent type.
Swift SVN r2395
2012-07-22 07:59:52 +00:00
John McCall
b2b4a2a614 Add IRGen's inevitable specialization of the TypeVisitor class.
Swift SVN r2393
2012-07-22 07:59:40 +00:00
John McCall
da8c01938e Reorg, monster comment.
Swift SVN r2391
2012-07-22 07:59:22 +00:00
John McCall
3950a6af41 Generic calls status code dump activate!
Swift SVN r2386
2012-07-20 21:59:14 +00:00
John McCall
e67466d164 Reorganize how we collect substitutions for callees,
and convert the code that was drilling into function
expressions into an ASTVisitor.

Swift SVN r2385
2012-07-20 21:59:09 +00:00
Eli Friedman
d6a4ba90dd Move TypeLocs to a design where a TypeLoc is a struct containing a type plus
location info for that type.  Propagate TypeLocs a bit more through the AST.



Swift SVN r2383
2012-07-20 21:00:30 +00:00
Eli Friedman
f1f67db652 Big cleanup for how we handle computing types for functions and semantic
analysis for patterns.

Major changes:
1. We no longer try to compute the types of functions in the parser.
2. The type of a function always matches the type of the argument patterns.
3. Every FuncDecl now has a corresponding FuncExpr; that FuncExpr might not
   have a body, though.
4. We now use a new class "ExprHandle" so that both a pattern and a type
   can hold a reference to the same expression.

Hopefully this will be a more reasonable foundation for further changes to
how we compute the types of FuncDecls in generics and for the implementation
of type location information.



Swift SVN r2370
2012-07-19 02:09:04 +00:00
Eli Friedman
29b3994cca Add a new entry point for allocating classes. This API probably isn't really
right, but we need something in the meantime to make the optimizer understand
that there could be non-trivial destructors involved.



Swift SVN r2366
2012-07-17 23:25:02 +00:00
Eli Friedman
c9cb594eb3 IRGen for destructors. (This code is likely to change a lot once we design classes properly, but it should be a decent start.)
Swift SVN r2365
2012-07-17 22:41:23 +00:00