Commit Graph

2435 Commits

Author SHA1 Message Date
Joe Groff
50312c847f Add interpreter test for writeback behavior.
I broke writeback of byref arguments to functions with my RValue refactor, but assignment writeback (including destructuring assignments like (a, b) = (b, a)) should work. Add a test for it.

Swift SVN r4731
2013-04-13 22:35:36 +00:00
Joe Groff
7406986487 SILGen: Class constructors need to return modified self.
-[NSMutableArray init] modifies self, causing NSStringDemo to fail when sil-irgenned because SILGen didn't handle constructors changing 'this' correctly.

Swift SVN r4728
2013-04-13 19:21:10 +00:00
Joe Groff
964198453e IRGen/constructor.swift is an interpreter test.
Put it in its place.

Swift SVN r4727
2013-04-13 17:56:11 +00:00
Joe Groff
f52984501b SIL-IRGen can compile code using slices now!
Swift SVN r4612
2013-04-05 18:03:45 +00:00
Joe Groff
bb1f516555 IRGen: Lower SIL SpecializeInsts.
Collect the substitutions from SpecializeInsts and use them when emitting an ApplyInst to pass archetype parameters and to reexplode arguments at the right abstraction level for the generic callee. Unfortunately, ArchetypeTypeInfo::allocate() is broken, so alloc_box $T for an archetype type T doesn't yet work.

Swift SVN r4597
2013-04-04 22:39:35 +00:00
Joe Groff
aee590a4b0 IRGen: Enable C function calls from SIL.
Preserve the AbstractCC of a function symbol when emitting a SIL ConstantRefInst by adding a new StaticFunction variant to LoweredValue. This lets us avoid a bunch of bitcasting noise for static functions that aren't used as values, and will lets us emit C-to-Swift-ABI thunks on demand when C functions are used as values.

Swift SVN r4543
2013-03-29 19:47:46 +00:00
Joe Groff
4c09ef61e3 Add conditional expressions.
Implement the syntax 'if x then y else z', which evaluates to 'y' if 'x' is true or 'z' if 'x' is false. 'x' must be a valid logic value, and 'y' and 'z' must be implicitly convertible to a common type.

Swift SVN r4407
2013-03-16 20:28:58 +00:00
Joe Groff
062ad267c4 Value-only switch statements.
Implement switch statements with simple value comparison to get the drudge work of parsing and generating switches in place. Cases are checked using a '=~' operator to compare the subject of the switch to the value in the case. Unlike a C switch, cases each have their own scope and don't fall through. 'break' and 'continue' apply to an outer loop rather to the switch itself. Multiple case values can be specified in a comma-separated list, as in 'case 1, 2, 3, 4:'. Currently no effort is made to check for duplicate cases or to rank cases by match strength; cases are just checked in source order, and the first one wins (aside from 'default', which is branched to if all cases fail).

Swift SVN r4359
2013-03-12 04:43:01 +00:00
Doug Gregor
ddc2b113c9 Check for declaration overrides within extensions as well as within classes.
A Swift method in an extension cannot override a method nor can it be
overridden by a method. Diagnose this. We may remove this limitation
at a later time.

An [objc] method in an extension can override and can be overridden, so
specifically allow this case. It's useful in our Foundation bindings.



Swift SVN r4308
2013-03-06 19:56:56 +00:00
Joe Groff
2a74aa7b44 Move test/SIL/IRGen to test/Interpreter/SIL.
They're all really interpreter tests.

Swift SVN r4306
2013-03-06 18:36:52 +00:00
Joe Groff
3f83f18913 Add Interpreter/SDK test blocked on 13319547.
Swift SVN r4245
2013-03-01 00:16:31 +00:00
Joe Groff
a7d1d7e252 Add SDK-dependent Interpreter tests.
In the lit.site.cfg, if a MODULES_SDK is available, add a '%sdk' substitution and enable REQUIRES: sdk tests. Add some tests under test/Interpreter/SDK to test some basic ObjC interop features.

Swift SVN r4243
2013-02-28 23:44:41 +00:00
Joe Groff
f946737515 IRGen: Collect/emit nested generic substitutions.
Alter CalleeSource and Callee to keep their own internal vector of substitutions and concatentate multiple SpecializationExpr substitutions. Update EmitPolymorphicArguments::emit to emit arguments out of the substitution list based on the generic parameters of the current function type instead of assuming that the substitution list and generic parameter list match up.

Swift SVN r3937
2013-02-02 22:00:15 +00:00
Daniel Dunbar
3c6cf4ddbb [tests] Add a generic "generator" test I would like to work. :)
- Defines a Generator struct using generics + closures to make it simpler to
   implement iterators.

Let me know if you'd rather not have XFAILs in the test suite.

