Commit Graph

153 Commits

Author SHA1 Message Date
Chris Lattner
1040bfec6a In the REPL, allow access to the Builtin module if explicitly imported,
there is no reason to deny it and it could be theoretically useful.


Swift SVN r5779
2013-06-24 16:07:56 +00:00
Chris Lattner
e8bf1dd6f5 expand the TranslationUnit kind to handle "standard library", and
plumb it through the compiler a bit.  This simplifies some code
in the driver, but should not induce any behavior change (yet).


Swift SVN r5740
2013-06-21 17:42:37 +00:00
Dmitri Hrybenko
f7cc014820 Explicitly include PathV1.h where it is used
Swift SVN r5577
2013-06-13 22:16:30 +00:00
Joe Groff
49dfa58f37 REPL: Create a new MemoryBuffer for each input.
Instead of reusing a fixed-size buffer, which causes problems when error messages refer back to previous inputs and corrupts AST references in *LiteralExpr that point back into source buffers, allocate each REPL input into its own buffer with its own SourceMgr entry. Fixes <rdar://problem/13387167>, crashes when using :dump_ast on expressions containing integer/float literal expr nodes, and hopefully sporadic buildbot failures running the Interpreter/repl test.

Swift SVN r5470
2013-06-04 18:02:44 +00:00
Doug Gregor
17e788e04f Open literal types as binding types, to provide [] sugar for arrays.
Swift SVN r5436
2013-06-03 19:43:02 +00:00
Joe Groff
ccc28d3253 Add some more DEBUG() noise to -i mode.
Dump the module IR just prior to instantiating the execution engine, and log the start of module initializers, static constructors, and main().

Swift SVN r5430
2013-06-01 00:40:38 +00:00
Doug Gregor
c038ab92e6 Remove -no-constraint-checker/-constraint-checker and the corresponding language option.
Swift SVN r5387
2013-05-29 22:16:34 +00:00
Jordan Rose
878cc5f0e1 Hack: ignore loaded modules in immediate mode SILGen/IRGen.
This matches the behavior for compilation, and lets us test modules that
don't need any extra codegen.

With this, typealiases of builtins can be used end-to-end in modules!

Swift SVN r5326
2013-05-25 01:34:59 +00:00
Chris Lattner
f2e3af3cf6 Eliminate the "global" list of unresolved identifier types maintained
by TranslationUnit.  This list existed solely to allow name lookup of
an unbound IdentifierType to know its DeclContext.  Instead of indirecting
through this list, just store the DeclContext in the IdentifierType in its
uninitialized state.

This eliminates a really terrible performance fixme about scanning the list,
eliminates the management fiddling around with this list in the parser, and
is generally much cleaner.


Swift SVN r5246
2013-05-21 05:27:37 +00:00
Doug Gregor
dbdc9db90a Keep track of the extensions associated with a nominal type declaration.
Switch the REPL's printing of extensions to use this mechanism, mostly
as a sanity check.



Swift SVN r5221
2013-05-20 15:23:16 +00:00
Jordan Rose
77ce3f31cb Add a DeclContextKind for Swift modules.
Swift SVN r5095
2013-05-08 18:33:34 +00:00
Joe Groff
a2341a4cde Add Unicode symbol characters to operator charset.
Remove '@' from the operator character set, but add the math, symbol, punctuation, arrow, and line- and box-drawing characters. Also allow operators to contain (but not start with) combining characters--this should be safe, because identifiers can't start with combining characters either, and we don't allow them anywhere else.

Swift SVN r5019
2013-05-01 23:13:48 +00:00
Chris Lattner
5b4c31dc94 reland r4968, with a bugfix to avoid breaking the lexer measuring token lengths.
Original message:
SIL Parsing: add plumbing to know when we're parsing a .sil file
Enhance the lexer to lex "sil" as a keyword in sil mode.


Swift SVN r4988
2013-04-30 00:28:37 +00:00
Chris Lattner
aafe3bdbdc revert r4968, it apparently breaks the world. I'll recommit it when I have time to investigate.
Swift SVN r4971
2013-04-29 16:58:43 +00:00
Chris Lattner
b503206bec SIL Parsing: add plumbing to know when we're parsing a .sil file
Enhance the lexer to lex "sil" as a keyword in sil mode.


Swift SVN r4970
2013-04-29 05:42:59 +00:00
Doug Gregor
6ad8dfd230 <rdar://problem/13698402> Use raw_ostream::has_colors rather than is_displayed
to determine whether we should display colors.


