Files
sdk/pkg/dev_compiler/test/codegen/opassign.dart
T
John Messerly 13cf3805b8 implement opassign, fix bugs in pre/postfix, introduce a let* helper
Simplifies js_codegen to remove the special cases for things like cascades and statement parent, instead these "fall out" of JSMetaLet node and the various to* methods in js_ast. As a result of handling things more uniformly, code gets cleaner in a lot of cases. One slight "regression" is a cascade at the end of a variable init list with multiple variables. But multiple variables aren't very common so doesn't seem worth optimizing readability there.

R=leafp@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/1069493002
2015-04-10 09:53:35 -07:00

34 lines
777 B
Dart

// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
get index {
print('called "index" getter');
return 0;
}
final _foo = new Foo();
get foo {
print('called "foo" getter');
return _foo;
}
class Foo { int x = 100; }
main() {
var f = { 0: 40 };
print('should only call "index" 2 times:');
++f[index];
forcePostfix(f[index]++);
print('should only call "foo" 2 times:');
++foo.x;
forcePostfix(foo.x++);
print('op assign test, should only call "index" twice:');
f[index] += f[index];
}
// Postfix generates as prefix if the value isn't used. This method prevents it.
forcePostfix(x) {}