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 /// This library defines the operations that define and manipulate Dart | 5 /// This library defines the operations that define and manipulate Dart |
6 /// classes. Included in this are: | 6 /// classes. Included in this are: |
7 /// - Generics | 7 /// - Generics |
8 /// - Class metadata | 8 /// - Class metadata |
9 /// - Extension methods | 9 /// - Extension methods |
10 /// | 10 /// |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 }) | 327 }) |
328 } | 328 } |
329 })()'''); | 329 })()'''); |
330 | 330 |
331 /// Set up the type signature of a class (constructor object) | 331 /// Set up the type signature of a class (constructor object) |
332 /// f is a constructor object | 332 /// f is a constructor object |
333 /// signature is an object containing optional properties as follows: | 333 /// signature is an object containing optional properties as follows: |
334 /// methods: A function returning an object mapping method names | 334 /// methods: A function returning an object mapping method names |
335 /// to method types. The function is evaluated lazily and cached. | 335 /// to method types. The function is evaluated lazily and cached. |
336 /// statics: A function returning an object mapping static method | 336 /// statics: A function returning an object mapping static method |
337 /// names to types. The function is evalutated lazily and cached. | 337 /// names to types. The function is evaluated lazily and cached. |
338 /// names: An array of the names of the static methods. Used to | 338 /// names: An array of the names of the static methods. Used to |
339 /// permit eagerly setting the runtimeType field on the methods | 339 /// permit eagerly setting the runtimeType field on the methods |
340 /// while still lazily computing the type descriptor object. | 340 /// while still lazily computing the type descriptor object. |
341 /// fields: A function returning an object mapping instance field | 341 /// fields: A function returning an object mapping instance field |
342 /// names to types. | 342 /// names to types. |
343 setSignature(f, signature) => JS( | 343 setSignature(f, signature) => JS( |
344 '', | 344 '', |
345 '''(() => { | 345 '''(() => { |
346 // TODO(ochafik): Deconstruct these when supported by Chrome. | 346 // TODO(ochafik): Deconstruct these when supported by Chrome. |
347 let constructors = | 347 let constructors = |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 570 |
571 defineEnumValues(enumClass, names) { | 571 defineEnumValues(enumClass, names) { |
572 var values = []; | 572 var values = []; |
573 for (var i = 0; i < JS('int', '#.length', names); i++) { | 573 for (var i = 0; i < JS('int', '#.length', names); i++) { |
574 var value = const_(JS('', 'new #.new(#)', enumClass, i)); | 574 var value = const_(JS('', 'new #.new(#)', enumClass, i)); |
575 JS('', '#.push(#)', values, value); | 575 JS('', '#.push(#)', values, value); |
576 defineValue(enumClass, JS('', '#[#]', names, i), value); | 576 defineValue(enumClass, JS('', '#[#]', names, i), value); |
577 } | 577 } |
578 JS('', '#.values = #', enumClass, constList(values, enumClass)); | 578 JS('', '#.values = #', enumClass, constList(values, enumClass)); |
579 } | 579 } |
OLD | NEW |