OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_REGEXP_JSREGEXP_H_ | 5 #ifndef V8_REGEXP_JSREGEXP_H_ |
6 #define V8_REGEXP_JSREGEXP_H_ | 6 #define V8_REGEXP_JSREGEXP_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/regexp/regexp-ast.h" | 10 #include "src/regexp/regexp-ast.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 class NodeVisitor; | 15 class NodeVisitor; |
16 class RegExpCompiler; | 16 class RegExpCompiler; |
17 class RegExpMacroAssembler; | 17 class RegExpMacroAssembler; |
18 class RegExpNode; | 18 class RegExpNode; |
19 class RegExpTree; | 19 class RegExpTree; |
20 class BoyerMooreLookahead; | 20 class BoyerMooreLookahead; |
21 | 21 |
| 22 |
| 23 static const uc32 kLeadSurrogateStart = 0xd800; |
| 24 static const uc32 kLeadSurrogateEnd = 0xdbff; |
| 25 static const uc32 kTrailSurrogateStart = 0xdc00; |
| 26 static const uc32 kTrailSurrogateEnd = 0xdfff; |
| 27 static const uc32 kNonBmpStart = 0x10000; |
| 28 static const uc32 kNonBmpEnd = 0x10ffff; |
| 29 |
| 30 |
22 class RegExpImpl { | 31 class RegExpImpl { |
23 public: | 32 public: |
24 // Whether V8 is compiled with native regexp support or not. | 33 // Whether V8 is compiled with native regexp support or not. |
25 static bool UsesNativeRegExp() { | 34 static bool UsesNativeRegExp() { |
26 #ifdef V8_INTERPRETED_REGEXP | 35 #ifdef V8_INTERPRETED_REGEXP |
27 return false; | 36 return false; |
28 #else | 37 #else |
29 return true; | 38 return true; |
30 #endif | 39 #endif |
31 } | 40 } |
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 // has to check if it succeeds a word or non-word. In this case the | 1480 // has to check if it succeeds a word or non-word. In this case the |
1472 // result will be something like: | 1481 // result will be something like: |
1473 // | 1482 // |
1474 // +-------+ +------------+ | 1483 // +-------+ +------------+ |
1475 // | . | | . | | 1484 // | . | | . | |
1476 // +-------+ ---> +------------+ | 1485 // +-------+ ---> +------------+ |
1477 // | word? | | check word | | 1486 // | word? | | check word | |
1478 // +-------+ +------------+ | 1487 // +-------+ +------------+ |
1479 class Analysis: public NodeVisitor { | 1488 class Analysis: public NodeVisitor { |
1480 public: | 1489 public: |
1481 Analysis(Isolate* isolate, bool ignore_case, bool is_one_byte) | 1490 Analysis(Isolate* isolate, JSRegExp::Flags flags, bool is_one_byte) |
1482 : isolate_(isolate), | 1491 : isolate_(isolate), |
1483 ignore_case_(ignore_case), | 1492 flags_(flags), |
1484 is_one_byte_(is_one_byte), | 1493 is_one_byte_(is_one_byte), |
1485 error_message_(NULL) {} | 1494 error_message_(NULL) {} |
1486 void EnsureAnalyzed(RegExpNode* node); | 1495 void EnsureAnalyzed(RegExpNode* node); |
1487 | 1496 |
1488 #define DECLARE_VISIT(Type) \ | 1497 #define DECLARE_VISIT(Type) \ |
1489 virtual void Visit##Type(Type##Node* that); | 1498 virtual void Visit##Type(Type##Node* that); |
1490 FOR_EACH_NODE_TYPE(DECLARE_VISIT) | 1499 FOR_EACH_NODE_TYPE(DECLARE_VISIT) |
1491 #undef DECLARE_VISIT | 1500 #undef DECLARE_VISIT |
1492 virtual void VisitLoopChoice(LoopChoiceNode* that); | 1501 virtual void VisitLoopChoice(LoopChoiceNode* that); |
1493 | 1502 |
1494 bool has_failed() { return error_message_ != NULL; } | 1503 bool has_failed() { return error_message_ != NULL; } |
1495 const char* error_message() { | 1504 const char* error_message() { |
1496 DCHECK(error_message_ != NULL); | 1505 DCHECK(error_message_ != NULL); |
1497 return error_message_; | 1506 return error_message_; |
1498 } | 1507 } |
1499 void fail(const char* error_message) { | 1508 void fail(const char* error_message) { |
1500 error_message_ = error_message; | 1509 error_message_ = error_message; |
1501 } | 1510 } |
1502 | 1511 |
1503 Isolate* isolate() const { return isolate_; } | 1512 Isolate* isolate() const { return isolate_; } |
1504 | 1513 |
| 1514 bool ignore_case() const { return (flags_ & JSRegExp::kIgnoreCase) != 0; } |
| 1515 bool unicode() const { return (flags_ & JSRegExp::kUnicode) != 0; } |
| 1516 |
1505 private: | 1517 private: |
1506 Isolate* isolate_; | 1518 Isolate* isolate_; |
1507 bool ignore_case_; | 1519 JSRegExp::Flags flags_; |
1508 bool is_one_byte_; | 1520 bool is_one_byte_; |
1509 const char* error_message_; | 1521 const char* error_message_; |
1510 | 1522 |
1511 DISALLOW_IMPLICIT_CONSTRUCTORS(Analysis); | 1523 DISALLOW_IMPLICIT_CONSTRUCTORS(Analysis); |
1512 }; | 1524 }; |
1513 | 1525 |
1514 | 1526 |
1515 struct RegExpCompileData { | 1527 struct RegExpCompileData { |
1516 RegExpCompileData() | 1528 RegExpCompileData() |
1517 : tree(NULL), | 1529 : tree(NULL), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 static const int kStringOffset = 0; | 1588 static const int kStringOffset = 0; |
1577 static const int kPatternOffset = 1; | 1589 static const int kPatternOffset = 1; |
1578 static const int kArrayOffset = 2; | 1590 static const int kArrayOffset = 2; |
1579 static const int kLastMatchOffset = 3; | 1591 static const int kLastMatchOffset = 3; |
1580 }; | 1592 }; |
1581 | 1593 |
1582 } // namespace internal | 1594 } // namespace internal |
1583 } // namespace v8 | 1595 } // namespace v8 |
1584 | 1596 |
1585 #endif // V8_REGEXP_JSREGEXP_H_ | 1597 #endif // V8_REGEXP_JSREGEXP_H_ |
OLD | NEW |