Commit Graph

4770 Commits

Author SHA1 Message Date
Paul Berry f30b494035 Flow analysis: add the ability to defer storing node info in AssignedVariables.
This is needed by the front end, since it sometimes finishes parsing a
construct before creating the kernel representation of it, so it needs
to defer storing the node info for that construct until it creates the
kernel representation.

Change-Id: I2a59f08a228b6fed2af711cc0f06576ddc99a054
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123505
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-30 12:25:54 +00:00
Aske Simon Christensen 6812504f08 [CFE] Error when an extension operation is used in a constant expression
Fixes https://github.com/dart-lang/sdk/issues/39146

Change-Id: Iba733d8887b2422d692ff18e03e126baec2f3d90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123247
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-30 12:23:34 +00:00
Johnni Winther 3ccdb01fc9 [cfe] Handle extensions exported through multiple libraries
Closes #39160

Change-Id: I605b1a95ddab822848b33244b3130ebf16b69842
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123523
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-10-30 11:59:44 +00:00
Jens Johansen c791aa880c [CFE] Fix parser crash when recovering from missing operator and having a return type
Fixes #39026

Change-Id: I2eb5620017f6c52e8a06248a8c2ed9f2eb196f9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123520
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-10-30 11:14:44 +00:00
Paul Berry f0561cb75e Sort declarations in flow_analysis.dart.
Change-Id: I2e0aec13302b7ef9b5093e45ec9724f8ba66e72b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123503
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-30 10:54:45 +00:00
Paul Berry 5837107613 Flow analysis: add AssignedVariables.discardNode method
This will need to be used by the front end's body builder to properly
record assigned variables for a try/catch/finally statement.

Change-Id: Ia0cda160e524f6dc52c19362cc35b6f405eca993
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123501
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-10-30 10:54:45 +00:00
Johnni Winther ee9ec9c3e0 [cfe] Report error on builtin identifier as extension name
Closes #38094

Change-Id: I029f8f30ee0c15ec9f1adf7419f83c4e76ca3ae1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123521
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2019-10-30 10:02:55 +00:00
Jens Johansen 5e323ba031 [CFE] Allow eof in assert to avoid crash
Fixes #39024.

Change-Id: I7c45d58133d54944f256f5c555b0f4f7332606ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123405
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-10-30 08:16:45 +00:00
Jens Johansen 63b9a155f7 [CFE] Fix potential parser crash when parsing typedef
Fixes #39033.

Change-Id: I746e7b9c6bd531565721ad45954ee68e0ac392b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123403
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-10-30 08:16:37 +00:00
Johnni Winther fc5d096617 [cfe] Make Scope.local, Scope.setters, Scope.parent private
+ improve type precision of setter and label maps in Scope.

Change-Id: I79e9b0c05dd3dbe38d9359c1f45e11f42fd584de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123255
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-10-29 14:45:44 +00:00
Johnni Winther b4198f3069 [cfe] Remove Builder.target
Change-Id: Ieb2d88d1014ed681d485052b4226d81351ce60fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123242
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-29 14:45:44 +00:00
Paul Berry 780af0fcfc Flow analysis: promote to "types of interest" on assignment.
This allows so-called "ensure guarded" promotions, e.g.
- `if (x is! int) x = 0;`
- `if (x == null) x = 0;`
- `x ??= 0;`

The latter two are particularly important to prepare for NNBD.

Change-Id: Ib53ca916e6d485945326b19e86f8cfb5b3ee2160
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-29 13:23:59 +00:00
Dmitry Stefantsov d213d3c736 [cfe] Start implementing reachability analysis involving type Never
Change-Id: I80edd4dd1b46b533a4f50243e1d3b18aa00f80ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123250
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-29 12:27:19 +00:00
Jens Johansen ea3cb7317a [CFE] Fix unescapeString crash
unescapeString would for instance crash if it got the string '"'
(without the quotes) (i.e. the single ascii character 0x22).

Fixes #39035

Change-Id: I0b6baba975b3e8a9279699027fde4b15cde4a5ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123249
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-29 09:38:46 +00:00
Johnni Winther c8ff1b0c21 [cfe] Add BlockKind to parse/begin/endBlock
... and use this to computed AssignedVariables data for try statements

