Chromium Code Reviews| Index: dart/sdk/lib/_internal/lib/js_mirrors.dart |
| diff --git a/dart/sdk/lib/_internal/lib/js_mirrors.dart b/dart/sdk/lib/_internal/lib/js_mirrors.dart |
| index 1d1c8252fed426f891210c316e3cb13bec3450d8..e31eefedcebb5fd71c683083f2d5740a5cb30bac 100644 |
| --- a/dart/sdk/lib/_internal/lib/js_mirrors.dart |
| +++ b/dart/sdk/lib/_internal/lib/js_mirrors.dart |
| @@ -448,7 +448,6 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror |
| var prototype = JS('', '#.prototype', _jsConstructor); |
| List<String> keys = extractKeys(prototype); |
| var result = <JsMethodMirror>[]; |
| - int i = 0; |
| for (String key in keys) { |
| if (key == '') continue; |
| String simpleName = mangledNames[key]; |
| @@ -478,10 +477,17 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror |
| } |
| Map<Symbol, MethodMirror> get getters { |
| - // TODO(ahe): Should this include getters for fields? |
| + // TODO(ahe): This is a hack to remove getters corresponding to a field. |
|
ngeoffray
2013/07/17 07:20:03
Why do you add this local? The TODO line 487 could
ahe
2013/07/17 07:38:32
That would be slow as variables create a new map e
ngeoffray
2013/07/17 07:42:42
Expensive getters for the win :) Is that the mirro
ahe
2013/07/17 08:00:36
Actually, the specification says "immutable map".
|
| + var fields = variables; |
| + |
| var result = new Map<Symbol, MethodMirror>(); |
| for (JsMethodMirror method in _methods) { |
| if (method.isGetter) { |
| + |
| + // TODO(ahe): This is a hack to remove getters corresponding to a field. |
| + String name = n(method.simpleName); |
| + if (fields[s(name)] != null) continue; |
| + |
| result[method.simpleName] = method; |
| } |
| } |
| @@ -489,10 +495,18 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror |
| } |
| Map<Symbol, MethodMirror> get setters { |
| - // TODO(ahe): Should this include setters for fields? |
| + // TODO(ahe): This is a hack to remove setters corresponding to a field. |
|
ngeoffray
2013/07/17 07:20:03
ditto.
|
| + var fields = variables; |
| + |
| var result = new Map<Symbol, MethodMirror>(); |
| for (JsMethodMirror method in _methods) { |
| if (method.isSetter) { |
| + |
| + // TODO(ahe): This is a hack to remove setters corresponding to a field. |
| + String name = n(method.simpleName); |
| + name = name.substring(0, name.length - 1); // Remove '='. |
| + if (fields[s(name)] != null) continue; |
| + |
| result[method.simpleName] = method; |
| } |
| } |
| @@ -509,10 +523,10 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror |
| if (_fieldsMetadata != null) { |
| metadata = _fieldsMetadata[fieldNumber++]; |
| } |
| - JsVariableMirror mirror = new JsVariableMirror.from(field, metadata); |
| + JsVariableMirror mirror = |
| + new JsVariableMirror.from(field, metadata, this); |
| if (mirror != null) { |
| result[mirror.simpleName] = mirror; |
| - mirror._owner = this; |
| } |
| } |
| return result; |
| @@ -646,17 +660,20 @@ class JsVariableMirror extends JsDeclarationMirror implements VariableMirror { |
| final bool isFinal; |
| final bool isStatic; |
| final _metadataFunction; |
| - DeclarationMirror _owner; |
| + final DeclarationMirror _owner; |
| List _metadata; |
| JsVariableMirror(Symbol simpleName, |
| this._jsName, |
| this.isFinal, |
| this.isStatic, |
| - this._metadataFunction) |
| + this._metadataFunction, |
| + this._owner) |
| : super(simpleName); |
| - factory JsVariableMirror.from(String descriptor, metadataFunction) { |
| + factory JsVariableMirror.from(String descriptor, |
| + metadataFunction, |
| + JsClassMirror owner) { |
| int length = descriptor.length; |
| var code = fieldCode(descriptor.codeUnitAt(length - 1)); |
| bool isFinal = false; |
| @@ -672,8 +689,18 @@ class JsVariableMirror extends JsDeclarationMirror implements VariableMirror { |
| accessorName = accessorName.substring(0, divider); |
| jsName = accessorName.substring(divider + 1); |
| } |
| + if (!hasSetter) { |
| + // TODO(ahe): This is a hack to handle checked setters in checked mode. |
| + var setterName = s('$accessorName='); |
| + for (JsMethodMirror method in owner._methods) { |
| + if (method.simpleName == setterName) { |
| + isFinal = false; |
| + break; |
| + } |
| + } |
| + } |
| return new JsVariableMirror( |
| - s(accessorName), jsName, isFinal, false, metadataFunction); |
| + s(accessorName), jsName, isFinal, false, metadataFunction, owner); |
| } |
| String get _prettyName => 'VariableMirror'; |