Commit Graph

6018 Commits

Author SHA1 Message Date
Konstantin Shcheglov 3a612c7b73 Generated front_end/testcases/inference test files from Analyzer tests.
Only *.strong.expect files are included.
The tests are marked as failing for compile/, kompile/ and outline/.
I could generate them, but I don't think that these results are
actually "expected", it'd more like the "status quo".

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

Review-Url: https://codereview.chromium.org/2846103002 .
2017-04-27 14:32:31 -07:00
Konstantin Shcheglov d91f4385c9 Wrap front-end inference tests into a reflective test.
So, they (1) can be made solo_, and (2) run in order.

R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2844353002 .
2017-04-27 14:13:41 -07:00
Sigmund Cherem 99ab24f628 Extend file-system abstraction with a couple methods, remove context.
New methods:
 - exists: I'll be using it for input validation among other things
 - lastModified: I'll be using this on some utilities to support the incremental
 API.

BUG=
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2844903002 .
2017-04-27 14:01:10 -07:00
Konstantin Shcheglov 0fe8546217 Rollback instrumentation during analysis and validate resolved ASTs instead.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2846883005 .
2017-04-27 10:30:19 -07:00
Paul Berry 748e7c8ded Extend pkg/front_end/lib/src/fasta/kernel/verifier.dart to check for UnknownType.
UnknownType should only ever appear in the type schemas used by type
inference; it should not show up in a completed program.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2843333005 .
2017-04-27 09:58:22 -07:00
Paul Berry 2d508dcc9c Add a clarifying comment explaining why UnknownType.accept() doesn't throw.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2842283002 .
2017-04-27 08:36:21 -07:00
Paul Berry 046a62a54f Remove AstFactory.field()
This method doesn't really belong in AstFactory, because it's not used
by BodyBuilder; it's used by KernelFieldBuilder, which always builds
kernel objects.  We only need to abstract the objects that are created
by BodyBuilder, since only BodyBuilder is going to have to be capable
of building analyzer ASTs.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2842273002 .
2017-04-26 13:47:59 -07:00
Konstantin Shcheglov 3f5c0be45f Add the forgotten expectations for a new inference test.
TBR

R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2841183002 .
2017-04-26 13:35:08 -07:00
Konstantin Shcheglov cf013c6469 Instrument analyzer's type analysis and run front_end inference tests.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2846463003 .
2017-04-26 13:31:10 -07:00
Paul Berry d7031ce9bf Change accessors and AstFactory to use tokens rather than file offsets.
This is a necessary prerequisite for re-using BodyBuilder to make
analyzer ASTs, since analyzer ASTs use tokens rather than offsets to
keep track of file positions.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2841863002 .
2017-04-26 13:29:42 -07:00
Konstantin Shcheglov 27b4b36b86 A couple of tweaks in ValidatingInstrumentation.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2843103002 .
2017-04-26 13:09:34 -07:00
Paul Berry 324d60d764 Add type schema elimination logic.
As defined in https://github.com/dart-lang/sdk/pull/29371/files

R=leafp@google.com

Review-Url: https://codereview.chromium.org/2837093002 .
2017-04-26 12:56:13 -07:00
Dan Rubel 3b790e5311 new TokenType and Keyword API
This adds two new methods and adapts most of the old references
to use these new API. Once all call sites have been updated,
the old API can be removed.

This is part one of https://codereview.chromium.org/2842643004/

* replace type == TokenType.KEYWORD with type.isKeyword
* change Keyword.syntax --> Keyword.lexeme

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

Review-Url: https://codereview.chromium.org/2842213003 .
2017-04-26 15:53:58 -04:00
Paul Berry 78c1cad702 Simplify BodyBuilder's Identifier class.
This class doesn't need to extend InvalidExpression as long as we make
sure that it is never seen by toValue().

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2845723002 .
2017-04-26 12:50:44 -07:00
Paul Berry d30c7e7650 Rename TypeInferrerImpl._context to _closureContext; make null outside of closures.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2839193003 .
2017-04-26 11:40:07 -07:00
Devon Carew 93401fdbaf Update IntelliJ metadata.
BUG=
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2845643002 .
2017-04-26 09:27:02 -07:00
Konstantin Shcheglov 7343bfacbd Reorder parameters in Instrumentation.record().
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2839003002 .
2017-04-25 15:06:41 -07:00
Sigmund Cherem 06189b271a loader, target, diet_listener moved
from front_end/lib/src/fasta/analyzer/
   to   analyzer/lib/src/fasta/

analyzer_compile and compile_platform_dartk moved
   from front_end/lib/src/fasta/analyzer/
   to   front_end/tool/_fasta/

