| 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 // 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 library dev_compiler.src.codegen.js_codegen; |     5 library dev_compiler.src.codegen.js_codegen; | 
|     6  |     6  | 
|     7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; |     7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; | 
|     8  |     8  | 
|     9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |     9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 
|    10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; |    10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    98   ModuleItemLoadOrder _loader; |    98   ModuleItemLoadOrder _loader; | 
|    99  |    99  | 
|   100   /// _interceptors.JSArray<E>, used for List literals. |   100   /// _interceptors.JSArray<E>, used for List literals. | 
|   101   ClassElement _jsArray; |   101   ClassElement _jsArray; | 
|   102  |   102  | 
|   103   /// The default value of the module object. See [visitLibraryDirective]. |   103   /// The default value of the module object. See [visitLibraryDirective]. | 
|   104   String _jsModuleValue; |   104   String _jsModuleValue; | 
|   105  |   105  | 
|   106   Map<String, DartType> _objectMembers; |   106   Map<String, DartType> _objectMembers; | 
|   107  |   107  | 
|   108   JSCodegenVisitor(AbstractCompiler compiler, this.currentLibrary, |   108   JSCodegenVisitor(AbstractCompiler compiler, this.rules, this.currentLibrary, | 
|   109       this._extensionTypes, this._fieldsNeedingStorage) |   109       this._extensionTypes, this._fieldsNeedingStorage) | 
|   110       : compiler = compiler, |   110       : compiler = compiler, | 
|   111         options = compiler.options.codegenOptions, |   111         options = compiler.options.codegenOptions, | 
|   112         rules = compiler.rules, |  | 
|   113         _types = compiler.context.typeProvider { |   112         _types = compiler.context.typeProvider { | 
|   114     _loader = new ModuleItemLoadOrder(_emitModuleItem); |   113     _loader = new ModuleItemLoadOrder(_emitModuleItem); | 
|   115  |   114  | 
|   116     var context = compiler.context; |   115     var context = compiler.context; | 
|   117     var src = context.sourceFactory.forUri('dart:_interceptors'); |   116     var src = context.sourceFactory.forUri('dart:_interceptors'); | 
|   118     var interceptors = context.computeLibraryElement(src); |   117     var interceptors = context.computeLibraryElement(src); | 
|   119     _jsArray = interceptors.getType('JSArray'); |   118     _jsArray = interceptors.getType('JSArray'); | 
|   120  |   119  | 
|   121     _objectMembers = getObjectMemberMap(types); |   120     _objectMembers = getObjectMemberMap(types); | 
|   122   } |   121   } | 
|   123  |   122  | 
|   124   TypeProvider get types => rules.provider; |   123   TypeProvider get types => rules.provider; | 
|   125  |   124  | 
|   126   JS.Program emitLibrary(LibraryUnit library) { |   125   JS.Program emitLibrary(LibraryUnit library) { | 
|   127     // Modify the AST to make coercions explicit. |   126     // Modify the AST to make coercions explicit. | 
|   128     new CoercionReifier(library, compiler).reify(); |   127     new CoercionReifier(library, rules).reify(); | 
|   129  |   128  | 
|   130     // Build the public namespace for this library. This allows us to do |   129     // Build the public namespace for this library. This allows us to do | 
|   131     // constant time lookups (contrast with `Element.getChild(name)`). |   130     // constant time lookups (contrast with `Element.getChild(name)`). | 
|   132     if (currentLibrary.publicNamespace == null) { |   131     if (currentLibrary.publicNamespace == null) { | 
|   133       (currentLibrary as LibraryElementImpl).publicNamespace = |   132       (currentLibrary as LibraryElementImpl).publicNamespace = | 
|   134           new PublicNamespaceBuilder().build(currentLibrary); |   133           new PublicNamespaceBuilder().build(currentLibrary); | 
|   135     } |   134     } | 
|   136  |   135  | 
|   137     library.library.directives.forEach(_visit); |   136     library.library.directives.forEach(_visit); | 
|   138  |   137  | 
| (...skipping 3134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3273     t.mixins.forEach(_addExtensionType); |  3272     t.mixins.forEach(_addExtensionType); | 
|  3274     _addExtensionType(t.superclass); |  3273     _addExtensionType(t.superclass); | 
|  3275   } |  3274   } | 
|  3276  |  3275  | 
|  3277   String generateLibrary(LibraryUnit unit) { |  3276   String generateLibrary(LibraryUnit unit) { | 
|  3278     // Clone the AST first, so we can mutate it. |  3277     // Clone the AST first, so we can mutate it. | 
|  3279     unit = unit.clone(); |  3278     unit = unit.clone(); | 
|  3280     var library = unit.library.element.library; |  3279     var library = unit.library.element.library; | 
|  3281     var fields = findFieldsNeedingStorage(unit); |  3280     var fields = findFieldsNeedingStorage(unit); | 
|  3282     var codegen = |  3281     var codegen = | 
|  3283         new JSCodegenVisitor(compiler, library, _extensionTypes, fields); |  3282         new JSCodegenVisitor(compiler, rules, library, _extensionTypes, fields); | 
|  3284     var module = codegen.emitLibrary(unit); |  3283     var module = codegen.emitLibrary(unit); | 
|  3285     var out = compiler.getOutputPath(library.source.uri); |  3284     var out = compiler.getOutputPath(library.source.uri); | 
|  3286     return writeJsLibrary(module, out, |  3285     return writeJsLibrary(module, out, | 
|  3287         emitSourceMaps: options.emitSourceMaps, |  3286         emitSourceMaps: options.emitSourceMaps, | 
|  3288         arrowFnBindThisWorkaround: options.arrowFnBindThisWorkaround); |  3287         arrowFnBindThisWorkaround: options.arrowFnBindThisWorkaround); | 
|  3289   } |  3288   } | 
|  3290 } |  3289 } | 
|  3291  |  3290  | 
|  3292 /// Choose a canonical name from the library element. |  3291 /// Choose a canonical name from the library element. | 
|  3293 /// This never uses the library's name (the identifier in the `library` |  3292 /// This never uses the library's name (the identifier in the `library` | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|  3313  |  3312  | 
|  3314 /// A special kind of element created by the compiler, signifying a temporary |  3313 /// A special kind of element created by the compiler, signifying a temporary | 
|  3315 /// variable. These objects use instance equality, and should be shared |  3314 /// variable. These objects use instance equality, and should be shared | 
|  3316 /// everywhere in the tree where they are treated as the same variable. |  3315 /// everywhere in the tree where they are treated as the same variable. | 
|  3317 class TemporaryVariableElement extends LocalVariableElementImpl { |  3316 class TemporaryVariableElement extends LocalVariableElementImpl { | 
|  3318   TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); |  3317   TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); | 
|  3319  |  3318  | 
|  3320   int get hashCode => identityHashCode(this); |  3319   int get hashCode => identityHashCode(this); | 
|  3321   bool operator ==(Object other) => identical(this, other); |  3320   bool operator ==(Object other) => identical(this, other); | 
|  3322 } |  3321 } | 
| OLD | NEW |