Swift SVN r2577
2012-08-07 22:15:08 +00:00
Doug Gregor
b2292e4688 Add minElement and maxElement algorithms, now that they are working.
Swift SVN r2558
2012-08-05 16:34:25 +00:00
Eli Friedman
26bebcfd61 IRGen for break/continue.
Swift SVN r2089
2012-05-31 02:45:18 +00:00
Doug Gregor
3fbd9682a1 Update the printf() implementation to match the May demo slides. Major
changes include: 

  - Each '%' in the format string is followed by some number of
    non-alpha characters (the "layout") and then an alpha character
    (the "kind"). The string and character are passed along to each
    FormattedPrintable's printFormatted() so they can do custom
    formatting
  - The Format struct is now used for the 'default' layout, which all
    of the standard libaries use
  - Added 'x' and 'o' custom formatting for formatting numbers in hex
    and octal, respectively. 'u' and 'l' can be used to print
    characters in uppercase or lowercase (String versions are yet to
    come).
  - The code for splitFormat()/printf() match what will be on the
    slides. They use the split operations to keep the whole thing
    linear, rather than performing inefficient slices.

There are some ugly hacks here due to <rdar://problem/11529601>.


Swift SVN r1980
2012-05-24 23:27:43 +00:00
Doug Gregor
ea6a7f94c9 Introduce String splitFirst/splitFirstIf algorithms.
Swift SVN r1979
2012-05-24 21:53:45 +00:00
Chris Lattner
2f44c0038c Initial stab at implementing string literal interpolation for simple expressions,
e.g. "foo is \(i+j)".  This implements rdar://11223686

Doug implemented all the hard parts of this.  I ripped out support for nested string
literals (i.e. string literals within an interpolated string), which simplified the
approach and defined away some problems with his patch in progress.  I plan a few refinements
on top of this basic patch.



Swift SVN r1738
2012-05-04 05:53:50 +00:00
Chris Lattner
02286ee034 add a few more shootout tests, exposing rdar://11344937
Swift SVN r1688
2012-04-30 04:28:35 +00:00
Chris Lattner
c7fd1b60ef add shootout_matrix, with several workarounds for rdar://11327139
Swift SVN r1687
2012-04-30 04:08:58 +00:00
Chris Lattner
edfe53294f add some benchmarks from shootout, but with reduce problem sizes since swift is so brutally slow.
Swift SVN r1685
2012-04-30 03:47:19 +00:00
Doug Gregor
86cf79a746 Add a range subscript operation for SliceInt64 that produces a slice, e.g.,
a[5..9]

will return a 4-element slice of the array a. Addresses
<rdar://problem/11329415>.


Swift SVN r1665
2012-04-27 00:07:52 +00:00
Chris Lattner
cc87aecfb9 add mandelbrot that goes through a temporary array.
Swift SVN r1656
2012-04-26 17:02:17 +00:00
Doug Gregor
44b3dd7b2b Move bitvector example into the Interpreter subdirectory and add some bit
get/set operations to test.

Add a String(Bool) constructor that produces 'true' or 'false'.



Swift SVN r1634
2012-04-25 16:14:29 +00:00
Doug Gregor
a04776044e Teach the import mechanism that it's rude to parse the same library
multiple times, as well as teaching the name lookup mechanism that
it's similarly rude to report ambiguous results because it searched
the same import twice. Fixes <rdar://problem/11287213>.

Yes, this is a bit of an ugly hack.


Swift SVN r1610
2012-04-24 22:36:17 +00:00
Ted Kremenek
123622ed38 Remove unndeed burningShip test (now in fractal.swift)
Swift SVN r1519
2012-04-20 00:05:21 +00:00
Ted Kremenek
edf7200447 Add 'fractal.swift' which does both mandelbrot and burning ship using a curried function core.
Swift SVN r1518
2012-04-20 00:05:02 +00:00
Eli Friedman
a5e1b4c645 Fix the REPL, which I accidentally broke. Add a test so it doesn't break by accident again.
Swift SVN r1504
2012-04-19 21:30:23 +00:00
Ted Kremenek
d702192c3f Add "burning ship" fractal test. Looking to consolidate with mandelbrot.
Swift SVN r1491
2012-04-19 05:25:36 +00:00
Ted Kremenek
bffb368f08 Replace mandelbrot.swift with mandelbrot2.swift.
Swift SVN r1490
2012-04-19 04:57:51 +00:00
Chris Lattner
ae316ce2a8 testcase for r1479, it will diverge from the other mandelbrot soon.
Swift SVN r1482
2012-04-19 00:45:18 +00:00
Ted Kremenek
9dd1c47287 Add Mandelbrot example.
Swift SVN r1460
2012-04-18 07:32:03 +00:00
Ted Kremenek
fe8ab72db6 Add a few interpreter examples based from samples from rosettacode.org
This currently consists of factorial and towers of hanoi, both using
recursion.

I'm not certain what the general policy will be for runtime tests,
but these don't look actively harmful right now and test real functionality.

Swift SVN r1440
2012-04-16 23:34:42 +00:00
Eli Friedman
d295d02c42 Initial interpreter implementation. The included pieces are enough to get the included simple.swift running in swift -i mode. <rdar://problem/10962290>, part 1.
Swift SVN r1319
2012-04-04 01:34:42 +00:00