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

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

Issue 2980853002: Registration-based approach to cross frame support. (Closed)
Patch Set: Created 3 years, 5 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) 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 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 .where((peer) => !peer.startsWith("!")) 1779 .where((peer) => !peer.startsWith("!"))
1780 .toList(); 1780 .toList();
1781 } else { 1781 } else {
1782 return []; 1782 return [];
1783 } 1783 }
1784 } 1784 }
1785 1785
1786 void _registerExtensionType( 1786 void _registerExtensionType(
1787 ClassElement classElem, String jsPeerName, List<JS.Statement> body) { 1787 ClassElement classElem, String jsPeerName, List<JS.Statement> body) {
1788 if (jsPeerName != null) { 1788 if (jsPeerName != null) {
1789 body.add(_callHelperStatement('registerExtension(#.global.#, #);', [ 1789 body.add(_callHelperStatement('registerExtension(#, #);',
Jennifer Messerly 2017/07/14 19:38:08 oh wow, this is much cleaner :)
1790 _runtimeModule, 1790 [js.string(jsPeerName), _emitTopLevelName(classElem)]));
1791 _propertyName(jsPeerName),
1792 _emitTopLevelName(classElem)
1793 ]));
1794 } 1791 }
1795 } 1792 }
1796 1793
1797 JS.Statement _setBaseClass(ClassElement classElem, JS.Expression className, 1794 JS.Statement _setBaseClass(ClassElement classElem, JS.Expression className,
1798 List<String> jsPeerNames, List<JS.Statement> body) { 1795 List<String> jsPeerNames, List<JS.Statement> body) {
1799 var typeFormals = classElem.typeParameters; 1796 var typeFormals = classElem.typeParameters;
1800 if (jsPeerNames.length == 1 && typeFormals.isNotEmpty) { 1797 if (jsPeerNames.length == 1 && typeFormals.isNotEmpty) {
1801 var newBaseClass = _callHelper('global.#', jsPeerNames[0]); 1798 var newBaseClass = _callHelper('global.#', jsPeerNames[0]);
1802 body.add(_callHelperStatement( 1799 body.add(_callHelperStatement(
1803 'setExtensionBaseClass(#, #);', [className, newBaseClass])); 1800 'setExtensionBaseClass(#, #);', [className, newBaseClass]));
(...skipping 4160 matching lines...) Expand 10 before | Expand all | Expand 10 after
5964 if (targetIdentifier.staticElement is! PrefixElement) return false; 5961 if (targetIdentifier.staticElement is! PrefixElement) return false;
5965 var prefix = targetIdentifier.staticElement as PrefixElement; 5962 var prefix = targetIdentifier.staticElement as PrefixElement;
5966 5963
5967 // The library the prefix is referring to must come from a deferred import. 5964 // The library the prefix is referring to must come from a deferred import.
5968 var containingLibrary = resolutionMap 5965 var containingLibrary = resolutionMap
5969 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) 5966 .elementDeclaredByCompilationUnit(target.root as CompilationUnit)
5970 .library; 5967 .library;
5971 var imports = containingLibrary.getImportsWithPrefix(prefix); 5968 var imports = containingLibrary.getImportsWithPrefix(prefix);
5972 return imports.length == 1 && imports[0].isDeferred; 5969 return imports.length == 1 && imports[0].isDeferred;
5973 } 5970 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698