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:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'dart:collection' show | 9 import 'dart:collection' show |
10 UnmodifiableListView, | 10 UnmodifiableListView, |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 String unmangledName = mangledGlobalNames[name]; | 419 String unmangledName = mangledGlobalNames[name]; |
420 if (unmangledName == null || | 420 if (unmangledName == null || |
421 JS('bool', "!!#['\$getterStub']", jsFunction)) { | 421 JS('bool', "!!#['\$getterStub']", jsFunction)) { |
422 // If there is no unmangledName, [jsFunction] is either a synthetic | 422 // If there is no unmangledName, [jsFunction] is either a synthetic |
423 // implementation detail, or something that is excluded | 423 // implementation detail, or something that is excluded |
424 // by @MirrorsUsed. | 424 // by @MirrorsUsed. |
425 // If it has a getterStub property it is a synthetic stub. | 425 // If it has a getterStub property it is a synthetic stub. |
426 // TODO(floitsch): Remove the getterStub hack. | 426 // TODO(floitsch): Remove the getterStub hack. |
427 continue; | 427 continue; |
428 } | 428 } |
429 bool isConstructor = unmangledName.startsWith('new '); | 429 bool isStatic = true; |
430 bool isStatic = !isConstructor; // Top-level functions are static, but | 430 bool isConstructor = false; |
431 // constructors are not. | |
432 if (isConstructor) { | |
433 unmangledName = unmangledName.substring(4).replaceAll(r'$', '.'); | |
434 } | |
435 JsMethodMirror mirror = | 431 JsMethodMirror mirror = |
436 new JsMethodMirror.fromUnmangledName( | 432 new JsMethodMirror.fromUnmangledName( |
437 unmangledName, jsFunction, isStatic, isConstructor); | 433 unmangledName, jsFunction, isStatic, isConstructor); |
438 result.add(mirror); | 434 result.add(mirror); |
439 mirror._owner = this; | 435 mirror._owner = this; |
440 } | 436 } |
441 return _cachedFunctionMirrors = result; | 437 return _cachedFunctionMirrors = result; |
442 } | 438 } |
443 | 439 |
444 List<VariableMirror> get _fields { | 440 List<VariableMirror> get _fields { |
(...skipping 2471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 // have a part (following a '.') that starts with '_'. | 2912 // have a part (following a '.') that starts with '_'. |
2917 const int UNDERSCORE = 0x5f; | 2913 const int UNDERSCORE = 0x5f; |
2918 if (name.isEmpty) return true; | 2914 if (name.isEmpty) return true; |
2919 int index = -1; | 2915 int index = -1; |
2920 do { | 2916 do { |
2921 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; | 2917 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; |
2922 index = name.indexOf('.', index + 1); | 2918 index = name.indexOf('.', index + 1); |
2923 } while (index >= 0 && index + 1 < name.length); | 2919 } while (index >= 0 && index + 1 < name.length); |
2924 return true; | 2920 return true; |
2925 } | 2921 } |
OLD | NEW |