Commit Graph

4770 Commits

Author SHA1 Message Date
Paul Berry a93aee1a08 Further integration of front end type inference into analyzer.
This CL propagates types from top level variable declarations into
analyzer ASTs.

This required adding a finishFields method to parser listeners (and a
corresponding method DietListener.listenerFinishFields which calls
it); this allows AnalyzerDietListener to thread the types through from
the BodyBuilder to the AstBuilder.  This is similar to what we were
already doing for methods.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2987503003 .
2017-07-19 23:00:52 -07:00
Sigmund Cherem 84828cff89 Random improvements in error reporting.
R=ahe@google.com

This mainly addresses comments and suggestions from
https://codereview.chromium.org/2979623002/
Review-Url: https://codereview.chromium.org/2980273002 .
2017-07-19 10:45:31 -07:00
Konstantin Shcheglov a295f782c0 Include TypeEnvironment into KernelResult.
We need it to use kernel.Expression.getStaticType().

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

Review-Url: https://codereview.chromium.org/2978333002 .
2017-07-19 09:40:33 -07:00
Sigmund Cherem 2628d75c4b Fix bots, address duplicate error reporting later.
My CL broke dartk/vm tests because I stopped reporting some errors accidentaly.
I thought I was duplicating all error messages, but turns out that recoverable
errors were only reported in the line fixed here.

This reverts to the old behavior so we can address the reporting issues
separately. Added details to: https://github.com/dart-lang/sdk/issues/30194

BUG=

Review-Url: https://codereview.chromium.org/2977423002 .
2017-07-18 19:42:28 -07:00
Sigmund Cherem 1aa139bc94 Unifying compiler context
Changes in this CL:
 - Updated CompilerContext:
    - it now contains a ProcessedOptions object

    - it no longer depends on CompilerCommandLine/CommandLine

    - it delegates to ProcessedOptions.report so all error reporting
      goes to one single place.

    - use "withContext" term instead of "withGlobalOptions" to be
      more clear about the intent

 - Changes in public API
    - added more options that correspond to flags in command-line
      fasta tools

    - default onError is different: we now use the
      command_line_reporting report, which prints and throws
      on fatal messages, but doesn't throw eagerly on all messages
      as before.

    - introduced "printMessages" option: make it easy to have
      both onError + command_line_reporting  (kernel-service.dart
      is the main use case at this time, other ideas welcome!)

    - renamed CompilationError to CompilationMessage

 - Other changes

    - set exit code is done on report, not on format
    - fixed corner cases not covered in previous CL
        - error reporting with missing-main needs to happen with
          a context
        - missing error cases when inferring .packages and input
          URIs are not file:* URIs

Ideas for follow up after this CL:
 - combine ProcessedOptions and CompilerContext into a single class
   (or extend one from the other)
 - switch onError to a stream

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2982093003 .
2017-07-18 17:02:59 -07:00
Peter von der Ahé 4565719783 Remove number from operator mismatch message.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2978903002 .
2017-07-18 14:43:11 +02:00
Peter von der Ahé 3709ff5150 Add closeBraceTokenFor and use it instead of BeginToken.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2978073002 .
2017-07-18 13:57:10 +02:00
Peter von der Ahé 3216bda008 Move parser helper classes to own files and clean them up.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2978063002 .
2017-07-18 13:02:41 +02:00
Peter von der Ahé c348f019ec Rename FunctionDeclaration to LocalFunctionDeclaration.
R=danrubel@google.com, johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2982033002 .
2017-07-18 12:35:41 +02:00
Konstantin Shcheglov 58b3421f5c Issue 30179. Infer return type of static setters to 'void'.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG= https://github.com/dart-lang/sdk/issues/30179

Review-Url: https://codereview.chromium.org/2977303002 .
2017-07-17 16:24:21 -07:00
Sigmund Cherem 8ecb50d0de Throw if there is no compiler context available
BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2980033004 .
2017-07-17 13:16:18 -07:00
Konstantin Shcheglov a9fbe224bc Add documentationComment for Class to Kernel. Parse it. Resynthesize in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977133002 .
2017-07-15 09:53:48 -07:00
Sigmund Cherem 4ad4f985af Move reify to use fasta instead of dartk
Note the suite seemed to have a lot of tests crashing in verification.

With my change I'm noting other crashes, but I haven't investigated where they are from.

Also, to run the suite, before it used to be run as:

  dart pkg/kernel/test/reify/suite.dart

