Commit Graph

6018 Commits

Author SHA1 Message Date
Peter von der Ahé fd9716fa95 Various semantic checks on formal parameters.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2926953004 .
2017-06-10 10:10:07 +02:00
Paul Berry 6b65fc22f7 Annotate targets of implicit this property gets/sets in inference tests.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2933663002 .
2017-06-09 17:41:13 -07:00
Paul Berry 8f5bcddc31 Implement type inference for assignments to a static variable.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2933643002 .
2017-06-09 17:36:20 -07:00
Paul Berry ef94f715a9 Add type inference for assignment to local variables.
Also fix some upwards inference cases for assignment to index
expressions.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2928033005 .
2017-06-09 15:13:14 -07:00
Konstantin Shcheglov c2f18fc930 Implement promised watch behaviour.
1. There are no reasons to use different watch function between
   computeDelta() invocations, so I moved it to the constructor.

2. We need to call it, and await, before reading files, not after.

3. Added tests.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2931183003 .
2017-06-09 15:04:30 -07:00
Konstantin Shcheglov 6f4bba5f03 Compute API signatures of files.
Note, that in non-incemental case this change has negative performance
implications - compilation is 10% slower. Computing MD5 hashes is very
expensive.

In real life scenarios we will cache API signatures and URIs as
part of unlinked information for each file.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2926883003 .
2017-06-09 11:41:29 -07:00
Paul Berry 4abff2291b Rework type inference of assignments to index expressions.
The approach from the las CL (try to figure out the structure of the
assignment expression from the desugared result) turned out to be
unsustainably complex.  In this version we keep track of the structure
while doing the desugaring, and then store the result in a wrapper
object the kernel AST.  The wrapper object defers visit methods to the
object it wraps, so when the kernel objects are serialized to disk,
the wrapper disappears.

I also took the liberty of removing the code that inserts types
into the temporary variables and conditional expressions
introduced by desugaring.  I will add this in a later CL if it
proves to be necessary.

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2927013004 .
2017-06-09 10:48:07 -07:00
Peter von der Ahé d9f14d6a2b Add --sdk option.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2929783002 .
2017-06-09 15:52:14 +02:00
Johnni Winther 2042128817 Include uriToSource from dill-based libraries in output.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2929103002 .
2017-06-09 14:11:43 +02:00
Dmitry Stefantsov aa8ca9244a Add getTarget method to CompilerCommandLine
The method is used to create an instance of a backend target class.
CompilerCommandLine already has the necessary information for this ("target"
name string and "strongMode" flag).  Additionally, a backed target instance is
now not created in fasta.dart/parseScriptInFileSystem, but should be passed at
the call site.

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2932513003 .
2017-06-09 11:04:44 +02:00
Konstantin Shcheglov cf59b1a0f9 Remove ClassHierarchy factory constructor.
KernelTarget already uses IncrementalClassHierarchy, and other clients
either need ClosedWorldClassHierarchy, so should explicitly create it,
or don't care, and can be switched to IncrementalClassHierarchy.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2930973002 .
2017-06-08 18:42:22 -07:00
Dan Rubel 56402976cd more fixes for fasta analyzer integration
* fix scanner adapter setSourceStart
* fix fasta token copy() methods
* replace "is TokenWithComment" with "?.preceedingComments != null"
* update scanner test

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2928773003 .
2017-06-08 18:02:09 -04:00
Paul Berry 029771d746 Add type inference for complex assignments whose LHS is an index expression.
In later CLs I will expand on this code to handle other kinds of
complex assignments.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2926763003 .
2017-06-08 09:25:24 -07:00
Peter von der Ahé 001ac97389 Implement initializer asserts.
Closes https://github.com/dart-lang/sdk/issues/29762

R=kasperl@google.com

