Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: sdk/lib/_internal/js_runtime/lib/js_mirrors.dart

Issue 1436263002: dart2js: Forbid # placeholders in JS function bodies. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_helper.dart ('k') | sdk/lib/_internal/js_runtime/lib/js_names.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/js_mirrors.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/js_mirrors.dart b/sdk/lib/_internal/js_runtime/lib/js_mirrors.dart
index fc78e7287cbdbf3f445e2dc5c9dfafb7ff2420fa..4cbb163b760ca63d9b38a0c1118c1c055ad58658 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_mirrors.dart
@@ -2245,19 +2245,25 @@ class JsClosureMirror extends JsInstanceMirror implements ClosureMirror {
disableTreeShaking();
// TODO(ahe): What about optional parameters (named or not).
String callPrefix = "${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$";
- var extractCallName = JS('', r'''
-function(reflectee) {
- var properties = Object.keys(reflectee.constructor.prototype);
- for (var i = 0; i < properties.length; i++) {
- var property = properties[i];
- if (# == property.substring(0, #) &&
- property[#] >= '0' &&
- property[#] <= '9') return property;
- }
- return null;
-}
-''', callPrefix, callPrefix.length, callPrefix.length, callPrefix.length);
- String callName = JS('String|Null', '#(#)', extractCallName, reflectee);
+
+ String callName = JS(
+ 'String|Null',
+ r'''
+ (function(reflectee, callPrefix) {
+ var properties = Object.keys(reflectee.constructor.prototype);
+ var callPrefixLength = callPrefix.length;
+ for (var i = 0; i < properties.length; i++) {
+ var property = properties[i];
+ if (callPrefix == property.substring(0, callPrefixLength) &&
+ property[callPrefixLength] >= "0" &&
+ property[callPrefixLength] <= "9") {
+ return property;
+ }
+ }
+ return null;
+ })(#, #)''',
+ reflectee, callPrefix);
+
if (callName == null) {
throw new RuntimeError('Cannot find callName on "$reflectee"');
}
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_helper.dart ('k') | sdk/lib/_internal/js_runtime/lib/js_names.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698