2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
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.
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.
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
26 #include "ExecutableAllocator.h"
27 #include <wtf/Forward.h>
28 #include <wtf/RefCounted.h>
36 class RegExp
: public RefCounted
<RegExp
> {
38 static PassRefPtr
<RegExp
> create(JSGlobalData
* globalData
, const UString
& pattern
);
39 static PassRefPtr
<RegExp
> create(JSGlobalData
* globalData
, const UString
& pattern
, const UString
& flags
);
42 bool global() const { return m_flagBits
& Global
; }
43 bool ignoreCase() const { return m_flagBits
& IgnoreCase
; }
44 bool multiline() const { return m_flagBits
& Multiline
; }
46 const UString
& pattern() const { return m_pattern
; }
47 const UString
& flags() const { return m_flags
; }
49 bool isValid() const { return !m_constructionError
; }
50 const char* errorMessage() const { return m_constructionError
; }
52 int match(const UString
&, int startOffset
, OwnArrayPtr
<int>* ovector
= 0);
53 unsigned numSubpatterns() const { return m_numSubpatterns
; }
56 RegExp(JSGlobalData
* globalData
, const UString
& pattern
);
57 RegExp(JSGlobalData
* globalData
, const UString
& pattern
, const UString
& flags
);
61 enum FlagBits
{ Global
= 1, IgnoreCase
= 2, Multiline
= 4 };
63 UString m_pattern
; // FIXME: Just decompile m_regExp instead of storing this.
64 UString m_flags
; // FIXME: Just decompile m_regExp instead of storing this.
67 const char* m_constructionError
;
68 unsigned m_numSubpatterns
;
71 WREC::CompiledRegExp m_wrecFunction
;
72 RefPtr
<ExecutablePool
> m_executablePool
;