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
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
'-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
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
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
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
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
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
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
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
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
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
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
Implement a 'lookupVisibleDecls' API similar to Clang's that replicates the UnqualifiedLookup logic for walking through a given scope looking for decls. Use it to populate the completion list in the repl.
Still to be done: Clang module lookup via Clang's lookupVisibleDecls, and context deduction from dotted path expressions.
Swift SVN r4056
Actually indent the source lines we receive from editline when we store them to the buffer so that :dump_source looks right. Fixes <rdar://problem/13171743>.
Swift SVN r3983
Set up a Completion object to extract context and a prefix string from a partial input and then track the state of the user's interaction with the completion system. Wire up tab in editline to trigger completion when pressed. It still needs to be hooked up to name lookup; right now it just looks in a fixed list of completion strings.
Swift SVN r3981
In theory this would colorize the prompt, but editline is broken and doesn't emit literal-mode characters in sequence with cooked characters.
Swift SVN r3973
When an Objective-C class is first used, the runtime will "realize" it,
i.e. create the rw-data and set a couple flags. With pure Swift classes,
though, it's possible to create an instance and then send a message to it
without ever sending a message to the class, in which case the runtime will
try to realize the /instance/ and mess everything up.
This patch "fixes" that by sending the +load message to all Swift classes,
to make sure they get realized before being used. This is a very
unfortunate cost in startup time but will be necessary for id-compatibility.
I will admit that I'm not sure why this is necessary for compiled classes.
I would have expected the object file to contain the necessary information
for the runtime to realize the classes in it by default. But perhaps
classes aren't realized until their first class message even in statically-
compiled code.
<rdar://problem/13154445>
Swift SVN r3951
This allows you to print imported structs that were defined as 'typedef struct foo {} foo;', for which the original decl is otherwise inaccessible:
swift> :print_decl NSFastEnumerationState
typealias NSFastEnumerationState = NSFastEnumerationState
struct NSFastEnumerationState {
...
}
Swift SVN r3922
The lexer now models tuples, patterns, subscripting, function calls, and
field access robustly. The output tokens are now better named as well:
l_paren and l_paren_call, and l_square and l_square_subscript. It
should be much more clear now which one to use. Also, the use of
l_paren or l_square will not arbitrarily flip flop if the token before
it is a keyword or if the token before it was the trailing ']' of an
attribute list. Similarly, tuples will always cause the lexer to produce
l_paren, regardless if the user typed '((x,y))' or '( (x,y))'.
When we someday add array literals, the right token is now naturally
falling out of the lexer.
Swift SVN r3840