Swift SVN r4832
2013-04-20 06:55:12 +00:00
Joe Groff
dc1fe2f8e2 Recursively SILGen modules before irgenning them.
Fixes <rdar://problem/13670581>.

Swift SVN r4777
2013-04-17 15:48:30 +00:00
Chris Lattner
2144140168 really use SIL IRGen for all recursive compilations as well, this exposes a symbol
redefinition (or linkage type) bug that causes two tests to fail.  I filed 
rdar://13670581 to track this and am plowing forward, since they seem minor.


Swift SVN r4761
2013-04-17 03:46:40 +00:00
Joe Groff
ad1c30539b Remove -no-sil-irgen option.
Swift SVN r4760
2013-04-17 00:48:36 +00:00
Chris Lattner
aa5a195477 Fix the repl when stdout is redirected.
The repl is sometimes failing to write anything to stdout when it is
being redirected to a file (as in test/Interpreter/repl.swift).  it
looks like an editline bug on 10.8.  explicitly fflushing stdout
seems to help.


Swift SVN r4669
2013-04-10 23:32:27 +00:00
Dave Abrahams
ad12dd6f9e Style fix: Use prevailing const& placement
Swift SVN r4627
2013-04-07 01:35:24 +00:00
Chris Lattner
db522fe7db thoroughly rework how the REPL synthesizes code to print values. This centralizes the
logic in Sema (previously, some of it was in tools/Swift/Frontend.cpp) and eliminates
redundancy between expr and pattern printing.  This also eliminates most of the invalid
ASTs that the repl was producing (there is still one left).

This commit reenables the disabled REPL testcase from my last big change.



Swift SVN r4622
2013-04-06 20:05:46 +00:00
Dave Abrahams
3ec813c71b Explicitly pass an argv to LLVM's execution engine
This commit touches many more interfaces than you might expect.  Tant pis.

Swift SVN r4618
2013-04-06 03:40:32 +00:00
Dave Abrahams
19a590617a Add a "--" option that allows arguments to be passed to scripts
Swift SVN r4565
2013-04-01 22:47:24 +00:00
Joe Groff
1a8b35d383 REPL: Support -sil-irgen.
Add a 'startElem' option to SILModule::constructSIL so that it can be used with REPL input.

Swift SVN r4519
2013-03-28 18:38:29 +00:00
Joe Groff
25e370fcce Frontend: Pass down -O level in -i mode.
'-i' code was always getting emitted at -O2 regardless of the -O flag, which enables the "standard library hack" that pulls in IR for all of swift.swift. For -i optimization is often less important than responsiveness, so allow the optimization level to be specified by a flag and default to -O0 normally.

Swift SVN r4518
2013-03-28 17:56:29 +00:00
Joe Groff
e2dd3974b7 CMake: Put Swift libraries in lib/swift.
Compiling with an -isysroot prevents the linker from considering libraries in the system /usr/lib.

Swift SVN r4322
2013-03-07 21:13:36 +00:00
Joe Groff
18df5de96a REPL: Reset colors on process exit.
Fixes <rdar://problem/13328404>.

Swift SVN r4268
2013-03-02 19:32:54 +00:00
Doug Gregor
6c647535ad REPL: automatically run replApplicationMain() the first time it becomes available.
Now, importing AppKit (or anything that depends on it) under
-repl-run-loop will set up the environment to do interactive UIs.


Swift SVN r4230
2013-02-27 22:13:44 +00:00
Joe Groff
aefdb8a480 REPL: Try to reset color when quitting or crashing
Also :dump_source on a crash so it's easier to c&p and get your context back. Fixes <rdar://problem/13306302>.

Swift SVN r4227
2013-02-27 20:05:07 +00:00
Joe Groff
c4aeffd69d REPL: Don't bold inputs after entry.
Dave didn't like it, and hopefully highlighting responses should be sufficient on its own to make REPL scripts easier to spectate.

Swift SVN r4223
2013-02-27 02:33:33 +00:00
Joe Groff
0afc1d4a62 REPL: Make :autoindent switchable.
If you're pasting blocks of prewritten code into the REPL, you don't want it to double-indent. Saying ':autoindent off' before you paste now disables the automatic indentation so you can paste preformatted code.

Swift SVN r4222
2013-02-27 02:29:39 +00:00
Joe Groff
0bdbcefef7 REPL: Fix output artifact with line continuations.
Swift SVN r4218
2013-02-27 01:38:29 +00:00
Joe Groff
021e10df6c REPL: Colorize inputs and responses.
Rerender inputs in bold after they've been entered. Colorize non-REPL output, cyan for normal responses, and green for REPL directive responses. (In my terminal setup these were the least retina-searing members of the vast and nuanced ANSI color palette.)

