Commit Graph

26 Commits

Author SHA1 Message Date
Sean Callanan
e3d2c7c079 Handle implicit conversions in the playground
transform, so that assignments to properties of
superclasses are logged properly.

<rdar://problem/16789091>


Swift SVN r17747
2014-05-09 00:52:41 +00:00
Sean Callanan
a3a5447f14 Ignore implicit Decls when instrumenting
playgrounds.  They don't have source locations
inside them so it's not really safe to generate
log calls.

<rdar://problem/16835641>


Swift SVN r17642
2014-05-07 20:32:48 +00:00
Sean Callanan
9336c8f84f Updated the playground transform to instrument
methods of classes, structs, extensions, etc.

<rdar://problem/16806714>


Swift SVN r17556
2014-05-06 19:47:58 +00:00
Sean Callanan
904cccf77d Fixed a bug where the playground transform tried
to initialize variables using lvalues.  Instead
it now uses a LoadExpr to convert the lvalue to
an rvalue before using it as an initializer.

<rdar://problem/16812526>


Swift SVN r17553
2014-05-06 17:36:09 +00:00
Doug Gregor
9cfb1b5ca4 Keep track of the locations of the element names in a TupleExpr.
As part of this, use tail allocation to reduce the memory footprint of
TupleExprs. Use factory methods to make it easier to construct.

I'll be using this information in a follow-on patch. SourceKit
probably wants it as well.


Swift SVN r17129
2014-05-01 00:16:36 +00:00
Sean Callanan
2d689365c0 Modified the playground transform to fix two
problems related to scopes:

  - First, the return value was being printed
    after the relevant scope exits.  I switched
    the order.

  - Second, two "global" scopes were being
    emitted -- one for the wrapper function,
    and one for the wrapper "if" statement.  We
    only need one, so I added necessary gating.

<rdar://problem/16765632>


Swift SVN r17122
2014-04-30 23:20:03 +00:00
Sean Callanan
baded9a328 Modified the playground transform to treat assignments
to properties of objects as mutations of the underlying
object.  This means that we report the new state of the
object rather than reporting the value of what was
assigned to the property.

<rdar://problem/16688167>


Swift SVN r17065
2014-04-30 02:24:39 +00:00
Sean Callanan
57a432eec4 Changed the playground transform to report the end
of the final token in each source range rather than
its beginning.  This means we report much better
character ranges.

<rdar://problem/16603092>


Swift SVN r17063
2014-04-30 01:32:23 +00:00
Sean Callanan
f7e6c67413 Modifying the playround transform to support logging
of statements like "x += y".  This involved two changes:

 - Where we previously only treated CallExprs as function
   calls, now we instead look at ApplyExprs.  This covers
   cases like this += call, which is actually a BinaryExpr.

 - For all such Exprs, if there is exactly one inout
   argument and the Expr returns void, log that argument.

<rdar://problem/16609821>


Swift SVN r17046
2014-04-29 22:10:13 +00:00
Sean Callanan
54eb58bbd8 Modified the playground transform to report the
name of the affected variable when appropriate
(i.e., for declarations, mutations, and
assignments).

Also removed an unused function.

<rdar://problem/16583133>


Swift SVN r17006
2014-04-29 00:48:10 +00:00
Sean Callanan
ed02db7d5d Fixed a bug where the playground transform was
generating typeless assignments, which the
type checker hates.

<rdar://problem/16674964>


Swift SVN r16633
2014-04-21 23:23:38 +00:00
Chris Lattner
84d360bbb9 remove two dead functions.
Swift SVN r16573
2014-04-20 00:22:15 +00:00
Sean Callanan
2c3e86bfb6 Updated the PlaygroundTransform to no longer
require that the modules it uses are present.
LLDB now explicitly forward-declares the builtins
that transformed code requires, so we can just
use them.

This makes the playground transform less error
prone, and means that if the functions really are
missing we'll get a nice and obvious link error
rather than a hard-to-diagnose error where the
playground transform quietly refuses to do
anything.

<rdar://problem/16599338>


Swift SVN r16563
2014-04-19 03:11:04 +00:00
Sean Callanan
1fe0b3dd2e Modified the playground transform to instrument
closure bodies wherever we find them.

<rdar://problem/16647809>