Review-Url: https://codereview.chromium.org/2930673002 .
2017-06-08 13:46:26 +02:00
Sigmund Cherem e551bef8ba add check of preconditions in run step.
BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2914773003 .
2017-06-07 15:45:55 -07:00
Sigmund Cherem 6e8155ae6f Follow up improvement for checking dart:_builtin
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2915153002 .
2017-06-07 15:38:18 -07:00
Sigmund Cherem cb5f3842c4 Skip directly to the last library to set the entry point and check importUri
instead of fileUri.

On some scenarios fileUri is relative and entryUri was absolute, but importUri
should match for the entry library.

BUG=
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2926933002 .
2017-06-07 14:50:01 -07:00
Sigmund Cherem aecfab68aa Add an incremental reloader example and a utility tool to trigger a reload by
hand.

The example includes:
 - an interactive UI that lets you trigger reloads without typing commands
 - a wrapper of the incremental kernel generator that invalidates files based on
 modification time stamps

BUG=
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2928483005 .
2017-06-07 13:44:56 -07:00
Sigmund Cherem ebdb0af64f Add integration test: hot reload + incremental compiler
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2925953002 .
2017-06-07 12:47:27 -07:00
Konstantin Shcheglov c510737b17 Make a copy of files to invalidate to avoid concurrent modifications.
In contrast to Analysis Driver, in Kernel Driver FileState.refresh()
is asynchronous, so we might (and actually do) get concurrent watch
events that update the set of invalidate files.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2924943005 .
2017-06-07 11:10:50 -07:00
Konstantin Shcheglov 400c7a0cb5 Set main procedure for Program.
Why is it called main _method_ when it is actually Procedure?

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2931603003 .
2017-06-07 10:59:32 -07:00
Konstantin Shcheglov 710af5af38 Measure time spent building graph of files.
It's about 1000 ms for analyzer_cli, which I use for benchmarking.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2932463002 .
2017-06-07 10:26:09 -07:00
Paul Berry 5c3dd4b11b Change MethodInvocation.interfaceTarget from a Procedure to a Member.
It's possible for the interface target to be a field, e.g.:

    typedef void F();
    class C {
      F f;
    }
    void g(C c) {
      c.f(); // Interface target is C::f
    }

Also, this CL fixes MethodInvocation.getStaticType() in the case where
the interface target is a getter.

R=dmitryas@google.com, kmillikin@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2923653003 .
2017-06-07 09:20:53 -07:00
Konstantin Shcheglov c569a4a8b8 Compute all canonical names only for libraries being serialized.
This makes compilation with Kernel Driver about 20% faster than Fasta,
about 5.8 seconds using Kernel Driver vs. 7.2 seconds using Fasta. Note
that this is initial compilation, i.e. nothing read from the cache yet.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2927463003 .
2017-06-07 08:50:04 -07:00
Dan Rubel b0374f214c update analyzer parser tests for fasta scanner
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2930453002 .
2017-06-07 11:05:44 -04:00
Peter von der Ahé c4a8b146e0 Semantic checks on switch cases and fall-through errors.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2926533004 .
2017-06-07 11:26:34 +02:00
Peter von der Ahé d6a766bb14 Improve NSM handling.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2927613002 .
2017-06-07 09:28:13 +02:00
Paul Berry b18c325f68 Add int.toString() to analyzer mock SDK.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2922383003 .
2017-06-06 13:35:36 -07:00
Paul Berry 49110ba0d6 Fix implementation of fold() in analyzer's mock SDK.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2924853003 .
2017-06-06 13:23:45 -07:00
Paul Berry 7ab22d7ad2 Properly flatten FutureOr types when inferring the type of an async method.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2923733004 .
2017-06-06 13:13:08 -07:00
Paul Berry f7f9d1766f Fix corner cases of type inference with implicit references to .call.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2928613003 .
2017-06-06 13:00:26 -07:00
Konstantin Shcheglov a0fb4d9aef Replace ClosedWorldClassHierarchy with IncrementalClassHierarchy in SourceLoader.
This does not cause any measurable performance changes for Fasta.

