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

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

Issue 2440863002: fix #27642, static members should now work (Closed)
Patch Set: Created 4 years, 2 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 | pkg/dev_compiler/test/browser/language_tests.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 2
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 import 'dart:collection' show HashMap, HashSet; 6 import 'dart:collection' show HashMap, HashSet;
7 import 'dart:math' show min, max; 7 import 'dart:math' show min, max;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4641 matching lines...) Expand 10 before | Expand all | Expand 10 after
4652 // TODO(jmesserly): handle explicitly passed type args. 4652 // TODO(jmesserly): handle explicitly passed type args.
4653 if (type == null) return null; 4653 if (type == null) return null;
4654 return _emitFunctionTypeArguments(type, instantiated); 4654 return _emitFunctionTypeArguments(type, instantiated);
4655 } 4655 }
4656 4656
4657 JS.LiteralString _emitDynamicOperationName(String name) => 4657 JS.LiteralString _emitDynamicOperationName(String name) =>
4658 js.string(options.replCompile ? '${name}Repl' : name); 4658 js.string(options.replCompile ? '${name}Repl' : name);
4659 4659
4660 JS.Expression _emitAccessInternal(Expression target, Element member, 4660 JS.Expression _emitAccessInternal(Expression target, Element member,
4661 String memberName, List<JS.Expression> typeArgs) { 4661 String memberName, List<JS.Expression> typeArgs) {
4662 bool isStatic = member is ClassMemberElement && member.isStatic; 4662 // TODO(jmesserly): we don't use member.isStatic because it doesn't seem to
4663 // work, see https://github.com/dart-lang/sdk/issues/27642 for context.
4664 bool isStatic = target is SimpleIdentifier &&
4665 target.staticElement is TypeDefiningElement;
vsm 2016/10/21 02:07:16 Hmm, do we need target is SimpleIdentifier? Might
Jennifer Messerly 2016/10/21 17:48:07 yes, we need something. You can't get a staticElem
4663 var name = _emitMemberName(memberName, 4666 var name = _emitMemberName(memberName,
4664 type: getStaticType(target), isStatic: isStatic); 4667 type: getStaticType(target), isStatic: isStatic);
4665 if (isDynamicInvoke(target)) { 4668 if (isDynamicInvoke(target)) {
4666 if (_inWhitelistCode(target)) { 4669 if (_inWhitelistCode(target)) {
4667 var vars = <JS.MetaLetVariable, JS.Expression>{}; 4670 var vars = <JS.MetaLetVariable, JS.Expression>{};
4668 var l = _visit(_bindValue(vars, 'l', target)); 4671 var l = _visit(_bindValue(vars, 'l', target));
4669 return new JS.MetaLet(vars, [ 4672 return new JS.MetaLet(vars, [
4670 js.call('(#[dart._extensionType]) ? #[dartx[#]] : #.#', 4673 js.call('(#[dart._extensionType]) ? #[dartx[#]] : #.#',
4671 [l, l, name, l, name]) 4674 [l, l, name, l, name])
4672 ]); 4675 ]);
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
5519 } 5522 }
5520 5523
5521 bool isLibraryPrefix(Expression node) => 5524 bool isLibraryPrefix(Expression node) =>
5522 node is SimpleIdentifier && node.staticElement is PrefixElement; 5525 node is SimpleIdentifier && node.staticElement is PrefixElement;
5523 5526
5524 LibraryElement _getLibrary(AnalysisContext c, String uri) => 5527 LibraryElement _getLibrary(AnalysisContext c, String uri) =>
5525 c.computeLibraryElement(c.sourceFactory.forUri(uri)); 5528 c.computeLibraryElement(c.sourceFactory.forUri(uri));
5526 5529
5527 bool _isDartRuntime(LibraryElement l) => 5530 bool _isDartRuntime(LibraryElement l) =>
5528 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; 5531 l.isInSdk && l.source.uri.toString() == 'dart:_runtime';
OLDNEW
« no previous file with comments | « no previous file | pkg/dev_compiler/test/browser/language_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698