source: webkit/trunk/JavaScriptCore/runtime/RegExp.h@ 44550

Last change on this file since 44550 was 44224, checked in by [email protected], 16 years ago

Revert 44221.

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21#ifndef RegExp_h
22#define RegExp_h
23
24#include "UString.h"
25#include "WREC.h"
26#include "ExecutableAllocator.h"
27#include <wtf/Forward.h>
28#include <wtf/RefCounted.h>
29#include "yarr/RegexJIT.h"
30#include "yarr/RegexInterpreter.h"
31
32struct JSRegExp;
33
34namespace JSC {
35
36 class JSGlobalData;
37
38 class RegExp : public RefCounted<RegExp> {
39 public:
40 static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern);
41 static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern, const UString& flags);
42#if !ENABLE(YARR)
43 ~RegExp();
44#endif
45
46 bool global() const { return m_flagBits & Global; }
47 bool ignoreCase() const { return m_flagBits & IgnoreCase; }
48 bool multiline() const { return m_flagBits & Multiline; }
49
50 const UString& pattern() const { return m_pattern; }
51 const UString& flags() const { return m_flags; }
52
53 bool isValid() const { return !m_constructionError; }
54 const char* errorMessage() const { return m_constructionError; }
55
56 int match(const UString&, int startOffset, OwnArrayPtr<int>* ovector = 0);
57 unsigned numSubpatterns() const { return m_numSubpatterns; }
58
59 private:
60 RegExp(JSGlobalData* globalData, const UString& pattern);
61 RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags);
62
63 void compile(JSGlobalData*);
64
65 enum FlagBits { Global = 1, IgnoreCase = 2, Multiline = 4 };
66
67 UString m_pattern; // FIXME: Just decompile m_regExp instead of storing this.
68 UString m_flags; // FIXME: Just decompile m_regExp instead of storing this.
69 int m_flagBits;
70 const char* m_constructionError;
71 unsigned m_numSubpatterns;
72
73#if ENABLE(YARR_JIT)
74 Yarr::RegexCodeBlock m_regExpJITCode;
75#elif ENABLE(YARR)
76 OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
77#else
78#if ENABLE(WREC)
79 WREC::CompiledRegExp m_wrecFunction;
80 RefPtr<ExecutablePool> m_executablePool;
81#endif
82 JSRegExp* m_regExp;
83#endif
84 };
85
86} // namespace JSC
87
88#endif // RegExp_h
Note: See TracBrowser for help on using the repository browser.