| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
/* This is the interface that the regexp engine exposes to SpiderMonkey. */ |
| 8 |
|
| 9 |
#ifndef regexp_RegExpAPI_h |
| 10 |
#define regexp_RegExpAPI_h |
| 11 |
|
| 12 |
#include "mozilla/Maybe.h" |
| 13 |
#include "mozilla/MemoryReporting.h" |
| 14 |
#include "mozilla/Range.h" |
| 15 |
|
| 16 |
#include <stddef.h> |
| 17 |
#include <stdint.h> |
| 18 |
|
| 19 |
#include "jstypes.h" |
| 20 |
|
| 21 |
#include "irregexp/RegExpTypes.h" |
| 22 |
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOigin |
| 23 |
#include "js/Stack.h" // JS::NativeStackLimit |
| 24 |
#include "vm/RegExpShared.h" |
| 25 |
|
| 26 |
struct JS_PUBLIC_API JSContext; |
| 27 |
class JS_PUBLIC_API JSTracer; |
| 28 |
|
| 29 |
namespace JS { |
| 30 |
class RegExpFlags; |
| 31 |
} |
| 32 |
|
| 33 |
namespace v8::internal { |
| 34 |
class RegExpStack; |
| 35 |
} |
| 36 |
|
| 37 |
namespace js { |
| 38 |
|
| 39 |
class VectorMatchPairs; |
| 40 |
class LifoAlloc; |
| 41 |
|
| 42 |
namespace frontend { |
| 43 |
class TokenStreamAnyChars; |
| 44 |
} |
| 45 |
|
| 46 |
namespace irregexp { |
| 47 |
|
| 48 |
Isolate* CreateIsolate(JSContext* cx); |
| 49 |
void TraceIsolate(JSTracer* trc, Isolate* isolate); |
| 50 |
void DestroyIsolate(Isolate* isolate); |
| 51 |
|
| 52 |
size_t IsolateSizeOfIncludingThis(Isolate* isolate, |
| 53 |
mozilla::MallocSizeOf mallocSizeOf); |
| 54 |
|
| 55 |
bool CheckPatternSyntax( |
| 56 |
js::LifoAlloc& alloc, JS::NativeStackLimit stackLimit, |
| 57 |
frontend::TokenStreamAnyChars& ts, |
| 58 |
const mozilla::Range<const char16_t> chars, JS::RegExpFlags flags, |
| 59 |
mozilla::Maybe<uint32_t> line = mozilla::Nothing(), |
| 60 |
mozilla::Maybe<JS::ColumnNumberOneOrigin> column = mozilla::Nothing()); |
| 61 |
bool CheckPatternSyntax(JSContext* cx, JS::NativeStackLimit stackLimit, |
| 62 |
frontend::TokenStreamAnyChars& ts, |
| 63 |
Handle<JSAtom*> pattern, JS::RegExpFlags flags); |
| 64 |
|
| 65 |
bool CompilePattern(JSContext* cx, MutableHandleRegExpShared re, |
| 66 |
Handle<JSLinearString*> input, |
| 67 |
RegExpShared::CodeKind codeKind); |
| 68 |
|
| 69 |
RegExpRunStatus Execute(JSContext* cx, MutableHandleRegExpShared re, |
| 70 |
Handle<JSLinearString*> input, size_t start, |
| 71 |
VectorMatchPairs* matches); |
| 72 |
|
| 73 |
RegExpRunStatus ExecuteForFuzzing(JSContext* cx, Handle<JSAtom*> pattern, |
| 74 |
Handle<JSLinearString*> input, |
| 75 |
JS::RegExpFlags flags, size_t startIndex, |
| 76 |
VectorMatchPairs* matches, |
| 77 |
RegExpShared::CodeKind codeKind); |
| 78 |
|
| 79 |
bool GrowBacktrackStack(v8::internal::RegExpStack* regexp_stack); |
| 80 |
|
| 81 |
uint32_t CaseInsensitiveCompareNonUnicode(const char16_t* substring1, |
| 82 |
const char16_t* substring2, |
| 83 |
size_t byteLength); |
| 84 |
uint32_t CaseInsensitiveCompareUnicode(const char16_t* substring1, |
| 85 |
const char16_t* substring2, |
| 86 |
size_t byteLength); |
| 87 |
bool IsCharacterInRangeArray(uint32_t c, ByteArrayData* ranges); |
| 88 |
|
| 89 |
#ifdef DEBUG |
| 90 |
bool IsolateShouldSimulateInterrupt(Isolate* isolate); |
| 91 |
void IsolateSetShouldSimulateInterrupt(Isolate* isolate); |
| 92 |
void IsolateClearShouldSimulateInterrupt(Isolate* isolate); |
| 93 |
#endif |
| 94 |
} // namespace irregexp |
| 95 |
} // namespace js |
| 96 |
|
| 97 |
#endif /* regexp_RegExpAPI_h */ |