This speeds up initial compilation using Kernel Driver from 16 seconds
to about 7.6 seconds. Just using Fasta takes 7 seconds, so Kernel
Driver is just about 10% slower now.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2927523002 .
2017-06-06 12:38:23 -07:00
Paul Berry 32e78868bd Record method invocation targets that are not procedures.
We don't yet store the targets in the kernel representation, since
kernel currently requires method invocation targets to be procedures
(see https://codereview.chromium.org/2923653003/).  But we record the
target that we *would* store in the kernel to instrumentation so that
we can pass tests.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2920223008 .
2017-06-06 12:27:34 -07:00
Peter von der Ahé 470127ae46 Setup correct scope for initializers and complain about fields initialized more than once.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2916333002 .
2017-06-06 19:35:35 +02:00
Paul Berry 47d50e51a3 Add type inference for this expressions.
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2925603002 .
2017-06-06 09:54:19 -07:00
Peter von der Ahé 7df768af0d Restore invariant that stack is empty in parseFunctionBody.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2914373002 .
2017-06-06 16:58:31 +02:00
Dmitry Stefantsov 09e755196a Pass a Target instance to DillTarget instead of its name
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2924833002 .
2017-06-06 16:03:49 +02:00
Dan Rubel c36936f37f translate remaining fasta scanner error codes
This updates the fasta scanner to translate the remaining
previously untranslated error codes so that they will be seen
by the analyzer when the fasta scanner is used by analyzer.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2923113002 .
2017-06-06 09:08:13 -04:00
Paul Berry b5883633f7 Do not annotate type parameters of instantiated function types.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2925693002 .
2017-06-05 13:26:12 -07:00
Paul Berry 2513c2b93f Adjust expectations for parameterized closures to match front_end behavior.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2925583003 .
2017-06-05 12:51:37 -07:00
Paul Berry 2162b2da9b Improve annotation of type variables in type inference tests.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2918373003 .
2017-06-05 11:47:07 -07:00
Paul Berry 3285dcf039 Remove type parameters from type promotion classes.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2923613002 .
2017-06-05 11:42:10 -07:00
Dan Rubel 32677b631f option to enable fasta scanner
* add cmdline option so that analyzer will use the fasta scanner
* refactor handling of unterminated strings

Use -DuseFastaScanner=true to use the fasta scanner
rather than the analyzer scanner

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2919163002 .
2017-06-05 14:13:08 -04:00
Paul Berry 416a860de5 Mark some more type inference tests as passing.
These tests were already working--they just needed expectations files
(and in one case, a `main` method).

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2926433002 .
2017-06-05 10:07:27 -07:00
Dan Rubel c4449efa33 improve handling of missing interpolation identifier
When the fasta scanner finds a STRING_INTERPOLATION_IDENTIFIER token '$'
without an identifier, it now inserts a synthetic identifier

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2922563002 .
2017-06-02 15:16:44 -04:00
Dan Rubel 5b6d7653fe fix unterminated interpolation expression handling
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2914213003 .
2017-06-02 13:47:08 -04:00
Paul Berry 506389a744 Remove an unnecessary TODO from PropertyGet type inference.
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2921913002 .
2017-06-02 08:57:48 -07:00
Dan Rubel b61f9f2343 improve fasta unterminated string recovery
This updates the fasta scanner
to append synthetic closing quotes to unterminated strings.

Rework of https://codereview.chromium.org/2912693002/

R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2915093002 .
2017-06-02 11:51:11 -04:00
Dmitry Stefantsov 1e2f06f8da Reapply "Use backend targets to run Kernel transformations in Fasta"
This reverts commit 0b424ca5d2

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2919003003 .
2017-06-02 16:10:28 +02:00
Peter von der Ahé a79a59d19c Improve position information.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2915123002 .
2017-06-02 15:14:53 +02:00