Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: src/regexp-codegen.h

Issue 9690: Rename codegen to macro-assembler.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28 #ifndef V8_REGEXP_CODEGEN_H_
29 #define V8_REGEXP_CODEGEN_H_
30
31 namespace v8 { namespace internal {
32
33
34 struct DisjunctDecisionRow {
35 RegExpCharacterClass cc;
36 Label* on_match;
37 int actions;
38 };
39
40
41 // Actions. These are things that can be specified to happen on a
42 // match or failure when generating code.
43 static const int kNoAction = 0x00;
44 // Pop the current position in the subject from the backtracking stack.
45 static const int kPopCurrentPosition = 0x01;
46 // Push the current position in the subject onto the backtracking stack.
47 static const int kPushCurrentPosition = 0x04;
48 // As above, but in CheckCharacter and CheckCharacterClass which take an
49 // offset, the offset is added to the current position first.
50 static const int kPushCurrentPositionPlusOffset = 0x06;
51 // Pop a new state from the stack and go to it.
52 static const int kBacktrack = 0x08;
53 // Goto the label that is given in another argument.
54 static const int kGotoLabel = 0x10;
55 // Advance current position (by the offset + 1).
56 static const int kAdvanceCurrentPosition = 0x20;
57 // Push the label that is given in another argument onto the backtrack stack.
58 static const int kPushBacktrackState = 0x40;
59 // The entire regexp has succeeded.
60 static const int kSuccess = 0x80;
61 // The entire regexp has failed to match.
62 static const int kFailure = 0x100;
63
64
65 template <typename SubjectChar>
66 class RegexpCodeGenerator {
67 public:
68 RegexpCodeGenerator() { }
69 virtual ~RegexpCodeGenerator() { }
70 virtual void Bind(Label* label) = 0;
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.
73 virtual void WriteCaptureInfo(int index) = 0;
74 // Pops the the given index of the capture array from the stack.
75 virtual void PopCaptureInfo(int index) = 0;
76 // Pushes the current position in the subject string onto the stack for later
77 // retrieval.
78 virtual void PushCurrentPosition() = 0;
79 // Pops the current position in the subject string.
80 virtual void PopCurrentPosition() = 0;
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.
83 virtual void AdvanceCurrentPosition(int by) = 0;
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
86 // kAdvanceCurrentPosition or kNoAction.
87 virtual void CheckCharacterClass(
88 RegExpCharacterClass* cclass,
89 int success_action,
90 int fail_action,
91 int offset, // Offset from current subject position.
92 Label* fail_state = NULL) = 0; // Used by kGotoLabel on failure.
93 // Check the current character for a match with a character class. Take
94 // one of the actions depending on whether there is a match.
95 virtual void CheckCharacters(
96 Vector<uc16> str,
97 int fail_action,
98 int offset,
99 Label* state = NULL) = 0; // Used by kGotoLabel on failure.
100 // Perform an action unconditionally.
101 virtual void Action(
102 int action,
103 Label* state = NULL) = 0;
104 // Peek at the next character and find out which of the disjunct character
105 // classes it is in. Perform the corresponding actions on the corresponding
106 // label.
107 virtual void DisjunctCharacterPeekDispatch(
108 Vector<DisjunctDecisionRow> outcomes) = 0;
109 private:
110 };
111
112
113 } } // namespace v8::internal
114
115 #endif // V8_REGEXP_CODEGEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698