Change-Id: I235575b055cb89b553baf0ac728d9954d8d0aaa6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123251
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-10-29 09:17:06 +00:00
Johnni Winther 688454c4a7 [cfe] Compute AssignedVariables in body builder
For-loops and try statements currently not supported.

Change-Id: I52a591b55149ddfd5d0c5792239555d72b8146fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123248
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-10-29 09:17:06 +00:00
Jens Johansen c738b6bc8a [CFE] Fix parser crash ("isSynthetic called on null" in list literal suffix)
Fixes #39058.

Change-Id: I6fd6c6ba45f43e95cea12e0a7776ff10515d3d9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123243
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-29 07:10:16 +00:00
Johnni Winther eb04e0922b [cfe] Refactor CompoundPropertySet and add CompoundExtensionSet
Change-Id: Id6dda215cae88dc35943f34be4f210d148eace00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122642
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-28 14:08:42 +00:00
Johnni Winther bb02531b7e [cfe] Move creation of error nodes to inferrer
During top-level inference we cannot emit errors. With this change
the inferrer controls whether to create and report an error or to create
a revisitable node.

Change-Id: Ia7821c6d2628fdae0897f3cd6108ef12d2f096df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122782
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-28 14:08:42 +00:00
Paul Berry e1fce75301 Flow analysis: clean up unit tests using custom matchers.
Previously, we made heavy use of operator== in the flow analysis
tests.  But we also tried to verify that the flow analysis engine
didn't compare types with operator==.  This was kludgy, because it
meant that we had to use a global variable to keep track of whether a
use of _Type.operator== should succeed.  It was also kludgy because it
required an implementation of operator== in flow analysis code that
was solely meant for testing.

By using custom matchers, we can get the same level of testing
flexibility without making use of operator== anywhere.

Also, fixed a few flaws in the tests for "join".  They were
accidentally setting up variables in the already-written state, so the
"assigned" subtest was passing in spite of incorrect expectations.

Change-Id: If326678aeb20a62433ad090968e150738ba5dc59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123140
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-28 13:59:07 +00:00
Jens Johansen d7c75edd57 [CFE] Use 'SyntheticBeginToken' for BeginToken that origins from a synthetic node
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/122863.

Change-Id: I17e79687fe9950ae8ff0f1f8a4a6270926106813
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123241
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-28 11:01:10 +00:00
Jens Johansen e9bc071821 [CFE/parser] Fix erroneous assert when parsing blocks
In for instance Parser.parseBlock a loop says while not "}" or EOF.
After the loop we assert it is in fact "}"...

Fixes #39060

Change-Id: I764dc6ab2df180cb55a813ddd42b968391a96f04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122864
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-10-28 07:20:25 +00:00
Paul Berry 9f25d0e1d8 Flow analysis: don't necessarily clear promotions on assignment.
If the RHS of an assignment is a subtype of the current promoted type
(or one of the previously promoted types), any relevant promotions are
kept.

So for example:

  if (x is int) {
    x = x + 1; // Still an int!
    print(x.isEVen); // ok
  }

This required two significant changes:

- Clients must now tell the flow analysis engine the type of the RHS
  of the assignment.  This required some refactoring in the analyzer,
  because this information wasn't always easily available at the point
  where we were calling flow analysis.

- The flow analysis engine now has to keep track of a "chain" of the
  currently active promotions, so that it can potentially un-do some
  promotions but not others.  This meant that the algorithms for
  "join" and "restrict" had to be reworked.

In a future CL I'll add the ability for assignments to promote to
types that have been previously checked against ("types of interest"),
e.g.:

  if (x is! int) {
    x = 0; // x is now an int!
  }
  // x is now known to be an int because it's promoted in both branches

Change-Id: I63d6c9a2021b045d391b2d9c674e9a2e5f770e62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123003
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-26 20:38:28 +00:00
Dmitry Stefantsov 9910fa8454 [cfe] Implement the first part of NNBD-aware isSubtypeOf
This CL is a squashing of the following smaller CLs:

