Support try/catch/finally by pretending it is macro-expanded into
try/catch and try/finally:
try S0 catch (ex, st) S1 finally S2
==>
try { try S0 catch (ex, st) S1 } finally S2
The duplicated code for try/catch and try/finally is abstracted into a
function parameterized over translations for all the parts that
differed.
R=asgerf@google.com
Review URL: https://codereview.chromium.org//1207703002.
Try/finally is implemented by inlining. There is a try/catch to catch
exceptions in the try block. The catch body contains the finally code
followed by a rethrow. The code for finally is translated again after the
normal exit of the try block. Break, continue, and return exits in the try
block have the finally code inlined just before the exit is taken.
Try/catch/finally is not yet supported, it requires some changes to the
assigned variables analysis.
R=asgerf@google.com
Review URL: https://codereview.chromium.org//1201983002.
When a term is deleted, the algorithm searches for new redexes created
by the term's deletion. Continuation beta redexes search up the term
between the redex and the continuation's binding to ensure that the
continuation is not moved into the scope of an exception handler.
This search fails if it first encounters the root of the deleted
subterm (i.e., the newly-created redex is in the deleted term). Just
ignore the redex in that case, since the term is being deleted.
Also, update some triaged test expectations with their bug numbers.
R=asgerf@google.com
Review URL: https://codereview.chromium.org//1196323002.
.length on JS arrays are not introduced yet because that is not
seen as field accesses by our class hierarchy.
I've changed the contract on Primitives so they can have side effects,
depend on state, diverge, throw, anything goes. GetField on possibly
null receivers would not be allowed otherwise.
AFAIK there are no optimizations that actually used the contract on
primitives, it just seemed like a good idea at one point in the past,
so that change only affects a single doc comment.
I'll migrate some of the classes that can now be primitives in another
CL.
BuiltinOperators are still required to be pure, although that too may
possibly change soon.
BUG=
R=kmillikin@google.com
Review URL: https://codereview.chromium.org//1188253006.
As of commit 67b99e4b33, it is now
consistently a compile error for a prefix not to be followed by '.'.
(Previously, there were two exceptions in which a prefix not followed
by '.' was treated as though it was preceded by "this.")
This CL updates analyzer to be consistent with the new spec langauge,
and modifies the tests in tests/language accordingly.
Dart2js and the VM do not yet produce the correct compile-time error
in all circumstances. See issues #23611 and #23612.
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1186033004.
The generated code uses different helpers than the SSA. In SSA, there are calls to buildFunctionType and _isTest. The CPS uses checkSubtypeOfRuntimeType, the "one size fits all" method we also use to test against type variable types.
When the function type has no type variables in it we could hoist the function type into a constant, but the constant system does not support type representation constants at the moment. But it seems like an optimization we may want to add later.
BUG=
R=karlklose@google.com
Review URL: https://codereview.chromium.org//1180973003.
The tests for e?.v++ and e?.v-- validate the spec text added in
58708e3 (as clarified by 1ab7736).
The tests for ++e?.v and --e?.v weren't mandated by any spec change,
but since these expressions weren't previously tested, it seemed
reasonable to add tests for them.
All tests pass under the current implementation of "?." in analyzer
and dart2js.
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1177043010.
This CL makes analyzer consistent with the VM and the spec, by
producing a compile-time error for code such as:
class C {
final x = 1;
const C() : x = 2;
}
main() {
const C();
}
Note that Dart2js also produces an error in this circumstance, but its
error is too general (the error should only be produced if the const
constructor is invoked using "const"; if the const constructor is
invoked using "new", or is not invoked at all, it should only be a
warning). See #23618.
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1175073002.
If 'p' is an import prefix, then 'p = ...' is treated as synonymous
with 'this.p = ...', and 'p()' is treated as synonymous with
'this.p()'. In all other circumstances where 'p' is not followed by
'.', the spec calls for a compile time error.
Previous to this CL, 'p' not followed by '.' was being treated as
synonymous with 'this.p' under all circumstances. This CL brings
analyzer in line with the spec, and updates the tests in
tests/language accordingly.
The VM and Dart2js currently fail to implement the compile-time error
properly. See issues #23611 and #23612.
Fixes issue #23461.
R=scheglov@google.com
Review URL: https://codereview.chromium.org//1173523002.
We now optimize type casts that always fail or always pass.
Type propagation has been refactored a bit to make this work.
A new IR node Unreachable has been added. This is an node that is known
to be unreachable and is ultimately compiled to an empty statement.
BUG=
R=karlklose@google.com
Review URL: https://codereview.chromium.org//1153603006