Just to be clear what we're talking about here.  lldb has an expression parser 
as one of its general features.  That expression parser can run in two modes.  
In one, the expression parser emulates "code run in the context of the 
currently selected frame." This is the expression parser invoked with no 
special options.  In the other it emulates code typed into a main swift file 
(albeit incrementally evaluated) - use "expr --repl" for this mode.  In this 
mode the expressions can see other entities defined in the REPL, and you can 
load swift modules into to REPL.  But it doesn't have access to local 
variables, etc.

So if you are trying to use the expression evaluator alongside a program you 
are debugging, then you want the basic expression evaluator, not the REPL.  If 
you want to use the expression evaluator as a place to just try out code ab 
initio, you want "expr --repl".

The overall "lldb --repl" which is pretty much what the "swift" command with no 
arguments does, also starts up a trivial target app so we'll have something 
into which to inject code.

There are also SB API's to access both modes of expression evaluation.  For 
instance, you can evaluate a single expression in REPL mode using the 
SBExpressionEvaluationOptions SetREPLEnabled for this purpose.  You would use 
these in SBTarget::EvaluateExpression or SBFrame::EvaluateExpression.

The other part of the REPL is all the input magic it does to handle multi-line 
editing, etc.  That code as written relies on cooperation between the IOHandler 
classes that deal with input and the overall lldb driver program, and isn't 
quite a cleanly separated as it should be.  It is our intention to make the 
IOHandler code more easily useable by other external clients, but that work is 
still on the drawing board.  In the mean time, you would just gather user input 
and feed it to the expression parser with the appropriate options.

Jim

> On Dec 7, 2015, at 2:16 PM, Gage Morgan via swift-lldb-dev 
> <[email protected]> wrote:
> 
> VSCode is Microsoft's open source IDE. I'd like to include a window that uses 
> REPL to analyze the code and display the effects on the window right next to 
> it. 
> 
> Sent from Outlook
> 
> 
> 
> 
> On Mon, Dec 7, 2015 at 1:12 PM -0800, "Todd Fiala" <[email protected]> 
> wrote:
> 
> 
> 
> On Mon, Dec 7, 2015 at 1:04 PM, Gage Morgan via swift-lldb-dev 
> <[email protected]> wrote:
> So would it be possible to develop a Playground-like debugger using Gtk+, 
> Swift, and VSCode using REPL?
> 
> To the extent that you want to look at, analyze, and even borrow some (or 
> all) of the code in Swift LLDB and Swift-proper to do so, nothing in the 
> swift.org and llvm.org licenses would prevent you from doing so.  They are 
> permissive licenses.  They just require attribution (see the licenses for 
> details).
> 
> I know nothing about VSCode, so that may have its own set of licensing 
> requirements.  You would need to investigate that independently.
>  
> 
> Sent from Outlook
> 
> 
> 
> 
> On Mon, Dec 7, 2015 at 10:17 AM -0800, "Todd Fiala" <[email protected]> wrote:
> 
> 
>> On Dec 5, 2015, at 12:25 PM, Gage Morgan via swift-lldb-dev 
>> <[email protected]> wrote:
>> 
>> As your question is similar to the one I have, does Apple explicitly say 
>> what we can and cannot do with REPL on Linux?
>> 
> 
> Hi Gage,
> 
> Great question!  Swift.org was setup to encourage collaboration and expansion 
> of the Swift ecosystem, both in terms of platform and feature set.  Community 
> contributions to expand usage of the REPL in new and novel ways is 
> encouraged, whether it be to support a new platform, a new windowing 
> mechanism or to incorporate in a program as an extension language.  Apple is 
> not attempting to limit the scope of community contributions; rather, we’re 
> explicitly encouraging it by open sourcing Swift.
> 
> You are welcome to take any part of the REPL and modify and/or incorporate 
> into your program.  The swift.org and llvm.org licenses just ask that you 
> attribute the code borrowed (per their licenses) in your product.  Go forth 
> and make great things :-)
> 
> Sincerely,
> Todd Fiala
> 
> 
>> Sent from Outlook
>> 
>>  _______________________________________________
>> swift-lldb-dev mailing list
>> [email protected]
>> https://lists.swift.org/mailman/listinfo/swift-lldb-dev
> 
> 
> 
> _______________________________________________
> swift-lldb-dev mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-lldb-dev
> 
> 
> 
> 
> -- 
> -Todd
> 
> _______________________________________________
> swift-lldb-dev mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-lldb-dev

_______________________________________________
swift-lldb-dev mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-lldb-dev

Reply via email to