* https://dart-review.googlesource.com/c/sdk/+/120669/
* https://dart-review.googlesource.com/c/sdk/+/120670/
* https://dart-review.googlesource.com/c/sdk/+/121331/
* https://dart-review.googlesource.com/c/sdk/+/121381/
* https://dart-review.googlesource.com/c/sdk/+/121383/
* https://dart-review.googlesource.com/c/sdk/+/121620/
* https://dart-review.googlesource.com/c/sdk/+/121707/
* https://dart-review.googlesource.com/c/sdk/+/122144/
* https://dart-review.googlesource.com/c/sdk/+/122360/
* https://dart-review.googlesource.com/c/sdk/+/122381/
* https://dart-review.googlesource.com/c/sdk/+/122783/
* https://dart-review.googlesource.com/c/sdk/+/122787/

Change-Id: I9d850f531f0fce07055ff9b5cd39abb605752005
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122868
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2019-10-25 16:37:39 +00:00
Paul Berry 0167f91012 Flow analysis: introduce ID tests for AssignedVariables.
This should make it easier to verify that the CFE implementation is
correct.

Note that this effort encountered a few bugs in the analyzer
implementation, which are marked with TODOs.  I will fix them in
follow-up CLs.

Change-Id: Ic164a1cf214b5730f848b17db2838c29d25b00d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122850
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-25 13:44:05 +00:00
Jens Johansen 165196dbc0 [parser] Fix infinite loop and setting offsets after EOF
Fixed: 38415
Change-Id: Iefc4fdd289d551fa77c341efbab2f59d48bb2b9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122863
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-10-25 10:57:54 +00:00
Johnni Winther d576ce69e1 [cfe] Implement initial integration of reachability
This CL is based on:

https://dart-review.googlesource.com/c/sdk/+/122397
https://dart-review.googlesource.com/c/sdk/+/122500
https://dart-review.googlesource.com/c/sdk/+/122399

Change-Id: Id5474e5338f3d04e6710015b9d1cc1baec93e7ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122861
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-10-25 09:53:34 +00:00
Jens Johansen 2d0cdbdd12 [CFE/Incremental compiler] Don't crash on parts with invalid scheme
Before this CL a part like "part ' package:foo/bar.dart';" would crash
the incremental compiler because the part specifies a scheme that is
invalid.

Change-Id: I567df0a68ff8709e4ca95d24e6dabc4d959c95fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122862
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-25 09:27:24 +00:00
Jens Johansen 87fa4e49d7 [CFE] Fix of an UTF8 BOM in input file possibly causing a crash
Fixes: #39091
Change-Id: I963d22a49efebbed16b9645d2249c0887c35d780
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122789
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-10-25 07:07:54 +00:00
Johnni Winther 1bc9fba660 [cfe] Allow this access in late field initializers
Change-Id: Ia2139e3e87a4b141b5e0df41541bab5f74acd5dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122760
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2019-10-24 18:11:17 +00:00
Paul Berry 8f5a45c22d Flow analysis: add support for ??=.
Change-Id: I8c99c42cf3a2560d7af3daf27ee316e22a2eb027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122588
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-24 17:57:27 +00:00
Paul Berry b7911e4490 Flow analysis: add support for asserts.
Fixes #38761.

Change-Id: I6cc4adc0383cc56d99fa73ef75f728db0c56063b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122732
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-24 17:01:33 +00:00
Johnni Winther 4d1bc04d69 [cfe] Flatten TypeInferrer(Engine) hierarchies
Makes TypeInferrerImpl and TypeInferenceEngineImpl fully implement
the interfaces.

Change-Id: Ic058e7c3cb4d6adae98d499df74824e96a395c8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122780
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-10-24 13:07:53 +00:00
Paul Berry 1bd6e20d76 Flow analysis: simplify the use of AssignedVariables.
Previously, the client was responsible for querying AssignedVariables
to find the variables assigned and captured during constructs like
loops, and passing that information into FlowAnalysis methods.  With
this CL, the client simply passes AssignedVariables into the
FlowAnalysis constructor, and the lookup happens automatically.

Change-Id: Ifbbf8ba8ea0d0f8a31d41244892c8c816eea56dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122731
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-24 13:00:50 +00:00
Johnni Winther 18d43babd1 [cfe] Avoid crash for missing object access targets in toplevel inference
We cannot emit errors during toplevel inference.

