Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: pkg/compiler/lib/src/closure.dart

Issue 3009903002: Pass in `this` as a free variable to the closure class (Closed)
Patch Set: merge with master Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'common/names.dart' show Identifiers; 5 import 'common/names.dart' show Identifiers;
6 import 'common/resolution.dart' show ParsingContext, Resolution; 6 import 'common/resolution.dart' show ParsingContext, Resolution;
7 import 'common/tasks.dart' show CompilerTask, Measurer; 7 import 'common/tasks.dart' show CompilerTask, Measurer;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'compiler.dart' show Compiler; 9 import 'compiler.dart' show Compiler;
10 import 'constants/expressions.dart'; 10 import 'constants/expressions.dart';
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 @override 608 @override
609 bool get hasConstant => false; 609 bool get hasConstant => false;
610 610
611 @override 611 @override
612 ConstantExpression get constant => null; 612 ConstantExpression get constant => null;
613 } 613 }
614 614
615 /// A local variable used encode the direct (uncaptured) references to [this]. 615 /// A local variable used encode the direct (uncaptured) references to [this].
616 class ThisLocal extends Local { 616 class ThisLocal extends Local {
617 final MemberEntity memberContext; 617 final MemberEntity memberContext;
618 final hashCode = ElementX.newHashCode();
619 618
620 ThisLocal(this.memberContext); 619 ThisLocal(this.memberContext);
621 620
622 Entity get executableContext => memberContext; 621 Entity get executableContext => memberContext;
623 622
624 String get name => 'this'; 623 String get name => 'this';
625 624
626 ClassEntity get enclosingClass => memberContext.enclosingClass; 625 ClassEntity get enclosingClass => memberContext.enclosingClass;
626
627 bool operator ==(other) {
628 return other is ThisLocal &&
629 other.name == name &&
630 other.memberContext == memberContext &&
631 other.enclosingClass == enclosingClass;
632 }
633
634 int get hashCode => memberContext.hashCode + enclosingClass.hashCode;
627 } 635 }
628 636
629 /// Call method of a closure class. 637 /// Call method of a closure class.
630 // ignore: STRONG_MODE_INVALID_METHOD_OVERRIDE_FROM_BASE 638 // ignore: STRONG_MODE_INVALID_METHOD_OVERRIDE_FROM_BASE
631 class SynthesizedCallMethodElementX extends BaseFunctionElementX 639 class SynthesizedCallMethodElementX extends BaseFunctionElementX
632 implements MethodElement { 640 implements MethodElement {
633 final LocalFunctionElement expression; 641 final LocalFunctionElement expression;
634 final FunctionExpression node; 642 final FunctionExpression node;
635 final TreeElements treeElements; 643 final TreeElements treeElements;
636 644
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 /// 1560 ///
1553 /// Move the below classes to a JS model eventually. 1561 /// Move the below classes to a JS model eventually.
1554 /// 1562 ///
1555 abstract class JSEntity implements MemberEntity { 1563 abstract class JSEntity implements MemberEntity {
1556 Local get declaredEntity; 1564 Local get declaredEntity;
1557 } 1565 }
1558 1566
1559 abstract class PrivatelyNamedJSEntity implements JSEntity { 1567 abstract class PrivatelyNamedJSEntity implements JSEntity {
1560 Entity get rootOfScope; 1568 Entity get rootOfScope;
1561 } 1569 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart » ('j') | tests/language_2/language_2_dart2js.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698