Swift SVN r4217
2013-02-27 01:35:36 +00:00
Joe Groff
321af9f090 Some frontend cleanup.
Package up some useful REPL context into a header-able REPLContext class. Move the response metavar index there instead of having it as a gross mutable static variable.

Swift SVN r4203
2013-02-26 00:05:00 +00:00
Joe Groff
687c61ad1b REPL: Bind top-level expressions to result vars.
If a REPL input parses to an expression, bind it to the next available variable 'r<n>', and print the result as if it were a name binding. Don't bind a variable if the expression consists of a lone DeclRef, and don't print the binding if it has void type.

Swift SVN r4201
2013-02-25 23:21:34 +00:00
Doug Gregor
1e80a25322 Automatically link against imported Clang modules in the JIT <rdar://problem/13191437>.
Swift SVN r4195
2013-02-25 18:54:47 +00:00
Dave Zarzycki
f90a57cd2f Fix implicit line continuation regression
We need to see an operator before infer an unfinished infix operator.

Swift SVN r4190
2013-02-25 04:59:35 +00:00
Dave Zarzycki
56ecce271e REPL: getwc() returns WEOF, not EOF
Swift SVN r4182
2013-02-25 02:14:13 +00:00
Joe Groff
9f755c162a REPL: Adjust some comments.
Document how we're relying on the synchronous-ness of CFMessagePortSendRequest to serialize AST access between the REPLInput and REPLEnvironment threads, and remove an inaccurate comment about EL_GETCFN.

Swift SVN r4178
2013-02-24 18:53:37 +00:00
Dave Zarzycki
17c8bbbc52 Unfinished infix expressions imply line continuation
This now works automagically:

(swift) 123 +
        456
// Int64 = 579
(swift) Int .
        max()
// Int64 = 9223372036854775807
(swift)

Swift SVN r4173
2013-02-24 02:13:43 +00:00
Dave Zarzycki
e6ea59785b Empty lines must not prematurely end the continuation prompt
Swift SVN r4172
2013-02-24 01:43:36 +00:00
Joe Groff
38a8b1f7e3 REPL: Don't call global_ctors before each entry.
The REPL was accreting global_ctors and rerunning all global initializers ever registered before every entry. Change it so that it only runs global initializers once and so that the ObjC initialization stuff that needs to happen on a per-entry basis just gets dropped directly into the main() for each entry.

Swift SVN r4154
2013-02-22 22:24:29 +00:00
Joe Groff
d78d95b861 stdlib: Add a 'replExit' hook.
In the repl, if a replExit function is defined, call it when the repl is exiting. In the stdlib, add an atREPLExit function that pushes replExit handlers onto a vector and a replExit function that invokes those handlers. In swiftAppKit, have REPLApplicationMain use atREPLExit to terminate the application when the REPL is exited.

Swift SVN r4132
2013-02-21 20:50:15 +00:00
Joe Groff
585a3b216a REPL: Add a -repl-run-loop mode.
This runs the REPL with the editline interactor in a separate thread while the main thread runs a CFRunLoop. The interactor thread then sends REPL inputs through a CFMessagePort which the main thread run loop responds to.

Swift SVN r4128
2013-02-21 18:09:57 +00:00
Joe Groff
0d9c1b970e REPL: More refactoring.
Separate the input and response code further into separate classes, so the top-level loop is just a getREPLInput/handleREPLInput loop.

Swift SVN r4125
2013-02-21 05:07:14 +00:00
Joe Groff
d1c34dcfd6 REPL: Separate the interface and response code.
Break out the code that actually puts together an editline input from the code that parses, compiles, and executes the code, with an eye toward letting the former run in a thread while the latter becomes a CFRunLoop client.

Swift SVN r4124
2013-02-21 01:49:39 +00:00
Joe Groff
babf12590c REPL: Port to editline's wchar_t interface.
This makes Unicode REPL input work. 💩

Swift SVN r4121
2013-02-20 23:43:01 +00:00
Doug Gregor
56815fd483 Add a stub Swift module for AppKit.
This (indirectly) makes "import AppKit" in the REPL dlopen() the
AppKit dylib, so one can use AppKit from the REPL.


Swift SVN r4092
2013-02-20 01:20:35 +00:00
Joe Groff
ddb7ead55c REPL: Contextual completions.
If the completion prefix has a '.' behind it, guesstimate a context expression by lexing backward through an identifier(.identifier)* dotted path, then attempt to parse and typecheck that expression to decide on a base type in which to find completions.

Swift SVN r4063
2013-02-16 20:07:50 +00:00