Change-Id: I2add33892ddf20c27ff53038a3be2b02c34029e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122761
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-24 10:51:49 +00:00
Johnni Winther 63d524dec0 [cfe] Add skeleton for testing nullability, definite assignment and type promotion
Change-Id: I8eab67deb401496af5a5aee3a44831a8ade55a1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122641
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-10-24 09:23:06 +00:00
Paul Berry 92c69f224b Flow analysis: promote on successful execution of an "as" expression.
Change-Id: I506281ab2dfe23b4b75daf795028fec979006932
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122586
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-23 17:02:37 +00:00
Johnni Winther 2727fd9b3c [cfe] Add helper for creating property set
The use of the helper removed the creation some unneeded temporary
variables in extension access which is reflected in the expectation
changes.

Change-Id: Ice6afcb223b7740c2555a076c3ddae9a9d4f092d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122394
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-23 12:23:53 +00:00
Johnni Winther e5a587fca4 [cfe] Add helper for creating property get during inference
Change-Id: Ic4b8f78cc0ced98f17d2dc27c2d4a6d6e273af91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122389
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-23 12:23:53 +00:00
Johnni Winther 857502b1d2 [cfe] Add helpers for creating index set/get operations
Change-Id: I0125d31ed5fb43baeb76b3346a4251703c5f8b4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122383
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-23 12:23:53 +00:00
Paul Berry 0887806796 Flow analysis: introduce TypeOperations.tryPromoteToType method.
Previously, any attempt to promote type A to type B produced type B if
B was a subtype of A, and failed otherwise.  But in order to support
promotion of type parameters, we need the ability to produce a fresh
"intersection type" (e.g. `T & int`).  The new
`TypeOperations.tryPromoteToType method` makes this possible by giving
the client the opportunity to synthesize the new type when necessary.

Change-Id: If671d5d865f38469a878329180c3a1c94e25a42c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122582
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-23 11:12:21 +00:00
Paul Berry 2e6afae4c3 Ignore EMACS backup files when running ID tests
Change-Id: I80891b2194522cd9c5746fff8c749a0edf2df4d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122580
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-23 07:04:16 +00:00
Paul Berry dfddeada02 Flow analysis: treat expressions of type Never as unreachable.
Change-Id: I4e6c629e4f9f8ebba3c7b2168b421a723c69928b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122417
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-23 05:52:26 +00:00
Paul Berry 689c934406 Flow analysis: add support for null-aware accesses.
Change-Id: I4367a1dd23d981b885a48d7fbe129d2288787a9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122415
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-22 19:18:16 +00:00
Kallen Tu 4601bd7bff Modified supertype check error message to be more descriptive.
Change-Id: I3068bf195eb9a746d25ac62007eaeac0296d3087
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121463
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2019-10-22 16:59:16 +00:00
Johnni Winther b26127fe01 [cfe] Add reachability test skeleton
Change-Id: Iac74d450816f1781512d44d533464e7c9857fed8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122388
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-10-22 12:26:31 +00:00
Paul Berry aeede3c1b0 Flow analysis: pass catch variables to tryCatchStatement_catchBegin.
Previously, it was the caller's responsibility to call initialize()
for any variables declared in a catch block.  Now this is done
automatically.

Change-Id: If9c586e12f7d114517476e56e984d16a570648e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122413
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-22 10:56:54 +00:00
Paul Berry 9579c4bc3c Flow analysis: simplify use of isExpression_end.
Previously, it was the caller's responsibility to determine if the
subexpression of an "is" expression was a read of a promotable
variable.  Now, the caller calls isExpression_end regardless of what
the subexpression is, and flow analysis determines whether promotion
should happen or not.

Change-Id: Ibba689935580d4e9c5ab79e5afb534c173386232
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122411
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-22 10:56:54 +00:00
Johnni Winther a58d337bd3 [cfe] Add helper for creating binary expressions.
Change-Id: Ieeafa15bbecaaa53c4624219fa0256c03d2c3207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122380
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-22 10:04:54 +00:00
Johnni Winther e76f6d49e4 [cfe] Implement null-shorting for most expressions
Binary operations and parenthesized expression are shorted which they
shouldn't be. Also, so complex expressions, like compound assignment,
are not handled because they need to be encoded in a more high-level
internal expression to support choosing the receiver based on shorting.

Change-Id: I0bdeabdc21da7d80f533ea0880662bfb11341c6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121856
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-10-22 10:04:54 +00:00