OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart._js_mirrors; | 5 library dart._js_mirrors; |
6 | 6 |
7 import 'dart:_js_embedded_names' show | 7 import 'dart:_js_embedded_names' show |
8 JsGetName, | 8 JsGetName, |
9 ALL_CLASSES, | 9 ALL_CLASSES, |
10 LAZIES, | 10 LAZIES, |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 TypeMirror get type => _target.type; | 1617 TypeMirror get type => _target.type; |
1618 | 1618 |
1619 bool get isOptional => false; | 1619 bool get isOptional => false; |
1620 bool get isNamed => false; | 1620 bool get isNamed => false; |
1621 bool get isStatic => false; | 1621 bool get isStatic => false; |
1622 bool get isTopLevel => false; | 1622 bool get isTopLevel => false; |
1623 bool get isConst => false; | 1623 bool get isConst => false; |
1624 bool get isFinal => true; | 1624 bool get isFinal => true; |
1625 bool get isPrivate => false; | 1625 bool get isPrivate => false; |
1626 bool get hasDefaultValue => false; | 1626 bool get hasDefaultValue => false; |
| 1627 bool get isInitializingFormal => false; |
1627 InstanceMirror get defaultValue => null; | 1628 InstanceMirror get defaultValue => null; |
1628 List<InstanceMirror> get metadata => const []; | 1629 List<InstanceMirror> get metadata => const []; |
1629 SourceLocation get location => throw new UnimplementedError(); | 1630 SourceLocation get location => throw new UnimplementedError(); |
1630 } | 1631 } |
1631 | 1632 |
1632 class JsClassMirror extends JsTypeMirror with JsObjectMirror | 1633 class JsClassMirror extends JsTypeMirror with JsObjectMirror |
1633 implements ClassMirror { | 1634 implements ClassMirror { |
1634 final String _mangledName; | 1635 final String _mangledName; |
1635 final _jsConstructor; | 1636 final _jsConstructor; |
1636 final String _fieldsDescriptor; | 1637 final String _fieldsDescriptor; |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 // Constructors aren't reified with their return type. | 2405 // Constructors aren't reified with their return type. |
2405 if (isConstructor) { | 2406 if (isConstructor) { |
2406 _returnType = owner; | 2407 _returnType = owner; |
2407 } else { | 2408 } else { |
2408 _returnType = type.returnType; | 2409 _returnType = type.returnType; |
2409 } | 2410 } |
2410 int i = 0; | 2411 int i = 0; |
2411 bool isNamed = info.areOptionalParametersNamed; | 2412 bool isNamed = info.areOptionalParametersNamed; |
2412 for (JsParameterMirror parameter in type.parameters) { | 2413 for (JsParameterMirror parameter in type.parameters) { |
2413 var name = info.parameterName(i); | 2414 var name = info.parameterName(i); |
| 2415 bool isInitializingFormal = false; |
| 2416 if (isConstructor) { |
| 2417 isInitializingFormal = info.isFieldInitializerParameter(i); |
| 2418 } |
2414 List<int> annotations = info.parameterMetadataAnnotations(i); | 2419 List<int> annotations = info.parameterMetadataAnnotations(i); |
2415 var p; | 2420 var p; |
2416 if (i < info.requiredParameterCount) { | 2421 if (i < info.requiredParameterCount) { |
2417 p = new JsParameterMirror(name, this, parameter._type, | 2422 p = new JsParameterMirror(name, this, parameter._type, |
2418 metadataList: annotations); | 2423 metadataList: annotations); |
2419 } else { | 2424 } else { |
2420 var defaultValue = info.defaultValue(i); | 2425 var defaultValue = info.defaultValue(i); |
2421 p = new JsParameterMirror( | 2426 p = new JsParameterMirror( |
2422 name, this, parameter._type, metadataList: annotations, | 2427 name, this, parameter._type, metadataList: annotations, |
2423 isOptional: true, isNamed: isNamed, defaultValue: defaultValue); | 2428 isOptional: true, isNamed: isNamed, defaultValue: defaultValue, |
| 2429 isInitializingFormal: isInitializingFormal); |
2424 } | 2430 } |
2425 formals[i++] = p; | 2431 formals[i++] = p; |
2426 } | 2432 } |
2427 } | 2433 } |
2428 _parameters = new UnmodifiableListView<ParameterMirror>(formals); | 2434 _parameters = new UnmodifiableListView<ParameterMirror>(formals); |
2429 _metadata = new UnmodifiableListView(raw.map(reflect)); | 2435 _metadata = new UnmodifiableListView(raw.map(reflect)); |
2430 } | 2436 } |
2431 return _metadata; | 2437 return _metadata; |
2432 } | 2438 } |
2433 | 2439 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 final int _defaultValue; | 2533 final int _defaultValue; |
2528 | 2534 |
2529 final List<int> metadataList; | 2535 final List<int> metadataList; |
2530 | 2536 |
2531 JsParameterMirror(String unmangledName, | 2537 JsParameterMirror(String unmangledName, |
2532 this.owner, | 2538 this.owner, |
2533 this._type, | 2539 this._type, |
2534 {this.metadataList: const <int>[], | 2540 {this.metadataList: const <int>[], |
2535 this.isOptional: false, | 2541 this.isOptional: false, |
2536 this.isNamed: false, | 2542 this.isNamed: false, |
| 2543 this.isInitializingFormal: false, |
2537 defaultValue}) | 2544 defaultValue}) |
2538 : _defaultValue = defaultValue, | 2545 : _defaultValue = defaultValue, |
2539 super(s(unmangledName)); | 2546 super(s(unmangledName)); |
2540 | 2547 |
2541 String get _prettyName => 'ParameterMirror'; | 2548 String get _prettyName => 'ParameterMirror'; |
2542 | 2549 |
2543 TypeMirror get type { | 2550 TypeMirror get type { |
2544 return typeMirrorFromRuntimeTypeRepresentation(owner, _type); | 2551 return typeMirrorFromRuntimeTypeRepresentation(owner, _type); |
2545 } | 2552 } |
2546 | 2553 |
2547 // Only true for static fields, never for a parameter. | 2554 // Only true for static fields, never for a parameter. |
2548 bool get isStatic => false; | 2555 bool get isStatic => false; |
2549 | 2556 |
2550 // TODO(ahe): Implement this. | 2557 // TODO(ahe): Implement this. |
2551 bool get isFinal => false; | 2558 bool get isFinal => false; |
2552 | 2559 |
2553 // TODO(ahe): Implement this. | 2560 // TODO(ahe): Implement this. |
2554 bool get isConst => false; | 2561 bool get isConst => false; |
2555 | 2562 |
| 2563 final bool isInitializingFormal; |
| 2564 |
2556 bool get hasDefaultValue => _defaultValue != null; | 2565 bool get hasDefaultValue => _defaultValue != null; |
2557 | 2566 |
2558 get defaultValue { | 2567 get defaultValue { |
2559 return hasDefaultValue ? reflect(getMetadata(_defaultValue)) : null; | 2568 return hasDefaultValue ? reflect(getMetadata(_defaultValue)) : null; |
2560 } | 2569 } |
2561 | 2570 |
2562 List<InstanceMirror> get metadata { | 2571 List<InstanceMirror> get metadata { |
2563 preserveMetadata(); | 2572 preserveMetadata(); |
2564 return metadataList.map((int i) => reflect(getMetadata(i))).toList(); | 2573 return metadataList.map((int i) => reflect(getMetadata(i))).toList(); |
2565 } | 2574 } |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3063 // have a part (following a '.') that starts with '_'. | 3072 // have a part (following a '.') that starts with '_'. |
3064 const int UNDERSCORE = 0x5f; | 3073 const int UNDERSCORE = 0x5f; |
3065 if (name.isEmpty) return true; | 3074 if (name.isEmpty) return true; |
3066 int index = -1; | 3075 int index = -1; |
3067 do { | 3076 do { |
3068 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; | 3077 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; |
3069 index = name.indexOf('.', index + 1); | 3078 index = name.indexOf('.', index + 1); |
3070 } while (index >= 0 && index + 1 < name.length); | 3079 } while (index >= 0 && index + 1 < name.length); |
3071 return true; | 3080 return true; |
3072 } | 3081 } |
OLD | NEW |