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

Side by Side Diff: lib/src/compiler/code_generator.dart

Issue 1895903002: emit 'this.x' when 'super.x' accesses a field (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | test/codegen/expect/language-all.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 'dart:collection' show HashMap, HashSet; 5 import 'dart:collection' show HashMap, HashSet;
6 6
7 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 7 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
8 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; 8 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 3036 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 if (member is PropertyAccessorElement) { 3047 if (member is PropertyAccessorElement) {
3048 member = (member as PropertyAccessorElement).variable; 3048 member = (member as PropertyAccessorElement).variable;
3049 } 3049 }
3050 bool isStatic = member is ClassMemberElement && member.isStatic; 3050 bool isStatic = member is ClassMemberElement && member.isStatic;
3051 var name = _emitMemberName(memberId.name, 3051 var name = _emitMemberName(memberId.name,
3052 type: getStaticType(target), isStatic: isStatic); 3052 type: getStaticType(target), isStatic: isStatic);
3053 if (DynamicInvoke.get(target)) { 3053 if (DynamicInvoke.get(target)) {
3054 return js.call('dart.dload(#, #)', [_visit(target), name]); 3054 return js.call('dart.dload(#, #)', [_visit(target), name]);
3055 } 3055 }
3056 3056
3057 if (target is SuperExpression &&
3058 member is FieldElement &&
3059 member.getter.isSynthetic) {
vsm 2016/04/18 20:27:43 Do we need this for setters as well?
Harry Terkelsen 2016/04/18 20:59:50 Doesn't synthetic getter imply synthetic setter? A
3060 // If super.x is actually a field, then x is an instance property since
3061 // subclasses cannot override x.
3062 return js.call('this.#', [name]);
3063 }
3064
3057 String code; 3065 String code;
3058 if (member != null && member is MethodElement && !isStatic) { 3066 if (member != null && member is MethodElement && !isStatic) {
3059 // Tear-off methods: explicitly bind it. 3067 // Tear-off methods: explicitly bind it.
3060 if (target is SuperExpression) { 3068 if (target is SuperExpression) {
3061 return js.call('dart.bind(this, #, #.#)', [name, _visit(target), name]); 3069 return js.call('dart.bind(this, #, #.#)', [name, _visit(target), name]);
3062 } else if (_requiresStaticDispatch(target, memberId.name)) { 3070 } else if (_requiresStaticDispatch(target, memberId.name)) {
3063 var type = member.type; 3071 var type = member.type;
3064 var clos = js.call('dart.#.bind(#)', [name, _visit(target)]); 3072 var clos = js.call('dart.#.bind(#)', [name, _visit(target)]);
3065 return js.call('dart.fn(#, #)', [clos, _emitFunctionTypeParts(type)]); 3073 return js.call('dart.fn(#, #)', [clos, _emitFunctionTypeParts(type)]);
3066 } 3074 }
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
3749 } 3757 }
3750 3758
3751 bool isLibraryPrefix(Expression node) => 3759 bool isLibraryPrefix(Expression node) =>
3752 node is SimpleIdentifier && node.staticElement is PrefixElement; 3760 node is SimpleIdentifier && node.staticElement is PrefixElement;
3753 3761
3754 LibraryElement _getLibrary(AnalysisContext c, String uri) => 3762 LibraryElement _getLibrary(AnalysisContext c, String uri) =>
3755 c.computeLibraryElement(c.sourceFactory.forUri(uri)); 3763 c.computeLibraryElement(c.sourceFactory.forUri(uri));
3756 3764
3757 bool _isDartRuntime(LibraryElement l) => 3765 bool _isDartRuntime(LibraryElement l) =>
3758 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; 3766 l.isInSdk && l.source.uri.toString() == 'dart:_runtime';
OLDNEW
« no previous file with comments | « no previous file | test/codegen/expect/language-all.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698