Swift SVN r16480
2014-04-17 23:57:24 +00:00
Sean Callanan
f35acb6dba Updated the playground transform to handle switch
statments.

<rdar://problem/16628109>


Swift SVN r16461
2014-04-17 19:21:28 +00:00
Sean Callanan
23e6fccf4d Only log variable declarations that have
initializations, to avoid errors about use
before initialization.

<rdar://problem/16587570>


Swift SVN r16237
2014-04-11 23:41:40 +00:00
Sean Callanan
630ce68ba9 Completed my changes to the playground transform
to support brace entry/exit.  We now maintain a
stack of brace statements we know we're inside.
The elements of this stack are colored:

- If we encounter a loop, while we are walking
  that loop we color its container to indicate
  that "break" and "continue" exit all braces
  up until the container of the loop.

- If we encounter a function, while we are
  walking that function we color its container
  to indicate that "return" exits all braces
  up until the container of the function.

Since at this point every BraceStmt is modified,
we don't need the "Modified" flag and I excised
it.


Swift SVN r16230
2014-04-11 21:48:39 +00:00
Sean Callanan
bf0a540b4e Updated the playground transform to log brace
entries and exits.

  - Added support to buildLoggerCall for different
    logger functions;

  - Added support to buildLoggerCall to handle
    source locations that fall outside the
    user-entered expression text; and

  - Added the necessary logging functions to the
    functions we check for before adding our
    instrumentation.

This involved some minor refactoring.  I still have
to add a stack of scopes that I can pop out of when
I see a break, continue, or return.


Swift SVN r16197
2014-04-11 03:28:08 +00:00
Sean Callanan
82ace2413d Fixed a problem in the playground instrumenter that
caused direct logging of expression to fail type
check sometimes.  We introduce an intermediate
variable, so instead of (pseudocode)

  3 -> log(3)

we have

  3 -> var tmp = 3; log(tmp)


Swift SVN r16189
2014-04-11 00:59:36 +00:00
Sean Callanan
b45bbde700 Fixed a bug in the playground transform, which
caused it not to emit log calls for mutations of
Objective-C objects.


Swift SVN r16146
2014-04-10 01:27:28 +00:00
Sean Callanan
00d6c54241 Updated the playground transform:
- Fixed a bug where it did not instrument a "for-in" loop.
    
  - Made sure nested function declarations' bodies are
    instrumented.
   
  - Added instrumentation for return statements.
  
<rdar://problem/16516131>


Swift SVN r15960
2014-04-04 22:24:53 +00:00
Sean Callanan
1aa676fe92 Updated the playground transform:
- Don't be so sensitive about how many of the
   required functions there are; and

 - Don't include the "header" parameter to
   playground_log any more; it's not needed.


Swift SVN r15755
2014-04-01 22:39:46 +00:00
Sean Callanan
69111164a3 Updated the playground transform to handle
loop constructs and mutations of variables.

We also try to ignore expressions that return
empty tuples, because this causes type-checking
failures.


Swift SVN r15568
2014-03-28 01:39:16 +00:00
Sean Callanan
4bb2d109b5 Updated the playground transform to handle
variable declarations, do a better job with
assignments, and handle bare expressions.  Also
adjusted to the new playground logger API.


Swift SVN r15313
2014-03-21 02:01:37 +00:00
Sean Callanan
8eb64b73c8 Modified the playground transform to
- use the most recent prototype for the logger
   function (playground_log), and

 - send the output of the logger function to
   DVTSendPlaygroundLogDataToHost.


Swift SVN r14892
2014-03-10 23:45:08 +00:00
Sean Callanan
3b95376949 Added a new AST transformation pass called the
"Playground Transform."  This is an
instrumentation pass that adds calls to a
function called playground_log at locations of
interest.  Roughly speaking, these locations are

- Initialization of variables
- Modification of variables
- Expressions returning values
- Application of mutating methods on objects

The playground transform currently only finds
modifications of variables, but the intent is to
make all of these cases work.

It is enabled by a frontend option, and can
also be invoked by calling

swift::performPlaygroundTransform(SF)

which is the way LLDB, its main client, will
use it.

The frontend option is intended for testing,
and indeed I will add tests for this
transformation in the coming week as I bring
more functionality online.


Swift SVN r14801
2014-03-07 22:59:19 +00:00