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

Side by Side Diff: frog/leg/lib/regexp_helper.dart

Issue 9873021: Move frog/leg to lib/compiler/implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/leg/lib/native_helper.dart ('k') | frog/leg/lib/string_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 List regExpExec(JSSyntaxRegExp regExp, String str) {
6 var nativeRegExp = regExpGetNative(regExp);
7 var result = JS('List', @'#.exec(#)', nativeRegExp, str);
8 if (JS('bool', @'# === null', result)) return null;
9 return result;
10 }
11
12 bool regExpTest(JSSyntaxRegExp regExp, String str) {
13 var nativeRegExp = regExpGetNative(regExp);
14 return JS('bool', @'#.test(#)', nativeRegExp, str);
15 }
16
17 regExpGetNative(JSSyntaxRegExp regExp) {
18 var r = JS('var', @'#._re', regExp);
19 if (r === null) {
20 r = JS('var', @'#._re = #', regExp, regExpMakeNative(regExp));
21 }
22 return r;
23 }
24
25 regExpAttachGlobalNative(JSSyntaxRegExp regExp) {
26 JS('var', @'#._re = #', regExp, regExpMakeNative(regExp, global: true));
27 }
28
29 regExpMakeNative(JSSyntaxRegExp regExp, [bool global = false]) {
30 String pattern = regExp.pattern;
31 bool multiLine = regExp.multiLine;
32 bool ignoreCase = regExp.ignoreCase;
33 checkString(pattern);
34 StringBuffer sb = new StringBuffer();
35 if (multiLine) sb.add('m');
36 if (ignoreCase) sb.add('i');
37 if (global) sb.add('g');
38 try {
39 return JS('Object', @'new RegExp(#, #)', pattern, sb.toString());
40 } catch (var e) {
41 throw new IllegalJSRegExpException(pattern,
42 JS('String', @'String(#)', e));
43 }
44 }
45
46 int regExpMatchStart(m) => JS('int', @'#.index', m);
OLDNEW
« no previous file with comments | « frog/leg/lib/native_helper.dart ('k') | frog/leg/lib/string_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698