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

Unified Diff: sdk/lib/_internal/js_runtime/lib/regexp_helper.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_names.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/regexp_helper.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/regexp_helper.dart b/sdk/lib/_internal/js_runtime/lib/regexp_helper.dart
index 9b44116c08cb9de956679643545747993d6e6b04..35a42d1ce00240ac3f2c7fc89e91651b4944e520 100644
--- a/sdk/lib/_internal/js_runtime/lib/regexp_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/regexp_helper.dart
@@ -85,23 +85,24 @@ class JSSyntaxRegExp implements RegExp {
String m = multiLine == true ? 'm' : '';
String i = caseSensitive == true ? '' : 'i';
String g = global ? 'g' : '';
- // We're using the JavaScript's try catch instead of the Dart one
- // to avoid dragging in Dart runtime support just because of using
- // RegExp.
+ // We're using the JavaScript's try catch instead of the Dart one to avoid
+ // dragging in Dart runtime support just because of using RegExp.
var regexp = JS('',
- '(function() {'
- 'try {'
- 'return new RegExp(#, # + # + #);'
- '} catch (e) {'
- 'return e;'
- '}'
- '})()', source, m, i, g);
+ r'''
+ (function(source, modifiers) {
+ try {
+ return new RegExp(source, modifiers);
+ } catch (e) {
+ return e;
+ }
+ })(#, # + # + #)''',
+ source, m, i, g);
if (JS('bool', '# instanceof RegExp', regexp)) return regexp;
// The returned value is the JavaScript exception. Turn it into a
// Dart exception.
String errorMessage = JS('String', r'String(#)', regexp);
throw new FormatException(
- "Illegal RegExp pattern ($errorMessage)", source);
+ 'Illegal RegExp pattern ($errorMessage)', source);
}
Match firstMatch(String string) {
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_names.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698