| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.js_emitter.class_stub_generator; | 5 library dart2js.js_emitter.class_stub_generator; |
| 6 | 6 |
| 7 import '../common/names.dart' show Identifiers; | 7 import '../common/names.dart' show Identifiers; |
| 8 import '../common_elements.dart' show CommonElements; | 8 import '../common_elements.dart' show CommonElements; |
| 9 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
| 10 import '../js/js.dart' as jsAst; | 10 import '../js/js.dart' as jsAst; |
| 11 import '../js/js.dart' show js; | 11 import '../js/js.dart' show js; |
| 12 import '../js_backend/namer.dart' show Namer; | 12 import '../js_backend/namer.dart' show Namer; |
| 13 import '../js_backend/interceptor_data.dart' show InterceptorData; | 13 import '../js_backend/interceptor_data.dart' show InterceptorData; |
| 14 import '../options.dart'; | 14 import '../options.dart'; |
| 15 import '../universe/selector.dart' show Selector; | 15 import '../universe/selector.dart' show Selector; |
| 16 import '../universe/world_builder.dart' | 16 import '../universe/world_builder.dart' |
| 17 show CodegenWorldBuilder, SelectorConstraints; | 17 show CodegenWorldBuilder, SelectorConstraints; |
| 18 import '../world.dart' show ClosedWorld; | 18 import '../world.dart' show ClosedWorld; |
| 19 | 19 |
| 20 import 'code_emitter_task.dart'; | 20 import 'code_emitter_task.dart'; |
| 21 import 'model.dart'; | 21 import 'model.dart'; |
| 22 | 22 |
| 23 class ClassStubGenerator { | 23 class ClassStubGenerator { |
| 24 final Namer _namer; | 24 final Namer _namer; |
| 25 final CodegenWorldBuilder _worldBuilder; | 25 final CodegenWorldBuilder _worldBuilder; |
| 26 final ClosedWorld _closedWorld; | 26 final ClosedWorld _closedWorld; |
| 27 final InterceptorData _interceptorData; | |
| 28 final bool enableMinification; | 27 final bool enableMinification; |
| 29 final Emitter _emitter; | 28 final Emitter _emitter; |
| 30 final CommonElements _commonElements; | 29 final CommonElements _commonElements; |
| 31 | 30 |
| 32 ClassStubGenerator(this._emitter, this._commonElements, this._namer, | 31 ClassStubGenerator(this._emitter, this._commonElements, this._namer, |
| 33 this._worldBuilder, this._interceptorData, this._closedWorld, | 32 this._worldBuilder, this._closedWorld, |
| 34 {this.enableMinification}); | 33 {this.enableMinification}); |
| 35 | 34 |
| 35 InterceptorData get _interceptorData => _closedWorld.interceptorData; |
| 36 |
| 36 jsAst.Expression generateClassConstructor( | 37 jsAst.Expression generateClassConstructor( |
| 37 ClassEntity classElement, Iterable<jsAst.Name> fields, bool hasRtiField) { | 38 ClassEntity classElement, Iterable<jsAst.Name> fields, bool hasRtiField) { |
| 38 // TODO(sra): Implement placeholders in VariableDeclaration position: | 39 // TODO(sra): Implement placeholders in VariableDeclaration position: |
| 39 // | 40 // |
| 40 // String constructorName = namer.getNameOfClass(classElement); | 41 // String constructorName = namer.getNameOfClass(classElement); |
| 41 // return js.statement('function #(#) { #; }', | 42 // return js.statement('function #(#) { #; }', |
| 42 // [ constructorName, fields, | 43 // [ constructorName, fields, |
| 43 // fields.map( | 44 // fields.map( |
| 44 // (name) => js('this.# = #', [name, name]))])); | 45 // (name) => js('this.# = #', [name, name]))])); |
| 45 var typeParameters = const <jsAst.Parameter>[]; | 46 var typeParameters = const <jsAst.Parameter>[]; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 if (cache === void 0) cache = #tearOff( | 313 if (cache === void 0) cache = #tearOff( |
| 313 this, funcs, reflectionInfo, true, [], name).prototype; | 314 this, funcs, reflectionInfo, true, [], name).prototype; |
| 314 return cache; | 315 return cache; |
| 315 } | 316 } |
| 316 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); | 317 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); |
| 317 }''', | 318 }''', |
| 318 {'tearOff': tearOffAccessExpression}); | 319 {'tearOff': tearOffAccessExpression}); |
| 319 | 320 |
| 320 return <jsAst.Statement>[tearOffGetter, tearOff]; | 321 return <jsAst.Statement>[tearOffGetter, tearOff]; |
| 321 } | 322 } |
| OLD | NEW |