Now it needs to be run as:
  DART_CONFIGURATION=ReleaseX64 out/ReleaseX64/dart pkg/kernel/test/reify/suite.dart

BUG=
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2981813002 .
2017-07-14 15:04:43 -07:00
Sigmund Cherem ebd9440b18 support resolving .packages in FE
BUG=
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2979003002 .
2017-07-14 12:54:35 -07:00
Sigmund Cherem 66b4efaa30 Disable printing in kernel-driver
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2980093002 .
2017-07-14 09:47:08 -07:00
Dan Rubel bb9ba11c6c translate more fasta error codes to analyzer error codes
R=ahe@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/2978993002 .
2017-07-14 12:31:13 -04:00
Dan Rubel f12be9d64d more fasta event cleanup and testing
* make _end(optional: false) which uncovered unbalanced begin/end pairs
* update and document top level member events
* rename handleSwitchCase to endSwitchCase to better align with beginSwitchCase
* update and document begin/endFor/endForIn events
* cleanup test listener

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

Review-Url: https://codereview.chromium.org/2980043003 .
2017-07-14 12:28:09 -04:00
Dan Rubel 14b76d6b22 cleanup fasta parser send and expression events
* remove unused beginSend
* rename endSend to handleSend

* remove unused beginThrowExpression
* remove unused beginExpression event
* rename endThrowExpression to handleThrowExpression

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

Review-Url: https://codereview.chromium.org/2976103002 .
2017-07-14 10:20:01 -04:00
Peter von der Ahé c94f8ef9ec Remove deprecated_wrapInCompileTimeError.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2983463002 .
2017-07-14 14:29:59 +02:00
Peter von der Ahé 18a41eba08 Report messages instead of just printing.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2977013002 .
2017-07-14 14:07:44 +02:00
Peter von der Ahé 5b38490530 Undeprecate buildCompileTimeError.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2975183002 .
2017-07-14 11:43:05 +02:00
Konstantin Shcheglov 00d5012906 Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt.
...instead of mixing formatting with actual changes in many CLs.

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

Review-Url: https://codereview.chromium.org/2975253002 .
2017-07-13 16:28:18 -07:00
Konstantin Shcheglov ebb3dea075 Set 'isSyntheticDefault' for default constructors.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2981783002 .
2017-07-13 14:06:11 -07:00
Paul Berry c9b42f6a41 Remove the "kompile" mode of running the front end.
This mode was needed in the early days of the front end when we were
contemplating the idea of building the analyzer AST representation of
code first, and then converting it to kernel.  Now that we build
kernel directly, it is no longer needed.

Further CLs will follow to remove code that is no longer used after
this change.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2980013002 .
2017-07-13 10:52:55 -07:00
Konstantin Shcheglov bead5672c6 Pass backend Target into Kernel driver.
Mock SDK in analyzer does not include all the internal libraries that
VM requires, and probably does not have to for analysis. So, we might
use NoneTarget to avoid requiring extra libraries and transformations.

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