front_end/src/fasta/testing/* continues to have some shared testing logic,
 - logic to compute the patched sdk is moved up one level
 - TestContext, Run, and suite.dart (which depend on analyzer) moved to pkg/front_end/test/fasta/testing/
 - only a copy of TestContext is duplicated under pkg/kernel/test/closure/.

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

Review-Url: https://codereview.chromium.org/2828583003 .
2017-04-25 13:16:14 -07:00
Kevin Millikin 9adfa8a105 Fix a pair of issues in the Dart code for the front end.
- A type needed for an annotation was not visible.
- An iterable was passed instead of a list.

BUG=
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2838983002 .
2017-04-25 21:45:28 +02:00
Kevin Millikin 385f8fb054 Read platform.dill in the VM.
1. A --platform flag is added to dart to give a path to a Kernel
   binary for the platform libraries (as produced by building the
   runtime_kernel target).

2. This binary is used for bootstrapping.  Since it contains libraries
   other then the VM's bootstrap libraries, they are also loaded.

3. The frontend does not send any library with a dart: import URI
   scheme.  Note that it does not (yet) prune the canonical name
   table, which will contain a lot of unnecessary names used for
   internal linkages in the platform libraries.

4. There is a single dependency in the platform libraries on the
   script: _getMainClosure in dart:_builtin.  This is patched after
   the script is loaded.

BUG=
R=ahe@google.com, kustermann@google.com, vegorov@google.com

Review-Url: https://codereview.chromium.org/2786083002 .
2017-04-25 20:04:25 +02:00
Paul Berry a3311858a7 Introduce initial plumbing for type promotion in fasta.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2829223007 .
2017-04-25 09:06:51 -07:00
Dan Rubel 684065855f merge PrecedenceInfo into TokenType and update all refs
* replace PrecedenceInfo *_INFO with TokenType.*
* remove outdated PrecedenceInfo tests
* delete unused precedence_info.dart

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2832403002 .
2017-04-25 08:51:52 -04:00
Paul Berry 3785385083 Make it possible to represent type schemas in the front end.
See https://github.com/dart-lang/sdk/pull/29371/files for more
information.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2839513002 .
2017-04-24 11:40:20 -07:00
Erik Corry 2fb5d08102 Spelling a
R=ahe@google.com
BUG=

Review-Url: https://codereview.chromium.org/2841543002 .
2017-04-24 14:53:51 +02:00
Erik Corry 6617737ff5 Replace 'the the' with 'the'
R=kmillikin@google.com
BUG=

Review-Url: https://codereview.chromium.org/2830353002 .
2017-04-24 08:50:37 +02:00
Dan Rubel 54d131ebd9 merge fasta.PrecedenceInfo into analyzer.TokenType
* move precedence consts into analyzer token.dart
* move PrecedenceInfo.all to TokenType.all
* replace references to PrecedenceInfo with TokenType
* merge fasta.PrecedenceInfo into analyzer.TokenType

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

Review-Url: https://codereview.chromium.org/2837473002 .
2017-04-23 09:13:24 -04:00
Dan Rubel a76255249b start merging fasta.precedence into analyzer.TokenType
* move methods and fields from PrecedenceInfo into TokenType
* extract precedence consts

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2835543002 .
2017-04-23 09:08:56 -04:00
Konstantin Shcheglov bd76de48ca Pass FileSystemState into FileTracker.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2828163006 .
2017-04-21 10:53:31 -07:00
Erik Corry 4b9bba55b4 Stoppp using trippple consonants
R=ahe@google.com
BUG=

Review-Url: https://codereview.chromium.org/2833073002 .
2017-04-21 17:50:13 +02:00
Paul Berry 925a0a5777 Split up TypeInferrer class.
This CL makes four classes:

- TypeInferrer, which is the API for type inference within a method
  body or field initializer, used by BodyBuilder.

- TypeInferrerImpl, which is the generic implementation of
  TypeInferrer.

- TypeInferenceEngine, which is the API for top level type inference
  and for creating TypeInferrers.

- TypeInferenceEngineImpl, which is the generic implementation of
  TypeInferenceEngine.

R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2830313002 .
2017-04-21 05:39:09 -07:00
Paul Berry 77d26a330c Add top level type inference logic for integer literals.
This CL hooks up enough infrastructure for doing simple top level type
inference of variables whose initializer is an int.

Additional type inference rules will be added in follow-up CLs.

R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2828253003 .
2017-04-21 04:38:18 -07:00
Paul Berry 3dbe0099a2 Prepare to publish analyzer, front_end, and kernel.
Due to the tight coupling between analyzer and front_end, they need to
be published atomically.  The last published version of kernel is old
enough that it needs to be published too.

I've bumped the versions to the following, and changed the
dependencies so that this set of versions is mutually compatible:

- analyzer: 0.30.0-alpha.3
- front_end: 0.1.0-alpha.2
- kernel: 0.2.0

(Note that kernel's version didn't need bumping since the most
recently published version of it is 0.1.0)

R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2828273003 .
2017-04-21 01:35:35 -07:00
Sigmund Cherem 4a19708532 Remove use of package:analyzer in dependency_grapher
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2834543002 .
2017-04-20 17:06:04 -07:00
Paul Berry f9189fdfe2 Make AstFactory.variableDeclaration(charOffset) a required parameter.
This prevents bugs where we forget to set the offset.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2829113002 .
2017-04-20 10:31:25 -07:00
Jacob Richman 997b4e62af Run formatter on a few frontend and kernel files that hadn't been formatted.
BUG=
R=asgerf@google.com

Review-Url: https://codereview.chromium.org/2820323005 .
2017-04-20 09:25:13 -07:00
Paul Berry e3347e03f7 Use a non-null TypeInferrer even in non-strong mode.
This is necessary because some of the TypeInferrer's roles (e.g. type
promotion and determination of the types of constants) are still
needed in non-strong mode.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2829683008 .
2017-04-20 04:11:19 -07:00
Paul Berry e8e8359cdf Add local type inference logic for integer literals.
This CL introduces Fasta's first type inference rule, and hooks it up
to all the necessary testing infrastructure.  The rule is that a local
variable whose initializer is an integer literal should have an
inferred type of int.

Only variables occurring at top level within a method are inferred (we
don't yet recurse inside sub-blocks).

Additional type inference rules will be added in follow-up CLs.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2828693003 .
2017-04-20 03:36:19 -07:00
Peter von der Ahé 9356e3cd61 Check const constructors.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2799973003 .
2017-04-20 10:55:58 +02:00
Paul Berry b5c6053deb Add explicit return types to work around #29398.
In a future CL I need to add an import to this file, and for reasons I
haven't been able to track down, doing so causes type inference
failures.  This CL works around the problem by making the affected
types explicit.

Once the bug is fixed, I hope to be able to revert this.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2833563004 .
2017-04-20 01:29:49 -07:00
Peter von der Ahé e2eee219ac Complain about incorrect this/super constructor initializers.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2800083002 .
2017-04-20 10:04:12 +02:00
Peter von der Ahé cf6b2736ec Wrap VariableDeclarations in Blocks as specified by Kernel.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2801283002 .
2017-04-20 09:31:36 +02:00
Peter von der Ahé 6bd0085ec1 Throw isn't a constant expression.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2801873008 .
2017-04-19 15:55:05 +02:00
Paul Berry a682c6a97e Introduce a testing framework for use with fasta type inference.
The framework will allow test source files to be annotated with
comments indicating where types are expected to be inferred, for
example:

    var /*@type=dart.core::int*/ x = 1;

