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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 static Handle<Object> JsreExec(Handle<JSRegExp> regexp, | 90 static Handle<Object> JsreExec(Handle<JSRegExp> regexp, |
91 Handle<String> subject, | 91 Handle<String> subject, |
92 Handle<Object> index); | 92 Handle<Object> index); |
93 | 93 |
94 static Handle<Object> JsreExecGlobal(Handle<JSRegExp> regexp, | 94 static Handle<Object> JsreExecGlobal(Handle<JSRegExp> regexp, |
95 Handle<String> subject); | 95 Handle<String> subject); |
96 | 96 |
97 static void NewSpaceCollectionPrologue(); | 97 static void NewSpaceCollectionPrologue(); |
98 static void OldSpaceCollectionPrologue(); | 98 static void OldSpaceCollectionPrologue(); |
99 | 99 |
100 private: | |
101 // Converts a source string to a 16 bit flat string. The string | 100 // Converts a source string to a 16 bit flat string. The string |
102 // will be either sequential or it will be a SlicedString backed | 101 // will be either sequential or it will be a SlicedString backed |
103 // by a flat string. | 102 // by a flat string. |
104 static Handle<String> StringToTwoByte(Handle<String> pattern); | 103 static Handle<String> StringToTwoByte(Handle<String> pattern); |
105 static Handle<String> CachedStringToTwoByte(Handle<String> pattern); | 104 static Handle<String> CachedStringToTwoByte(Handle<String> pattern); |
106 | 105 |
| 106 private: |
107 static String* last_ascii_string_; | 107 static String* last_ascii_string_; |
108 static String* two_byte_cached_string_; | 108 static String* two_byte_cached_string_; |
109 | 109 |
110 // Returns the caputure from the re. | 110 // Returns the caputure from the re. |
111 static int JsreCapture(Handle<JSRegExp> re); | 111 static int JsreCapture(Handle<JSRegExp> re); |
112 static ByteArray* JsreInternal(Handle<JSRegExp> re); | 112 static ByteArray* JsreInternal(Handle<JSRegExp> re); |
113 | 113 |
114 // Call jsRegExpExecute once | 114 // Call jsRegExpExecute once |
115 static Handle<Object> JsreExecOnce(Handle<JSRegExp> regexp, | 115 static Handle<Object> JsreExecOnce(Handle<JSRegExp> regexp, |
116 int num_captures, | 116 int num_captures, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 Key key_; | 239 Key key_; |
240 Value value_; | 240 Value value_; |
241 Node* left_; | 241 Node* left_; |
242 Node* right_; | 242 Node* right_; |
243 }; | 243 }; |
244 | 244 |
245 // A locator provides access to a node in the tree without actually | 245 // A locator provides access to a node in the tree without actually |
246 // exposing the node. | 246 // exposing the node. |
247 class Locator { | 247 class Locator { |
248 public: | 248 public: |
249 Locator(Node* node) : node_(node) { } | 249 explicit Locator(Node* node) : node_(node) { } |
250 Locator() : node_(NULL) { } | 250 Locator() : node_(NULL) { } |
251 const Key& key() { return node_->key_; } | 251 const Key& key() { return node_->key_; } |
252 Value& value() { return node_->value_; } | 252 Value& value() { return node_->value_; } |
253 void set_value(const Value& value) { node_->value_ = value; } | 253 void set_value(const Value& value) { node_->value_ = value; } |
254 inline void bind(Node* node) { node_ = node; } | 254 inline void bind(Node* node) { node_ = node; } |
255 private: | 255 private: |
256 Node* node_; | 256 Node* node_; |
257 }; | 257 }; |
258 | 258 |
259 template <class Callback> | 259 template <class Callback> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 }; | 355 }; |
356 | 356 |
357 | 357 |
358 class RegExpEngine: public AllStatic { | 358 class RegExpEngine: public AllStatic { |
359 public: | 359 public: |
360 static RegExpNode* Compile(RegExpParseResult* input); | 360 static RegExpNode* Compile(RegExpParseResult* input); |
361 static void DotPrint(const char* label, RegExpNode* node); | 361 static void DotPrint(const char* label, RegExpNode* node); |
362 }; | 362 }; |
363 | 363 |
364 | 364 |
| 365 class RegExpCompiler; |
| 366 |
| 367 |
| 368 class RegExpNode: public ZoneObject { |
| 369 public: |
| 370 virtual ~RegExpNode() { } |
| 371 virtual void Accept(NodeVisitor* visitor) = 0; |
| 372 // Generates a goto to this node or actually generates the code at this point. |
| 373 void GoTo(RegExpCompiler* compiler); |
| 374 void EmitAddress(RegExpCompiler* compiler); |
| 375 virtual void Emit(RegExpCompiler* compiler) = 0; |
| 376 private: |
| 377 Label label; |
| 378 }; |
| 379 |
| 380 |
365 } } // namespace v8::internal | 381 } } // namespace v8::internal |
366 | 382 |
367 #endif // V8_JSREGEXP_H_ | 383 #endif // V8_JSREGEXP_H_ |
OLD | NEW |