Changeset 49365 in webkit for trunk/JavaScriptCore/runtime/RegExpConstructor.h
- Timestamp:
- Oct 8, 2009, 8:22:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/RegExpConstructor.h
r48836 r49365 23 23 24 24 #include "InternalFunction.h" 25 #include "RegExp.h" 25 26 #include <wtf/OwnPtr.h> 26 27 … … 30 31 class RegExpPrototype; 31 32 struct RegExpConstructorPrivate; 33 34 struct RegExpConstructorPrivate : FastAllocBase { 35 // Global search cache / settings 36 RegExpConstructorPrivate() 37 : lastNumSubPatterns(0) 38 , multiline(false) 39 , lastOvectorIndex(0) 40 { 41 } 42 43 const Vector<int, 32>& lastOvector() const { return ovector[lastOvectorIndex]; } 44 Vector<int, 32>& lastOvector() { return ovector[lastOvectorIndex]; } 45 Vector<int, 32>& tempOvector() { return ovector[lastOvectorIndex ? 0 : 1]; } 46 void changeLastOvector() { lastOvectorIndex = lastOvectorIndex ? 0 : 1; } 47 48 UString input; 49 UString lastInput; 50 Vector<int, 32> ovector[2]; 51 unsigned lastNumSubPatterns : 30; 52 bool multiline : 1; 53 unsigned lastOvectorIndex : 1; 54 }; 32 55 33 56 class RegExpConstructor : public InternalFunction { … … 79 102 } 80 103 104 /* 105 To facilitate result caching, exec(), test(), match(), search(), and replace() dipatch regular 106 expression matching through the performMatch function. We use cached results to calculate, 107 e.g., RegExp.lastMatch and RegExp.leftParen. 108 */ 109 inline void RegExpConstructor::performMatch(RegExp* r, const UString& s, int startOffset, int& position, int& length, int** ovector) 110 { 111 position = r->match(s, startOffset, &d->tempOvector()); 112 113 if (ovector) 114 *ovector = d->tempOvector().data(); 115 116 if (position != -1) { 117 ASSERT(!d->tempOvector().isEmpty()); 118 119 length = d->tempOvector()[1] - d->tempOvector()[0]; 120 121 d->input = s; 122 d->lastInput = s; 123 d->changeLastOvector(); 124 d->lastNumSubPatterns = r->numSubpatterns(); 125 } 126 } 127 81 128 } // namespace JSC 82 129
Note:
See TracChangeset
for help on using the changeset viewer.