Review-Url: https://codereview.chromium.org/2980813002 .
2017-07-13 09:13:37 -07:00
Paul Berry b87556e00d Start copying resolution/inference data from front end to analyzer ASTs.
This CL lays the groundwork for integrating the front end with
analyzer by creating a mechanism to copy resolution and type inference
information (produced by the front end's type inference engine) into
analyzer ASTs (produced by AstBuilder).

The general technique is to parse each function twice: once with
BodyBuilder as a listener and once with AstBuilder as a listener.  The
BodyBuilder generates a kernel representation of the function, but
this isn't used; instead, type inference and resolution information is
captured using ResolutionStorer (which is a TypeInferenceListener).
Later, this information is applied to the analyzer AST generated by
AstBuilder using ResolutionApplier (which is an analyzer AST visitor).

At the moment the intermediate data exchanged between ResolutionStorer
and ResolutionApplier is simply a list of types (one for each
subexpression, in a post-order traversal of the program syntax).  For
debugging and validation purposes, this is augmented with a list of
file offsets, so that if the ResolutionStorer and ResolutionApplier
get out of sync we can diagnose the problem easily.

In later CLs, more data will need to be exchanged between
ResolutionStorer and ResolutionApplier (e.g. a list of elements to
which identifiers are resolved).

This CL doesn't tackle the problem of translating between the kernel
and analyzer representation of types; for now we simply map each type
to `dynamic`.  This is sufficient for early development, since it is
still enough to let us verify that ResolutionStorer and
ResolutionApplier stay in sync.

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

Review-Url: https://codereview.chromium.org/2981693002 .
2017-07-13 08:55:29 -07:00
Peter von der Ahé 6dbcd67e01 Remove deprecated API from scope.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2975163002 .
2017-07-13 16:52:07 +02:00
Peter von der Ahé 8a6cf606ed Remove deprecated_memberError
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2983443003 .
2017-07-13 15:42:21 +02:00
Peter von der Ahé 579a23d8ef Remove deprecated_addError.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2982673002 .
2017-07-13 14:52:23 +02:00
Peter von der Ahé 959470b6e6 Remove deprecated_warning.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2980823002 .
2017-07-13 14:11:40 +02:00
Peter von der Ahé 17dc720681 Remove deprecated_warningNotError.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2977903002 .
2017-07-13 13:51:43 +02:00
Peter von der Ahé c894d8b62c Undeprecate IncompleteError.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2977893002 .
2017-07-13 13:09:30 +02:00
Konstantin Shcheglov e08b72cab9 Remove KernelDriver/IKG.invalidateAll().
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2975143002 .
2017-07-12 21:59:04 -07:00
Sigmund Cherem a7865761d4 Use messages for (some) public API errors
not entirely ready - looking for comments.

BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2979623002 .
2017-07-12 14:55:17 -07:00
Peter von der Ahé 83e4138cd4 Remove deprecated api from LibraryBuilder.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2977713002 .
2017-07-12 22:31:13 +02:00
Peter von der Ahé 59e9638232 Remove deprecated methods from ClassBuilder.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2977693002 .
2017-07-12 21:59:46 +02:00
Paul Berry 285a18dd23 Rename most "debug" methods in TypeInferenceListener classes to "generic".
In a future CL I'm going to start taking advantage of the fact that
these methods provide a fallback behavior when the listener doesn't
override a more specific method, so to avoid confusion I'm renaming
the methods to reflect that use case.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2981653002 .
2017-07-12 12:29:34 -07:00
Konstantin Shcheglov b985f3c000 Rename TranslateUri to UriTranslator, rename files, extract Impl.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2982593002 .
2017-07-12 11:56:14 -07:00
Konstantin Shcheglov a9a926a197 Implement IncrementalKernelGeneratorImpl using KernelDriver.
What is not done, and I'd like to do in following CLs.

1. Write documentation for KernelDriver.
2. Add separate tests for KernelDriver.

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

Review-Url: https://codereview.chromium.org/2976003002 .
2017-07-12 11:24:45 -07:00
Peter von der Ahé ca4ad3e65d Remove deprecated_addNit.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2976753002 .
2017-07-12 18:44:52 +02:00
Konstantin Shcheglov cb3a79f883 Refactorings for TranslateUri and its tests.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977703002 .
2017-07-12 09:22:17 -07:00
Peter von der Ahé 619006eac3 Sort generated messages.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2976743002 .
2017-07-12 17:43:22 +02:00
Peter von der Ahé 20ffc179b7 Remove prefixes from messages and document why.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2974203002 .
2017-07-12 17:18:05 +02:00
Peter von der Ahé de891789da Remove deprecated_internalProblem.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2974933002 .
2017-07-12 16:27:52 +02:00
Peter von der Ahé a66d0c797a Implement more message argument kinds.
R=johnniwinther@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2977653003 .
2017-07-12 15:03:53 +02:00
Peter von der Ahé 8a1600b12e Add --set-exit-code-on-problem option.
Fixes https://github.com/dart-lang/sdk/issues/30127

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2979713002 .
2017-07-12 14:29:17 +02:00
Peter von der Ahé 42bcc10aa8 Correctly pass options to CompilerCommandLine.withGlobalOptions.
See #30127.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2982443002 .
2017-07-12 12:26:04 +02:00
Konstantin Shcheglov 53d23afd23 Use precomputed uriBytes while computing cycle signature.
This makes the "perfect" incremental case (when every library has its
kernel ready in the byte store) about 5% faster.

R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2980523003 .
2017-07-11 10:37:01 -07:00
Peter von der Ahé 99d637f581 Improve parsing of function expressions.
Fixes #29937
Fixes #29978
Fixes #29979

R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2968093003 .
2017-07-11 10:35:59 +02:00
Peter von der Ahé 2baaf0be13 Rename special dart2js error codes.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2973053002 .
2017-07-11 10:00:16 +02:00