Chromium Code Reviews| Index: frog/lib/isolate.dart |
| =================================================================== |
| --- frog/lib/isolate.dart (revision 4497) |
| +++ frog/lib/isolate.dart (working copy) |
| @@ -757,7 +757,7 @@ |
| return runnable.constructor.name; |
| """; |
| - /** Find a constructor given it's name. */ |
| + /** Find a constructor given its name. */ |
|
Siggi Cherem (dart-lang)
2012/02/22 23:46:49
thx :)
|
| static var _getJSConstructorFromName(String factoryName) native """ |
| return \$globalThis[factoryName]; |
| """; |
| @@ -766,7 +766,25 @@ |
| return \$globalThis[functionName]; |
| """; |
| - static String _getJSFunctionName(Function f) native "return f.name || null;"; |
| + /** Get a string name for the function, if possible. The result for |
|
Siggi Cherem (dart-lang)
2012/02/22 23:46:49
(nit) style of the comment block: if it's multilin
eub
2012/02/23 00:00:12
Done.
|
| + * anonymous functions is browser-dependent -- it may be "" or "anonymous" |
| + * but you should probably not count on this. */ |
| + static String _getJSFunctionName(Function f) native """ |
|
kasperl
2012/02/23 06:53:35
Can't we simplify this whole thing by not using .n
Siggi Cherem (dart-lang)
2012/02/23 17:13:23
Yes, we debated a bit about this, and were afraid
kasperl
2012/02/27 11:28:24
Option (c) sounds good to me. That should be even
|
| + // Are we in a browser that implements the non-standard but |
| + // oh-so-convenient function .name property? |
|
Siggi Cherem (dart-lang)
2012/02/22 23:46:49
some of these comments are useful, but note that c
eub
2012/02/23 00:00:12
Removed a little chatter, and moved the implementa
|
| + if (typeof(f.name) === 'undefined') { |
| + // No. Parse the name out of toString()! |
| + // |
| + // When there is a match, our capture is element 1 of the results list. |
| + // If there is no match, match() returns null; we || this to a list |
| + // whose element 1 is null so everything lines up without error. |
| + // (Double-backslash in this string gives a backslash in the native JS.) |
| + return (f.toString().match(/function (.+)\\(/) || [, null])[1]; |
| + } else { |
| + // Yes. Use .name property. |
| + return f.name || null; |
| + } |
| + """; |
| /** Create a new JavasSript object instance given it's constructor. */ |
| static var _allocate(var ctor) native "return new ctor();"; |