| OLD | NEW |
| 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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 var classExpr = new JS.ClassExpression(new JS.Identifier(type.name), | 1167 var classExpr = new JS.ClassExpression(new JS.Identifier(type.name), |
| 1168 _emitClassHeritage(element), [constructor, toStringF]); | 1168 _emitClassHeritage(element), [constructor, toStringF]); |
| 1169 var id = _emitTopLevelName(element); | 1169 var id = _emitTopLevelName(element); |
| 1170 | 1170 |
| 1171 // Emit metadata for synthetic enum index member. | 1171 // Emit metadata for synthetic enum index member. |
| 1172 // TODO(jacobr): make field readonly when that is supported. | 1172 // TODO(jacobr): make field readonly when that is supported. |
| 1173 var tInstanceFields = <JS.Property>[ | 1173 var tInstanceFields = <JS.Property>[ |
| 1174 new JS.Property( | 1174 new JS.Property( |
| 1175 _emitMemberName('index'), _emitAnnotatedType(intClass.type, null)) | 1175 _emitMemberName('index'), _emitAnnotatedType(intClass.type, null)) |
| 1176 ]; | 1176 ]; |
| 1177 var sigFields = <JS.Property>[_buildSignatureField('fields', tInstanceFields
)]; | 1177 var sigFields = <JS.Property>[ |
| 1178 _buildSignatureField('fields', tInstanceFields) |
| 1179 ]; |
| 1178 var sig = new JS.ObjectInitializer(sigFields); | 1180 var sig = new JS.ObjectInitializer(sigFields); |
| 1179 | 1181 |
| 1180 var result = [ | 1182 var result = [ |
| 1181 js.statement('# = #', [id, classExpr]), | 1183 js.statement('# = #', [id, classExpr]), |
| 1182 _callHelperStatement('setSignature(#, #);', [id, sig]) | 1184 _callHelperStatement('setSignature(#, #);', [id, sig]) |
| 1183 ]; | 1185 ]; |
| 1184 | 1186 |
| 1185 // defineEnumValues internally depends on dart.constList which uses | 1187 // defineEnumValues internally depends on dart.constList which uses |
| 1186 // _interceptors.JSArray. | 1188 // _interceptors.JSArray. |
| 1187 _declareBeforeUse(_jsArray); | 1189 _declareBeforeUse(_jsArray); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 methodNames.add(_declareMemberName(e, useExtension: false)); | 1779 methodNames.add(_declareMemberName(e, useExtension: false)); |
| 1778 } | 1780 } |
| 1779 body.add(_callHelperStatement('defineExtensionMembers(#, #);', [ | 1781 body.add(_callHelperStatement('defineExtensionMembers(#, #);', [ |
| 1780 className, | 1782 className, |
| 1781 new JS.ArrayInitializer(methodNames, multiline: methodNames.length > 4) | 1783 new JS.ArrayInitializer(methodNames, multiline: methodNames.length > 4) |
| 1782 ])); | 1784 ])); |
| 1783 } | 1785 } |
| 1784 } | 1786 } |
| 1785 | 1787 |
| 1786 JS.Property _buildSignatureField(String name, List<JS.Property> elements) { | 1788 JS.Property _buildSignatureField(String name, List<JS.Property> elements) { |
| 1787 var o = | 1789 var o = new JS.ObjectInitializer(elements, multiline: elements.length > 1); |
| 1788 new JS.ObjectInitializer(elements, multiline: elements.length > 1); | |
| 1789 // TODO(vsm): Remove | 1790 // TODO(vsm): Remove |
| 1790 var e = js.call('() => #', o); | 1791 var e = js.call('() => #', o); |
| 1791 return new JS.Property(_propertyName(name), e); | 1792 return new JS.Property(_propertyName(name), e); |
| 1792 } | 1793 } |
| 1793 | 1794 |
| 1794 /// Emit the signature on the class recording the runtime type information | 1795 /// Emit the signature on the class recording the runtime type information |
| 1795 void _emitClassSignature( | 1796 void _emitClassSignature( |
| 1796 List<MethodDeclaration> methods, | 1797 List<MethodDeclaration> methods, |
| 1797 List<FieldDeclaration> fields, | 1798 List<FieldDeclaration> fields, |
| 1798 ClassElement classElem, | 1799 ClassElement classElem, |
| (...skipping 4068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5867 if (targetIdentifier.staticElement is! PrefixElement) return false; | 5868 if (targetIdentifier.staticElement is! PrefixElement) return false; |
| 5868 var prefix = targetIdentifier.staticElement as PrefixElement; | 5869 var prefix = targetIdentifier.staticElement as PrefixElement; |
| 5869 | 5870 |
| 5870 // The library the prefix is referring to must come from a deferred import. | 5871 // The library the prefix is referring to must come from a deferred import. |
| 5871 var containingLibrary = resolutionMap | 5872 var containingLibrary = resolutionMap |
| 5872 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) | 5873 .elementDeclaredByCompilationUnit(target.root as CompilationUnit) |
| 5873 .library; | 5874 .library; |
| 5874 var imports = containingLibrary.getImportsWithPrefix(prefix); | 5875 var imports = containingLibrary.getImportsWithPrefix(prefix); |
| 5875 return imports.length == 1 && imports[0].isDeferred; | 5876 return imports.length == 1 && imports[0].isDeferred; |
| 5876 } | 5877 } |
| OLD | NEW |