Other features of the testing framework:

- Normally only those expectations explicitly listed will be checked.
  The special comment "/*@testedFeatures=inference*/" at the top of
  the file turns on extra checking which will cause the test to fail
  if any unexpected type inference occurs.

- Should be easy to extend to support other features, such as checking
  that the proper errors and warnings are generated at the proper
  locations.

- If the test is run with "-DupdateExpectations=true", the
  expectations will be updated in place.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2824393002 .
2017-04-19 06:54:08 -07:00
Peter von der Ahé 0ceb30a5e0 Make zero-termination optional.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2827543006 .
2017-04-19 15:29:00 +02:00
Peter von der Ahé e534a45cec Handle bad rethrows.
R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2802203002 .
2017-04-19 15:17:10 +02:00
Peter von der Ahé ba0e07846f Produce a compile-time error if there's no main method.
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2801853006 .
2017-04-19 14:28:10 +02:00
Peter von der Ahé 2d9956a93d Move kernel baseline tests to front_end.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2825063002 .
2017-04-19 10:57:58 +02:00
Paul Berry 13941eaa03 Plumb TypeInferrer through KernelExpression._inferExpression.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2827793003 .
2017-04-18 18:40:46 -07:00
Paul Berry ea0c1d8f35 Address nits from https://codereview.chromium.org/2823243002/
I thought I'd made these changes prior to landing the above CL, but I
accidentally made them to the wrong branch, so they didn't wind up
getting committed.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2821193004 .
2017-04-18 15:46:08 -07:00
P.Y. Laligand 36a7e49822 Updated build files for Fuchsia. (#29382) 2017-04-18 15:02:19 -07:00