Commit Graph

115 Commits

Author SHA1 Message Date
Asger Feldthaus fe5a26f264 [kernel] Treat an arrow body in a void method as void context.
BUG=https://github.com/dart-lang/kernel/issues/31
R=ahe@google.com

Review URL: https://chromereviews.googleplex.com/511307014 .
2016-09-29 11:08:28 +02:00
Martin Kustermann 44a70d3534 [kernel] Mixin desugaring: Clone constructors from base classes, rewrite super initializers
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/510377013 .
2016-09-27 12:19:42 +02:00
Asger Feldthaus 6fec4ee7a5 [kernel] Fix a bug in DartOptions.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/515767013 .
2016-09-23 17:51:00 +02:00
Asger Feldthaus cd60bb203f [kernel] Ensure class type parameters are not referenced from static context.
BUG=https://github.com/dart-lang/kernel/issues/16
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/510207013 .
2016-09-23 16:33:12 +02:00
Asger Feldthaus 795ce44ec7 [kernel] Refactor the frontend classes.
dartk and other command-line tools no longer rely on analyzer classes
like AnalysisContext or DartSdk, and instead use only the interface
defined in loader.dart.

The class AnalyzerLoader has been renamed to DartLoader.

The sharing of state in batch mode is now owned by loader.dart, so
dartk.dart does not deal with DartSdk and package_config.

Repository no longer has a package or SDK path. These concepts are
now specific to the Dart frontend. Consequently, loading a binary
file no longer relies on URI resolution.

The Repository class is now more clearly focused on linking symbolic
names to their IR objects, which for the time being is only
URI-to-library bindings, but should be extended to support linking
class and member references across different files and different
loaders.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/512907013 .
2016-09-23 16:11:41 +02:00
Asger Feldthaus a91cae8bb4 [kernel] Remove the ?? operator from the IR and desugar it in the frontend.
Note that this affects the binary format, since a type is no longer
stored on LogicalExpression.

R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/502297014 .
2016-09-23 12:52:00 +02:00
Asger Feldthaus e5423f6251 [kernel] Read in -D defines and pass them on to the frontend.
This also enables configuration-specific imports when using a newer
version of the analyzer (not currently on pub).

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/515727013 .
2016-09-23 12:28:33 +02:00
Asger Feldthaus 492e65b68e [kernel] Support .packages file.
BUG=https://github.com/dart-lang/kernel/issues/27
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/508267014 .
2016-09-22 14:18:18 +02:00
Martin Kustermann 99b1be4d09 [kernel] Add support for passing --url-mapping=<scheme>:<name>::<url> to dartk
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/507527013 .
2016-09-22 13:16:08 +02:00
Martin Kustermann a4a3ad3961 [kernel] Use InvalidInitializer() for initializers with compile-time errors
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/508347013 .
2016-09-22 13:05:16 +02:00
Asger Feldthaus c323d3608a [kernel] Set constructor body to an empty statement if its body was omitted.
BUG=https://github.com/dart-lang/kernel/issues/28
R=johnniwinther@google.com

Review URL: https://chromereviews.googleplex.com/512727013 .
2016-09-22 12:15:42 +02:00
Jens Johansen c6d1d01738 [kernel] Fix of saving expression in function body.
Creating a redirecting factory constructor to an abstract class
creates a throw expression directly in function.body.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/506587013 .
2016-09-21 08:26:35 +02:00
Asger Feldthaus b02cdaccf7 [kernel] Report more errors.
Include up to 100 errors in the output, and print the number
of errors that were truncated.

Also report errors from the SDK and package files.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/506077014 .
2016-09-13 13:16:05 +02:00
Asger Feldthaus 7890404af4 [kernel] Print errors in a nicer format.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/508597013 .
2016-09-13 12:41:22 +02:00
Asger Feldthaus 5711977941 [kernel] Forward scanner and strong mode errors from the analyzer.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/507827013 .
2016-09-13 12:23:51 +02:00
Asger Feldthaus 204a0f9b19 [kernel] Fix unresolved access on class or library prefix.
An unresolved `C.name` would be translate to `this.name` in non-static
contexts.  It is now translated to throw a NoSuchMethodError.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504977014 .
2016-09-09 17:47:31 +02:00
Asger Feldthaus 8ef3abbb09 [kernel] Fix initialization of type parameter bounds on mixin applications.
There was a circularity issue with type parameter bounds being copied
from other classes, while those classes we not yet fully initialized.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/499437013 .
2016-09-09 13:21:29 +02:00
Asger Feldthaus 93299997e3 [kernel] Insert dynamic when type arguments are omitted from redirecting factory.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/500317013 .

Committed: https://github.com/dart-lang/kernel/commit/9d9d61ec4649b159ed3bbe1c2a486d98e7bf07ea
2016-09-08 16:08:43 +02:00
Asger Feldthaus 9a3c54e0e9 [kernel] Revert "Insert dynamic when type arguments are omitted from redirecting factory."
This reverts commit 9d9d61ec4649b159ed3bbe1c2a486d98e7bf07ea.

