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

Side by Side Diff: regexp2000/src/jsregexp.h

Issue 8765: * Use new RegExp parser. (Closed)
Patch Set: Use new RegExp parser. 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
« no previous file with comments | « regexp2000/src/ast.cc ('k') | regexp2000/src/jsregexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 static Handle<Object> Exec(Handle<JSRegExp> regexp, 54 static Handle<Object> Exec(Handle<JSRegExp> regexp,
55 Handle<String> subject, 55 Handle<String> subject,
56 Handle<Object> index); 56 Handle<Object> index);
57 57
58 // Call RegExp.prototyp.exec(string) in a loop. 58 // Call RegExp.prototyp.exec(string) in a loop.
59 // Used by String.prototype.match and String.prototype.replace. 59 // Used by String.prototype.match and String.prototype.replace.
60 // This function calls the garbage collector if necessary. 60 // This function calls the garbage collector if necessary.
61 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp, 61 static Handle<Object> ExecGlobal(Handle<JSRegExp> regexp,
62 Handle<String> subject); 62 Handle<String> subject);
63 63
64 // Stores an uncompiled RegExp pattern in the JSRegExp object.
65 // It will be compiled by JSCRE when first executed.
66 static Handle<Object> JsrePrepare(Handle<JSRegExp> re,
67 Handle<String> pattern,
68 JSRegExp::Flags flags);
69
70 // Compile the pattern using JSCRE and store the result in the
71 // JSRegExp object.
72 static Handle<Object> JsreCompile(Handle<JSRegExp> re);
73
64 static Handle<Object> AtomCompile(Handle<JSRegExp> re, 74 static Handle<Object> AtomCompile(Handle<JSRegExp> re,
65 Handle<String> pattern, 75 Handle<String> pattern,
66 JSRegExp::Flags flags); 76 JSRegExp::Flags flags);
67
68 static Handle<Object> AtomExec(Handle<JSRegExp> regexp, 77 static Handle<Object> AtomExec(Handle<JSRegExp> regexp,
69 Handle<String> subject, 78 Handle<String> subject,
70 Handle<Object> index); 79 Handle<Object> index);
71 80
72 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp, 81 static Handle<Object> AtomExecGlobal(Handle<JSRegExp> regexp,
73 Handle<String> subject); 82 Handle<String> subject);
74 83
75 static Handle<Object> JsreCompile(Handle<JSRegExp> re, 84 static Handle<Object> JsreCompile(Handle<JSRegExp> re,
76 Handle<String> pattern, 85 Handle<String> pattern,
77 JSRegExp::Flags flags); 86 JSRegExp::Flags flags);
78 87
88 // Execute a compiled JSCRE pattern.
79 static Handle<Object> JsreExec(Handle<JSRegExp> regexp, 89 static Handle<Object> JsreExec(Handle<JSRegExp> regexp,
80 Handle<String> subject, 90 Handle<String> subject,
81 Handle<Object> index); 91 Handle<Object> index);
82 92
83 static Handle<Object> JsreExecGlobal(Handle<JSRegExp> regexp, 93 static Handle<Object> JsreExecGlobal(Handle<JSRegExp> regexp,
84 Handle<String> subject); 94 Handle<String> subject);
85 95
86 static void NewSpaceCollectionPrologue(); 96 static void NewSpaceCollectionPrologue();
87 static void OldSpaceCollectionPrologue(); 97 static void OldSpaceCollectionPrologue();
88 98
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 static inline unsigned segment_of(uc16 value); 197 static inline unsigned segment_of(uc16 value);
188 static inline uc16 segment_start(unsigned segment); 198 static inline uc16 segment_start(unsigned segment);
189 199
190 private: 200 private:
191 static const int kCharSize = 16; 201 static const int kCharSize = 16;
192 static const int kFieldSegmentIndexWidth = 10; 202 static const int kFieldSegmentIndexWidth = 10;
193 static const int kFieldWidth = kCharSize - kFieldSegmentIndexWidth; 203 static const int kFieldWidth = kCharSize - kFieldSegmentIndexWidth;
194 static const int kFieldMax = (1 << kFieldWidth); 204 static const int kFieldMax = (1 << kFieldWidth);
195 static const int kSegmentMask = (1 << kFieldWidth) - 1; 205 static const int kSegmentMask = (1 << kFieldWidth) - 1;
196 static const int kNibbleCount = kFieldMax / 4; 206 static const int kNibbleCount = kFieldMax / 4;
197 STATIC_ASSERT(kFieldMax == 8 * sizeof(uint64_t)); 207 STATIC_CHECK(kFieldMax == 8 * sizeof(uint64_t));
198 208
199 Type type() { return type_; } 209 Type type() { return type_; }
200 210
201 static inline uint64_t long_bit(int index) { 211 static inline uint64_t long_bit(int index) {
202 return static_cast<uint64_t>(1) << index; 212 return static_cast<uint64_t>(1) << index;
203 } 213 }
204 214
205 Type type_: 2; 215 Type type_: 2;
206 unsigned segment_ : 10; 216 unsigned segment_ : 10;
207 unsigned count_ : 4; 217 unsigned count_ : 4;
208 union { 218 union {
209 // These have the same type to make it easier to change one without 219 // These have the same type to make it easier to change one without
210 // touching the other. 220 // touching the other.
211 uint64_t u_field; 221 uint64_t u_field;
212 uint64_t u_ranges; 222 uint64_t u_ranges;
213 struct { 223 struct {
214 CharacterClass* left; 224 CharacterClass* left;
215 CharacterClass* right; 225 CharacterClass* right;
216 } u_union; 226 } u_union;
217 } data_; 227 } data_;
218 }; 228 };
219 229
220 230
221 STATIC_ASSERT(sizeof(CharacterClass) == 3 * kIntSize); 231 STATIC_CHECK(sizeof(CharacterClass) == 3 * kIntSize);
222 232
223 233
224 class CharacterClassAllocator { 234 class CharacterClassAllocator {
225 public: 235 public:
226 virtual CharacterClass* Allocate() = 0; 236 virtual CharacterClass* Allocate() = 0;
227 virtual ~CharacterClassAllocator() { } 237 virtual ~CharacterClassAllocator() { }
228 }; 238 };
229 239
230 240
231 template <int kCount> 241 template <int kCount>
(...skipping 13 matching lines...) Expand all
245 static RegExpNode<Char>* Compile(RegExpTree* regexp); 255 static RegExpNode<Char>* Compile(RegExpTree* regexp);
246 256
247 template <typename Char> 257 template <typename Char>
248 static bool Execute(RegExpNode<Char>* start, Vector<Char> input); 258 static bool Execute(RegExpNode<Char>* start, Vector<Char> input);
249 }; 259 };
250 260
251 261
252 } } // namespace v8::internal 262 } } // namespace v8::internal
253 263
254 #endif // V8_JSREGEXP_H_ 264 #endif // V8_JSREGEXP_H_
OLDNEW
« no previous file with comments | « regexp2000/src/ast.cc ('k') | regexp2000/src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698