| 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 30 matching lines...) Expand all Loading... |
| 41 static Handle<Object> CreateRegExpLiteral(Handle<JSFunction> constructor, | 41 static Handle<Object> CreateRegExpLiteral(Handle<JSFunction> constructor, |
| 42 Handle<String> pattern, | 42 Handle<String> pattern, |
| 43 Handle<String> flags, | 43 Handle<String> flags, |
| 44 bool* has_pending_exception); | 44 bool* has_pending_exception); |
| 45 | 45 |
| 46 // Returns a string representation of a regular expression. | 46 // Returns a string representation of a regular expression. |
| 47 // Implements RegExp.prototype.toString, see ECMA-262 section 15.10.6.4. | 47 // Implements RegExp.prototype.toString, see ECMA-262 section 15.10.6.4. |
| 48 // This function calls the garbage collector if necessary. | 48 // This function calls the garbage collector if necessary. |
| 49 static Handle<String> ToString(Handle<Object> value); | 49 static Handle<String> ToString(Handle<Object> value); |
| 50 | 50 |
| 51 // Parses the RegExp pattern and prepares the JSRegExp object with |
| 52 // generic data and choice of implementation - as well as what |
| 53 // the implementation wants to store in the data field. |
| 51 static Handle<Object> Compile(Handle<JSRegExp> re, | 54 static Handle<Object> Compile(Handle<JSRegExp> re, |
| 52 Handle<String> pattern, | 55 Handle<String> pattern, |
| 53 Handle<String> flags); | 56 Handle<String> flags); |
| 54 | 57 |
| 55 // Implements RegExp.prototype.exec(string) function. | 58 // Implements RegExp.prototype.exec(string) function. |
| 56 // See ECMA-262 section 15.10.6.2. | 59 // See ECMA-262 section 15.10.6.2. |
| 57 // This function calls the garbage collector if necessary. | 60 // This function calls the garbage collector if necessary. |
| 58 static Handle<Object> Exec(Handle<JSRegExp> regexp, | 61 static Handle<Object> Exec(Handle<JSRegExp> regexp, |
| 59 Handle<String> subject, | 62 Handle<String> subject, |
| 60 Handle<Object> index); | 63 Handle<Object> index); |
| 61 | 64 |
| 62 // Call RegExp.prototyp.exec(string) in a loop. | 65 // Call RegExp.prototyp.exec(string) in a loop. |
| 63 // Used by String.prototype.match and String.prototype.replace. | 66 // Used by String.prototype.match and String.prototype.replace. |
| 64 // This function calls the garbage collector if necessary. | 67 // This function calls the garbage collector if necessary. |
| 65 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp, | 68 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp, |
| 66 Handle<String> subject); | 69 Handle<String> subject); |
| 67 | 70 |
| 68 // Stores an uncompiled RegExp pattern in the JSRegExp object. | 71 // Stores an uncompiled RegExp pattern in the JSRegExp object. |
| 69 // It will be compiled by JSCRE when first executed. | 72 // It will be compiled by JSCRE when first executed. |
| 70 static Handle<Object> JscrePrepare(Handle<JSRegExp> re, | 73 static Handle<Object> JscrePrepare(Handle<JSRegExp> re, |
| 71 Handle<String> pattern, | 74 Handle<String> pattern, |
| 72 JSRegExp::Flags flags); | 75 JSRegExp::Flags flags); |
| 73 | 76 |
| 74 // Stores a compiled RegExp pattern in the JSRegExp object. | 77 // Prepares a JSRegExp object with Irregexp-specific data. |
| 75 // The pattern is compiled by Irregexp. | |
| 76 static Handle<Object> IrregexpPrepare(Handle<JSRegExp> re, | 78 static Handle<Object> IrregexpPrepare(Handle<JSRegExp> re, |
| 77 Handle<String> pattern, | 79 Handle<String> pattern, |
| 78 JSRegExp::Flags flags, | 80 JSRegExp::Flags flags); |
| 79 Handle<FixedArray> irregexp_data); | |
| 80 | 81 |
| 81 | 82 |
| 82 // Compile the pattern using JSCRE and store the result in the | 83 // Compile the pattern using JSCRE and store the result in the |
| 83 // JSRegExp object. | 84 // JSRegExp object. |
| 84 static Handle<Object> JscreCompile(Handle<JSRegExp> re); | 85 static Handle<Object> JscreCompile(Handle<JSRegExp> re); |
| 85 | 86 |
| 86 static Handle<Object> AtomCompile(Handle<JSRegExp> re, | 87 static Handle<Object> AtomCompile(Handle<JSRegExp> re, |
| 87 Handle<String> pattern, | 88 Handle<String> pattern, |
| 88 JSRegExp::Flags flags, | 89 JSRegExp::Flags flags, |
| 89 Handle<String> match_pattern); | 90 Handle<String> match_pattern); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 static const int kJscreInternalIndex = 1; | 134 static const int kJscreInternalIndex = 1; |
| 134 static const int kJscreDataLength = 2; | 135 static const int kJscreDataLength = 2; |
| 135 | 136 |
| 136 private: | 137 private: |
| 137 static String* last_ascii_string_; | 138 static String* last_ascii_string_; |
| 138 static String* two_byte_cached_string_; | 139 static String* two_byte_cached_string_; |
| 139 | 140 |
| 140 static int JscreNumberOfCaptures(Handle<JSRegExp> re); | 141 static int JscreNumberOfCaptures(Handle<JSRegExp> re); |
| 141 static ByteArray* JscreInternal(Handle<JSRegExp> re); | 142 static ByteArray* JscreInternal(Handle<JSRegExp> re); |
| 142 | 143 |
| 143 static int IrregexpNumberOfCaptures(Handle<JSRegExp> re); | 144 static int IrregexpNumberOfCaptures(Handle<FixedArray> re); |
| 144 static int IrregexpNumberOfRegisters(Handle<JSRegExp> re); | 145 static int IrregexpNumberOfRegisters(Handle<FixedArray> re); |
| 145 static Handle<ByteArray> IrregexpCode(Handle<JSRegExp> re); | 146 static Handle<ByteArray> IrregexpByteCode(Handle<FixedArray> re); |
| 147 static Handle<Code> IrregexpNativeCode(Handle<FixedArray> re); |
| 146 | 148 |
| 147 // Call jsRegExpExecute once | 149 // Call jsRegExpExecute once |
| 148 static Handle<Object> JscreExecOnce(Handle<JSRegExp> regexp, | 150 static Handle<Object> JscreExecOnce(Handle<JSRegExp> regexp, |
| 149 int num_captures, | 151 int num_captures, |
| 150 Handle<String> subject, | 152 Handle<String> subject, |
| 151 int previous_index, | 153 int previous_index, |
| 152 const uc16* utf8_subject, | 154 const uc16* utf8_subject, |
| 153 int* ovector, | 155 int* ovector, |
| 154 int ovector_length); | 156 int ovector_length); |
| 155 | 157 |
| 156 static Handle<Object> IrregexpExecOnce(Handle<JSRegExp> regexp, | 158 static Handle<Object> IrregexpExecOnce(Handle<FixedArray> regexp, |
| 157 int num_captures, | 159 int num_captures, |
| 158 Handle<String> subject16, | 160 Handle<String> subject16, |
| 159 int previous_index, | 161 int previous_index, |
| 160 int* ovector, | 162 int* ovector, |
| 161 int ovector_length); | 163 int ovector_length); |
| 162 | 164 |
| 163 // Set the subject cache. The previous string buffer is not deleted, so the | 165 // Set the subject cache. The previous string buffer is not deleted, so the |
| 164 // caller should ensure that it doesn't leak. | 166 // caller should ensure that it doesn't leak. |
| 165 static void SetSubjectCache(String* subject, | 167 static void SetSubjectCache(String* subject, |
| 166 char* utf8_subject, | 168 char* utf8_subject, |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 int capture_count; | 1077 int capture_count; |
| 1076 }; | 1078 }; |
| 1077 | 1079 |
| 1078 | 1080 |
| 1079 class RegExpEngine: public AllStatic { | 1081 class RegExpEngine: public AllStatic { |
| 1080 public: | 1082 public: |
| 1081 static Handle<FixedArray> Compile(RegExpParseResult* input, | 1083 static Handle<FixedArray> Compile(RegExpParseResult* input, |
| 1082 RegExpNode** node_return, | 1084 RegExpNode** node_return, |
| 1083 bool ignore_case, | 1085 bool ignore_case, |
| 1084 bool multiline, | 1086 bool multiline, |
| 1085 Handle<String> pattern); | 1087 Handle<String> pattern, |
| 1088 bool is_ascii); |
| 1089 |
| 1086 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); | 1090 static void DotPrint(const char* label, RegExpNode* node, bool ignore_case); |
| 1087 }; | 1091 }; |
| 1088 | 1092 |
| 1089 | 1093 |
| 1090 } } // namespace v8::internal | 1094 } } // namespace v8::internal |
| 1091 | 1095 |
| 1092 #endif // V8_JSREGEXP_H_ | 1096 #endif // V8_JSREGEXP_H_ |
| OLD | NEW |