BUG=

Review URL: https://chromereviews.googleplex.com/502317013 .
2016-09-08 15:35:20 +02:00
Asger Feldthaus 1316073b81 [kernel] Apply async transformation when --target=vm.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/504897014 .
2016-09-08 15:25:20 +02:00
Asger Feldthaus f7fd49e0f1 [kernel] Insert dynamic when type arguments are omitted from redirecting factory.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/500317013 .
2016-09-08 14:24:42 +02:00
Asger Feldthaus e7a10f9424 [kernel] Put the interface target on implied .call invocations.
Example from js_ast:

  class JsBuilder {
  	Node call(x) => ...
  }
  const JsBuilder js = const JsBuilder();

In codegen:
  js("#.#", ...)

Translated to kernel:
  js.call("#.#", ...) // JsBuilder::call as interface target

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/502947013 .
2016-09-07 13:37:25 +02:00
Asger Feldthaus 0613969032 [kernel] Ensure analysis options are also set on the SDK context.
The analyzer keeps a separate AnalysisContext for the SDK, and the
options we set on our own context did not match those on the SDK,
mainly causing issues for strong mode.

Also, the BatchModeState is now used to share the Dart SDK, instead of
using a single instance held in a static variable.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504827013 .
2016-09-07 13:15:58 +02:00
Asger Feldthaus 4ce54bdb64 [kernel] Decompose method invocations into getters with a call.
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/504757014 .
2016-09-06 16:22:05 +02:00
Asger Feldthaus 062cb17ec4 [kernel] Strong mode: add interface targets and resynthesis of expression types.
The interface target can now be stored on PropertyGet, PropertySet, and
MethodInvocation  If set, we know the concrete target overrides or
implements that member.

All expressions have a method getStaticType for computing its type,
which relies on interface targets for the expressions that have one.

Expressions whose type is a least upper bound have the type stored
explicitly, so the definition of least upper bounds is contained only
in the frontend.

This is a work in progress towards strong mode support, it is still
not complete.

Still missing in the frontend:
- checks from implicit downcasts
- parameter checks from covariant override or covariant generics

Implemented but not part of this CL:
- subtype tests
- IR type checker (for debugging)

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/496717014 .
2016-09-06 11:40:13 +02:00
Asger Feldthaus f40abb7e56 [kernel] Do not insert type arguments in super initializer calls
BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/502787013 .
2016-09-05 14:19:21 +02:00
Asger Feldthaus 6ac6e2fa96 [kernel] Emit an error, but don't crash, if a target-specific library is missing.
BUG=

Review URL: https://chromereviews.googleplex.com/503797013 .
2016-09-05 13:36:51 +02:00
Kevin Millikin a70332a6c0 [kernel] Add a target-specific list of extra libraries.
Some backend targets require extra libraries that are not used
explicitly by a program (e.g., the Dart VM requires its bootstrap
libraries).  Add a target-specific list of these libraries and ensure
that they are loaded when loading a program from Dart sources.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/495497014 .
2016-09-01 13:13:41 +02:00
Kevin Millikin f9fffc319f [kernel] Change the annotation Native to ExternalName.
The annotation Native from dart:_internal clashes with a class of the
same name from dart:_js_helper.  Change the one in dart:_internal to
ExternalName instead.

BUG=
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/493567015 .
2016-08-31 15:17:27 +02:00
Asger Feldthaus f1422becf5 [kernel] Canonicalize mixin applications within each library.
For example:
  class A extends Foo<int> with Bar<String> {}
  class B extends Foo<int> with Bar<double> {}

becomes:
  class Foo&Bar<S,T> = Foo<S> with Bar<T>;
  class A extends Foo&Bar<int, String> {}
  class B extends Foo&Bar<int, double> {}

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/493197013 .
2016-08-31 09:42:55 +02:00
Asger Feldthaus 760baa3b55 [kernel] Make mixin and super resolution a transformation.
This makes super calls name-based (no target) and add direct calls with
both receiver and explicit target.

Super call resolution translates the name-based super calls into direct
calls after they have been cloned into the mixin application.

For JS backends, it should suffice to clone mixed-in methods that
contain super calls, but that transformation is not part of this CL.

This also adds a --target option to dartk designating the target to
which the kernel IR should be specialized.  The new transformation
is run when --target=vm.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/486537013 .
2016-08-24 16:46:50 +02:00
Asger Feldthaus 55a08b45a6 [kernel] Fix generation of index field on enums.
Make sure the 'index' field we generate corresponds to the Element
from the analyzer's model.

As it is now, this does not cause any reproducible errors since the
Element for the 'index' field is never referenced, but this will change
as we introduce interface targets in strong mode.

BUG=
R=kasperl@google.com

