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; |
(...skipping 26 matching lines...) Expand all Loading... |
37 jsAst.Expression generateClassConstructor( | 37 jsAst.Expression generateClassConstructor( |
38 ClassEntity classElement, Iterable<jsAst.Name> fields, bool hasRtiField) { | 38 ClassEntity classElement, Iterable<jsAst.Name> fields, bool hasRtiField) { |
39 // TODO(sra): Implement placeholders in VariableDeclaration position: | 39 // TODO(sra): Implement placeholders in VariableDeclaration position: |
40 // | 40 // |
41 // String constructorName = namer.getNameOfClass(classElement); | 41 // String constructorName = namer.getNameOfClass(classElement); |
42 // return js.statement('function #(#) { #; }', | 42 // return js.statement('function #(#) { #; }', |
43 // [ constructorName, fields, | 43 // [ constructorName, fields, |
44 // fields.map( | 44 // fields.map( |
45 // (name) => js('this.# = #', [name, name]))])); | 45 // (name) => js('this.# = #', [name, name]))])); |
46 var typeParameters = const <jsAst.Parameter>[]; | 46 var typeParameters = const <jsAst.Parameter>[]; |
47 var typeInits = const <jsAst.Expression>[]; | 47 dynamic typeInits = const <jsAst.Expression>[]; |
48 if (hasRtiField) { | 48 if (hasRtiField) { |
49 var rtiName = _namer.rtiFieldJsName; | 49 dynamic rtiName = _namer.rtiFieldJsName; |
50 typeParameters = rtiName; | 50 typeParameters = rtiName; |
51 typeInits = js('this.# = #', [rtiName, rtiName]); | 51 typeInits = js('this.# = #', [rtiName, rtiName]); |
52 } | 52 } |
53 return js('function(#, #) { #; #; this.#();}', [ | 53 return js('function(#, #) { #; #; this.#();}', [ |
54 fields, | 54 fields, |
55 typeParameters, | 55 typeParameters, |
56 fields.map((name) => js('this.# = #', [name, name])), | 56 fields.map((name) => js('this.# = #', [name, name])), |
57 typeInits, | 57 typeInits, |
58 _namer.deferredAction | 58 _namer.deferredAction |
59 ]); | 59 ]); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (cache === void 0) cache = #tearOff( | 313 if (cache === void 0) cache = #tearOff( |
314 this, funcs, reflectionInfo, true, [], name).prototype; | 314 this, funcs, reflectionInfo, true, [], name).prototype; |
315 return cache; | 315 return cache; |
316 } | 316 } |
317 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); | 317 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); |
318 }''', | 318 }''', |
319 {'tearOff': tearOffAccessExpression}); | 319 {'tearOff': tearOffAccessExpression}); |
320 | 320 |
321 return <jsAst.Statement>[tearOffGetter, tearOff]; | 321 return <jsAst.Statement>[tearOffGetter, tearOff]; |
322 } | 322 } |
OLD | NEW |