OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 static Handle<Object> Exec(Handle<JSRegExp> regexp, | 60 static Handle<Object> Exec(Handle<JSRegExp> regexp, |
61 Handle<String> subject, | 61 Handle<String> subject, |
62 Handle<Object> index); | 62 Handle<Object> index); |
63 | 63 |
64 // Call RegExp.prototyp.exec(string) in a loop. | 64 // Call RegExp.prototyp.exec(string) in a loop. |
65 // Used by String.prototype.match and String.prototype.replace. | 65 // Used by String.prototype.match and String.prototype.replace. |
66 // This function calls the garbage collector if necessary. | 66 // This function calls the garbage collector if necessary. |
67 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp, | 67 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp, |
68 Handle<String> subject); | 68 Handle<String> subject); |
69 | 69 |
70 // Stores an uncompiled RegExp pattern in the JSRegExp object. | |
71 // It will be compiled by JSCRE when first executed. | |
72 static Handle<Object> JscrePrepare(Handle<JSRegExp> re, | |
73 Handle<String> pattern, | |
74 JSRegExp::Flags flags); | |
75 | |
76 // Prepares a JSRegExp object with Irregexp-specific data. | 70 // Prepares a JSRegExp object with Irregexp-specific data. |
77 static Handle<Object> IrregexpPrepare(Handle<JSRegExp> re, | 71 static Handle<Object> IrregexpPrepare(Handle<JSRegExp> re, |
78 Handle<String> pattern, | 72 Handle<String> pattern, |
79 JSRegExp::Flags flags); | 73 JSRegExp::Flags flags); |
80 | 74 |
81 | 75 |
82 // Compile the pattern using JSCRE and store the result in the | |
83 // JSRegExp object. | |
84 static Handle<Object> JscreCompile(Handle<JSRegExp> re); | |
85 | |
86 static Handle<Object> AtomCompile(Handle<JSRegExp> re, | 76 static Handle<Object> AtomCompile(Handle<JSRegExp> re, |
87 Handle<String> pattern, | 77 Handle<String> pattern, |
88 JSRegExp::Flags flags, | 78 JSRegExp::Flags flags, |
89 Handle<String> match_pattern); | 79 Handle<String> match_pattern); |
90 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, | 80 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, |
91 Handle<String> subject, | 81 Handle<String> subject, |
92 Handle<Object> index); | 82 Handle<Object> index); |
93 | 83 |
94 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp, | 84 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp, |
95 Handle<String> subject); | 85 Handle<String> subject); |
96 | 86 |
97 static Handle<Object> JscreCompile(Handle<JSRegExp> re, | |
98 Handle<String> pattern, | |
99 JSRegExp::Flags flags); | |
100 | |
101 // Execute a compiled JSCRE pattern. | |
102 static Handle<Object> JscreExec(Handle<JSRegExp> regexp, | |
103 Handle<String> subject, | |
104 Handle<Object> index); | |
105 | |
106 // Execute an Irregexp bytecode pattern. | 87 // Execute an Irregexp bytecode pattern. |
107 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, | 88 static Handle<Object> IrregexpExec(Handle<JSRegExp> regexp, |
108 Handle<String> subject, | 89 Handle<String> subject, |
109 Handle<Object> index); | 90 Handle<Object> index); |
110 | 91 |
111 static Handle<Object> JscreExecGlobal(Handle<JSRegExp> regexp, | |
112 Handle<String> subject); | |
113 | |
114 static Handle<Object> IrregexpExecGlobal(Handle<JSRegExp> regexp, | 92 static Handle<Object> IrregexpExecGlobal(Handle<JSRegExp> regexp, |
115 Handle<String> subject); | 93 Handle<String> subject); |
116 | 94 |
117 static void NewSpaceCollectionPrologue(); | 95 static void NewSpaceCollectionPrologue(); |
118 static void OldSpaceCollectionPrologue(); | 96 static void OldSpaceCollectionPrologue(); |
119 | 97 |
120 // Converts a source string to a 16 bit flat string. The string | 98 // Converts a source string to a 16 bit flat string. The string |
121 // will be either sequential or it will be a SlicedString backed | 99 // will be either sequential or it will be a SlicedString backed |
122 // by a flat string. | 100 // by a flat string. |
123 static Handle<String> StringToTwoByte(Handle<String> pattern); | 101 static Handle<String> StringToTwoByte(Handle<String> pattern); |
124 static Handle<String> CachedStringToTwoByte(Handle<String> pattern); | 102 static Handle<String> CachedStringToTwoByte(Handle<String> pattern); |
125 | 103 |
126 static const int kIrregexpImplementationIndex = 0; | 104 static const int kIrregexpImplementationIndex = 0; |
127 static const int kIrregexpNumberOfCapturesIndex = 1; | 105 static const int kIrregexpNumberOfCapturesIndex = 1; |
128 static const int kIrregexpNumberOfRegistersIndex = 2; | 106 static const int kIrregexpNumberOfRegistersIndex = 2; |
129 static const int kIrregexpCodeIndex = 3; | 107 static const int kIrregexpCodeIndex = 3; |
130 static const int kIrregexpDataLength = 4; | 108 static const int kIrregexpDataLength = 4; |
131 | 109 |
132 static const int kJscreNumberOfCapturesIndex = 0; | |
133 static const int kJscreInternalIndex = 1; | |
134 static const int kJscreDataLength = 2; | |
135 | |
136 private: | 110 private: |
137 static String* last_ascii_string_; | 111 static String* last_ascii_string_; |
138 static String* two_byte_cached_string_; | 112 static String* two_byte_cached_string_; |
139 | 113 |
140 static int JscreNumberOfCaptures(Handle<JSRegExp> re); | |
141 static ByteArray* JscreInternal(Handle<JSRegExp> re); | |
142 | |
143 static int IrregexpNumberOfCaptures(Handle<FixedArray> re); | 114 static int IrregexpNumberOfCaptures(Handle<FixedArray> re); |
144 static int IrregexpNumberOfRegisters(Handle<FixedArray> re); | 115 static int IrregexpNumberOfRegisters(Handle<FixedArray> re); |
145 static Handle<ByteArray> IrregexpByteCode(Handle<FixedArray> re); | 116 static Handle<ByteArray> IrregexpByteCode(Handle<FixedArray> re); |
146 static Handle<Code> IrregexpNativeCode(Handle<FixedArray> re); | 117 static Handle<Code> IrregexpNativeCode(Handle<FixedArray> re); |
147 | 118 |
148 // Call jsRegExpExecute once | |
149 static Handle<Object> JscreExecOnce(Handle<JSRegExp> regexp, | |
150 int num_captures, | |
151 Handle<String> subject, | |
152 int previous_index, | |
153 const uc16* utf8_subject, | |
154 int* ovector, | |
155 int ovector_length); | |
156 | |
157 // On a successful match, the result is a JSArray containing | 119 // On a successful match, the result is a JSArray containing |
158 // captured positions. On a failure, the result is the null value. | 120 // captured positions. On a failure, the result is the null value. |
159 // Returns an empty handle in case of an exception. | 121 // Returns an empty handle in case of an exception. |
160 static Handle<Object> IrregexpExecOnce(Handle<FixedArray> regexp, | 122 static Handle<Object> IrregexpExecOnce(Handle<FixedArray> regexp, |
161 int num_captures, | 123 int num_captures, |
162 Handle<String> subject16, | 124 Handle<String> subject16, |
163 int previous_index, | 125 int previous_index, |
164 int* ovector, | 126 int* ovector, |
165 int ovector_length); | 127 int ovector_length); |
166 | 128 |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 Handle<String> pattern, | 1325 Handle<String> pattern, |
1364 bool is_ascii); | 1326 bool is_ascii); |
1365 | 1327 |
1366 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); | 1328 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); |
1367 }; | 1329 }; |
1368 | 1330 |
1369 | 1331 |
1370 } } // namespace v8::internal | 1332 } } // namespace v8::internal |
1371 | 1333 |
1372 #endif // V8_JSREGEXP_H_ | 1334 #endif // V8_JSREGEXP_H_ |
OLD | NEW |