Also this removes the workaround for dart:html that used a RegExp to
attempt to match inline-JS code that might trigger the problem.
Change-Id: I74b447928aaeaca43b3a9241d42526c284dbeffa
Reviewed-on: https://dart-review.googlesource.com/55504
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
This builds on the VM's support for constants, and brings dartdevk to
parity with dartdevc. Also, constants are computed with arithmetic
operations that match runtime behavior (JS numbers).
Constants are limited in some cases right now: when building outline
kernel files (via pkg/dev_compiler/tool/build_pkgs.dart), constant field
initializers are not preserved, and this fact is not recorded, making
these fields appear to be implicitly null. dartdevk will recognize this
and avoid inlining the constant in these cases.
Change-Id: I5e6d95ccc32799da3bec1667ed16078a1a87d0bd
Reviewed-on: https://dart-review.googlesource.com/53121
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Most notably this fixes mixins, but a few others issues were discovered
as well. Fixes#32428.
This gets dartdevk closer to producing a valid Dart SDK file
Change-Id: I2973baef279d6b71ed29b97bec758b2d3209c275
Reviewed-on: https://dart-review.googlesource.com/51760
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
It's possible for `dart.fn` (tearoff) to be called after `dart.lazyFn`,
so lazyFn needs to support a setter.
Change-Id: Iaba1a1d6145d94501c77de6a6a2c107eac2d92d7
Reviewed-on: https://dart-review.googlesource.com/51441
Reviewed-by: Vijay Menon <vsm@google.com>
Also removes unsafe-force-compile for DDC's selfhost during snapshot
build, and fixes DDK's snapshot to train by selfhosting.
This does not enable preview-dart-2 for DDC/DDK's snapshots or on
the buildbots yet.
Change-Id: Id0b395eb67677d0e69dc5e827536a9039bc95816
Reviewed-on: https://dart-review.googlesource.com/51206
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
- changes top-level/static method tearoffs to work similar to instance
method tearoffs (attach typeinfo at the tearoff location).
- changes getters/setter signatures to a more compact representation.
- fixes incorrect reification of tearoffs in DDC Kernel backend,
causing a couple of tests to pass after the changes.
- module startup should also be faster, because we avoid using
`defineLazyProperty` for signatures.
Change-Id: I9d1705adcd5101a99f0599120cb927396eae778a
Reviewed-on: https://dart-review.googlesource.com/48455
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
When enclosingElement is `null` we fail to find the library. There are
several places in the compiler that depend on having a library available
for resolved elements.
Change-Id: I2746110d8caed97733c73e89e6baef3e96882563
Reviewed-on: https://dart-review.googlesource.com/49544
Reviewed-by: Vijay Menon <vsm@google.com>
This works around broken FunctionTypeImpl.== in Analyzer. Also
makes DDK's type naming heuristic more consistent with DDC.
Change-Id: I09527fad681c3fdc6c66654e572e9b03c57491bd
Reviewed-on: https://dart-review.googlesource.com/37120
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
This disables most runtime features of dart:isolate, similar to dart:io.
For now, this supports `new ReceivePort()` and `ReceivePort.close` as
those are used by async tests to keep the Dart VM alive. Those are
no-ops in DDC. Also removes most of dart:_isolate_helper, except for
the JS API that's used to bootstrap DDC `main()`.
Change-Id: I84eab6cd39d05a70a6afe982e952076ddaaa8c0f
Reviewed-on: https://dart-review.googlesource.com/45754
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Translate assert statements in async functions. The translation of
the condition subexpression can produce a sequence of statements that
have been hoisted out of it. These need to be guarded so they are
executed only when asserts are enabled.
For this purpose, we introduce an AssertBlock. The semantics of the
assert block:
assert { s0; ...; sn; }
is the same as:
if (assertsEnabled) { s0; ...; sn; }
where assertsEnabled is a more primitive nullary expression that is
true iff. assertions are enabled. We chose not to encode this using a
construct like assertsEnabled because (1) we would have to support it
appearing as an arbitrary expression which we don't currently need
and (2) it requires deeper pattern matching to detect and skip the
guarded code when desired.
The translation is more complicated because if there is a message
subexpression in an assert, it is conditionally evaluated only if the
assert's condition is false.
Fixes https://github.com/dart-lang/sdk/issues/28498
Change-Id: I0912a57104ede3160533e49f65b6fb79b76f1500
Reviewed-on: https://dart-review.googlesource.com/46442
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This bug prevented various DDC features from working correctly at
runtime, such as tearoffs, dynamic call checking, generic methods, and
parameter type checks.
Change-Id: I02cd27abbcb1d5f42b9d4ac504c7dd8bc80c866a
Reviewed-on: https://dart-review.googlesource.com/45960
Reviewed-by: Vijay Menon <vsm@google.com>
There are a few bug fixes here as well. Most notably, `.name.name`
instead of `.name` in DDK's analysis of virtual accessors. DDC/K's
handling of spread arguments in JS interop was also fairly broken
(it was generating a RestParameter instead of Spread). There's
also a lot of cleanup in js_ast as well, to make it a bit more
type safe.
Change-Id: Ia5333179e6dd0a62f20ce64a2b2b8bedf2ed7c49
Reviewed-on: https://dart-review.googlesource.com/44700
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
We use renamable variables for Dart libraries, this ensures we still
export it with the correct name.
Change-Id: I96dc161e33d265c0ffbd07f8d642629504dffe62
Reviewed-on: https://dart-review.googlesource.com/42892
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
This generates string.length instead of string[dartx.length]. Will
do same kernel side if this looks good.
Change-Id: I1fed3ca3febfa441ba36a0be34d06ab9e2e103c8
Reviewed-on: https://dart-review.googlesource.com/44280
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Jenny Messerly <jmesserly@google.com>
We were avoiding it in most cases, but a few slipped in.
Also refactors a few `uri.toString() == value` to test the scheme and
path, avoiding the expensive `Uri.toString()` call.
Change-Id: I7500a1fa9139b0cc0f2d5bd6d899f6563ec402b8
Reviewed-on: https://dart-review.googlesource.com/42463
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
For example, hover now works on `async` in `async.scheduleMicrotask`:
import 'dart:async' as async;
main() {
async.scheduleMicrotask(() { print('hi'); });
}
This does not change the import line or types, as neither of those
currently supports hover.
Change-Id: I4d9d61fb4e67ebda02cc6c1ce982b35b31d799bc
Reviewed-on: https://dart-review.googlesource.com/42086
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
We already do this in most cases when we have a constructor initializer
and the field initializer is side effect free (e.g. implicit null or a
literal). But `this.` fields were not recognized as being initialized
explicitly by the constructor.
This is already working in DDC+Kernel (because `this.` parameters are
desugared).
Change-Id: I2af1a71681451adf00c1807b2c41dad874a9465a
Reviewed-on: https://dart-review.googlesource.com/41961
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
This change improves DDC/DDK source maps:
- fix Analyzer backend step locations to pass all of the tests
Kernel was passing. Also improves breakpoints and code coverage.
- fix Analyzer backend to mark hover spans where possible, such as
fields, parameters, locals, `this`, properties, methods, etc.
- refactor DDC/DDK backends to emit source locations, rather than
pointers to Analyzer/Kernel tree nodes.
- unify/simplify source_map_printer between Analyzer/Kernel backends.
- source_map_printer understands JS expression nesting, marking the
innermost JS expression offset corresponding to a given Dart offset.
This preserves hover tooltips, even for expressions with implicit
coercions (e.g. `dart.test(x)`)
- source_map_printer understands that JS end-of-function markings need
to be before the closing brace.
- merge _visitAndMarkExpression and _visitExpression to simplify
Analyzer & Kernel backends.
- fix test expectations where the column location was too specific.
- adds a message to the stepping test runner to help future debugging.
- removes optional destructuring support from Analyzer backend. This
was unused/untested and added complexity. Instead we should decide
if/when to fully switch to destructuring, and then do so.
Change-Id: Ic47b4e21447fffc8fb1809b7bf8ffceeeb61b43e
Reviewed-on: https://dart-review.googlesource.com/42028
Reviewed-by: Vijay Menon <vsm@google.com>
This gets DDC and DDK to handle the block body of functions/methods in a
similar way, eliminating it from the JS if it is not necessary, and fixes
a bug in DDC for cases where we do need to emit a nested block scope.
Change-Id: I37d3d69bfcf9b1204385cca7785601fb7d6edfc3
Reviewed-on: https://dart-review.googlesource.com/41565
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
This was unintentionally regressed during a fix to field init order. It
does not typically show up in Dart code because undefined and null are
both handled, but it can break JS interop.
Change-Id: I771895826ee09bb6c5e2f9b016eb7673caf61cd1
Reviewed-on: https://dart-review.googlesource.com/40202
Reviewed-by: Vijay Menon <vsm@google.com>