Review URL: https://chromereviews.googleplex.com/497607013 .
2016-08-23 12:55:12 +02:00
Asger Feldthaus d1bc33eba9 [kernel] Fix some frontend bugs.
BUG=
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/491157013 .
2016-08-23 10:31:05 +02:00
Asger Feldthaus 551889c3fb [kernel] Remove NormalClass, MixinClass and use just Class.
We need the ability to efficiently transform a mixin application class
into a regular class, and the separation was obstructing it.  It also
simplifies the IR a bit, although it no longer enforces the invariant
that mixin applications cannot contain fields and procedures.

The binary format is unchanged, so the separation still shows up in
there.  This ensures the CL can land without any changes to the SDK.

BUG=
R=vegorov@google.com

Review URL: https://chromereviews.googleplex.com/488407013 .
2016-08-22 12:35:18 +02:00
Asger Feldthaus 64a31ebdad [kernel] Fix a type annotation.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/488427013 .
2016-08-22 10:41:41 +02:00
Paul Berry fe4c8eb032 [kernel] Update pubspec to point to analyzer 0.27.4.
And fix the resulting deprecation warning.

R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/492777014 .
2016-08-17 05:59:29 -07:00
Asger Feldthaus 8f3c6994ef [kernel] More error handling and a bunch of fixes in the frontend.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/485377014 .
2016-08-17 13:51:33 +02:00
Asger Feldthaus 95b6cce25a [kernel] Mark native functions as external and annotate with @Native.
This requires a class Native to exist in the dart:_internal library, to
be used as the annotation.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/493667013 .
2016-08-16 13:18:46 +02:00
Asger Feldthaus 4c82d6853e [kernel] Support metadata annotations on classes and members.
BUG=
R=jensj@google.com, kustermann@google.com, vegorov@google.com

Review URL: https://chromereviews.googleplex.com/481447014 .
2016-08-09 16:32:23 +02:00
Asger Feldthaus f3b8057f9e [kernel] Fix analyzer warnings and remove unused code.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/483967014 .
2016-08-05 11:33:58 +02:00
Asger Feldthaus c97036648a [kernel] Correctly translate PropertyAccess of a static class member.
This handles the case of null-aware static member access `C?.foo`, as
well as fully qualified static member access `h.C.foo`.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/476957013 .
2016-07-25 15:18:21 +02:00
Asger Feldthaus 2432655e48 [kernel] Add support for batch mode in dartk.
Also forwards errors reported by the analyzer for use
in testing.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/476727013 .
2016-07-22 17:42:32 +02:00
Asger Feldthaus f13be3e4bc [kernel] Add LocalInitializer and move super calls last in initializer lists.
LocalInitializer lets us to bind temporaries to variables in the
initializer list.  We use it to ensure the arguments to super() are
evaluated at the right time.

accessors.dart and the new file super_calls.dart have been moved into
a folder "frontend" for frontend helpers that operate on Kernel IR.

BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/457457013 .
2016-06-28 14:27:01 +02:00
Asger Feldthaus d61e67d85a [kernel] Fix a broken parent pointer and add option in dartk to check them.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/460807013 .
2016-06-28 11:15:48 +02:00
Asger Feldthaus 4a40d3f244 [kernel] Insert default super constructor calls.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/457997013 .
2016-06-28 10:59:54 +02:00
Asger Feldthaus 37d46de6a5 [kernel] Fix labeled variable declarations.
BUG=
R=kustermann@google.com

Review URL: https://chromereviews.googleplex.com/453477013 .
2016-06-27 12:23:02 +02:00
Peter von der Ahé 0e36559dd4 [kernel] Reduce dependencies on analyzer.
R=asgerf@google.com

Review URL: https://chromereviews.googleplex.com/445507013 .
2016-06-17 11:41:26 +02:00
Asger Feldthaus 638b4bfaff [kernel] Normalize DartTypes to 'dynamic' instead of 'null' when omitted.
For constructor bodies, we arbitrarily set the return type to 'void'.

Although there is hardly any legitimate use for the "return type" of
a constructor, this doesn't have any overhead and it simplifies the
restriction on FunctionNode.

BUG=
R=kmillikin@google.com

Review URL: https://chromereviews.googleplex.com/446827013 .
2016-06-06 15:01:51 +02:00
Asger Feldthaus 311c893fa3 [kernel] Avoid redundant allocations in the frontend.
Doesn't make much of a difference, but we might as well land it now.
At least it rules them out as a bottleneck.

BUG=
R=kmillikin@google.com, kustermann@google.com

Review URL: https://chromereviews.googleplex.com/439987013 .
2016-05-30 14:21:50 +02:00
Asger Feldthaus e42ad3d3f9 [kernel] Fix name of unary- method and regenerate dart2js binary used for testing
BUG=

Review URL: https://chromereviews.googleplex.com/434157013 .
2016-05-27 11:46:18 +02:00