| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_REGEXP_CODEGEN_H_ | 28 #ifndef V8_REGEXP_MACRO_ASSEMBLER_H_ |
| 29 #define V8_REGEXP_CODEGEN_H_ | 29 #define V8_REGEXP_MACRO_ASSEMBLER_H_ |
| 30 | 30 |
| 31 namespace v8 { namespace internal { | 31 namespace v8 { namespace internal { |
| 32 | 32 |
| 33 | 33 |
| 34 struct DisjunctDecisionRow { | 34 struct DisjunctDecisionRow { |
| 35 RegExpCharacterClass cc; | 35 RegExpCharacterClass cc; |
| 36 Label* on_match; | 36 Label* on_match; |
| 37 int actions; | 37 int actions; |
| 38 }; | 38 }; |
| 39 | 39 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 static const int kAdvanceCurrentPosition = 0x20; | 56 static const int kAdvanceCurrentPosition = 0x20; |
| 57 // Push the label that is given in another argument onto the backtrack stack. | 57 // Push the label that is given in another argument onto the backtrack stack. |
| 58 static const int kPushBacktrackState = 0x40; | 58 static const int kPushBacktrackState = 0x40; |
| 59 // The entire regexp has succeeded. | 59 // The entire regexp has succeeded. |
| 60 static const int kSuccess = 0x80; | 60 static const int kSuccess = 0x80; |
| 61 // The entire regexp has failed to match. | 61 // The entire regexp has failed to match. |
| 62 static const int kFailure = 0x100; | 62 static const int kFailure = 0x100; |
| 63 | 63 |
| 64 | 64 |
| 65 template <typename SubjectChar> | 65 template <typename SubjectChar> |
| 66 class RegexpCodeGenerator { | 66 class RegexpMacroAssembler { |
| 67 public: | 67 public: |
| 68 RegexpCodeGenerator() { } | 68 RegexpMacroAssembler() { } |
| 69 virtual ~RegexpCodeGenerator() { } | 69 virtual ~RegexpMacroAssembler() { } |
| 70 virtual void Bind(Label* label) = 0; | 70 virtual void Bind(Label* label) = 0; |
| 71 // Writes the current position in the subject string into the given index of | 71 // Writes the current position in the subject string into the given index of |
| 72 // the captures array. The old value is pushed to the stack. | 72 // the captures array. The old value is pushed to the stack. |
| 73 virtual void WriteCaptureInfo(int index) = 0; | 73 virtual void WriteCurrentPositionToRegister(int index) = 0; |
| 74 // Pops the the given index of the capture array from the stack. | 74 // Pops the the given index of the capture array from the stack. |
| 75 virtual void PopCaptureInfo(int index) = 0; | 75 virtual void PopRegister(int index) = 0; |
| 76 // Pushes the current position in the subject string onto the stack for later | 76 // Pushes the current position in the subject string onto the stack for later |
| 77 // retrieval. | 77 // retrieval. |
| 78 virtual void PushCurrentPosition() = 0; | 78 virtual void PushCurrentPosition() = 0; |
| 79 // Pops the current position in the subject string. | 79 // Pops the current position in the subject string. |
| 80 virtual void PopCurrentPosition() = 0; | 80 virtual void PopCurrentPosition() = 0; |
| 81 // Check the current character for a match with a character class. Take | 81 // Check the current character for a match with a character class. Take |
| 82 // one of the actions depending on whether there is a match. | 82 // one of the actions depending on whether there is a match. |
| 83 virtual void AdvanceCurrentPosition(int by) = 0; | 83 virtual void AdvanceCurrentPosition(int by) = 0; |
| 84 // Looks at the next character from the subject and performs the corresponding | 84 // Looks at the next character from the subject and performs the corresponding |
| 85 // action according to whether it matches. Success_action can only be one of | 85 // action according to whether it matches. Success_action can only be one of |
| (...skipping 19 matching lines...) Expand all Loading... |
| 105 // classes it is in. Perform the corresponding actions on the corresponding | 105 // classes it is in. Perform the corresponding actions on the corresponding |
| 106 // label. | 106 // label. |
| 107 virtual void DisjunctCharacterPeekDispatch( | 107 virtual void DisjunctCharacterPeekDispatch( |
| 108 Vector<DisjunctDecisionRow> outcomes) = 0; | 108 Vector<DisjunctDecisionRow> outcomes) = 0; |
| 109 private: | 109 private: |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 | 112 |
| 113 } } // namespace v8::internal | 113 } } // namespace v8::internal |
| 114 | 114 |
| 115 #endif // V8_REGEXP_CODEGEN_H_ | 115 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ |
| OLD | NEW |