本文整理汇总了C++中HandleLinearString::hasLatin1Chars方法的典型用法代码示例。如果您正苦于以下问题:C++ HandleLinearString::hasLatin1Chars方法的具体用法?C++ HandleLinearString::hasLatin1Chars怎么用?C++ HandleLinearString::hasLatin1Chars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HandleLinearString
的用法示例。
在下文中一共展示了HandleLinearString::hasLatin1Chars方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compile
bool
RegExpShared::compileIfNecessary(JSContext *cx, HandleLinearString input, CompilationMode mode)
{
if (isCompiled(mode, input->hasLatin1Chars()) || canStringMatch)
return true;
return compile(cx, input, mode);
}
示例2: compile
bool
RegExpShared::compileIfNecessary(JSContext* cx, HandleLinearString input,
CompilationMode mode, ForceByteCodeEnum force)
{
if (isCompiled(mode, input->hasLatin1Chars(), force))
return true;
return compile(cx, input, mode, force);
}
示例3:
static bool
IsTrailSurrogateWithLeadSurrogate(JSContext* cx, HandleLinearString input, int32_t index)
{
if (index <= 0 || size_t(index) >= input->length())
return false;
return input->hasLatin1Chars()
? IsTrailSurrogateWithLeadSurrogateImpl<Latin1Char>(cx, input, index)
: IsTrailSurrogateWithLeadSurrogateImpl<char16_t>(cx, input, index);
}
示例4: options
bool
RegExpShared::compile(JSContext* cx, HandleAtom pattern, HandleLinearString input,
CompilationMode mode, bool sticky, ForceByteCodeEnum force)
{
if (!ignoreCase() && !StringHasRegExpMetaChars(pattern))
canStringMatch = true;
CompileOptions options(cx);
TokenStream dummyTokenStream(cx, options, nullptr, 0, nullptr);
LifoAllocScope scope(&cx->tempLifoAlloc());
/* Parse the pattern. */
irregexp::RegExpCompileData data;
if (!irregexp::ParsePattern(dummyTokenStream, cx->tempLifoAlloc(), pattern,
multiline(), mode == MatchOnly, unicode(), ignoreCase(), &data))
{
return false;
}
this->parenCount = data.capture_count;
irregexp::RegExpCode code = irregexp::CompilePattern(cx, this, &data, input,
false /* global() */,
ignoreCase(),
input->hasLatin1Chars(),
mode == MatchOnly,
force == ForceByteCode,
sticky, unicode());
if (code.empty())
return false;
MOZ_ASSERT(!code.jitCode || !code.byteCode);
MOZ_ASSERT_IF(force == ForceByteCode, code.byteCode);
RegExpCompilation& compilation = this->compilation(mode, sticky, input->hasLatin1Chars());
if (code.jitCode)
compilation.jitCode = code.jitCode;
else if (code.byteCode)
compilation.byteCode = code.byteCode;
return true;
}
示例5: stackScope
RegExpRunStatus
RegExpShared::execute(JSContext* cx, HandleLinearString input, size_t start,
MatchPairs* matches)
{
TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime());
CompilationMode mode = matches ? Normal : MatchOnly;
/* Compile the code at point-of-use. */
if (!compileIfNecessary(cx, input, mode, DontForceByteCode))
return RegExpRunStatus_Error;
/*
* Ensure sufficient memory for output vector.
* No need to initialize it. The RegExp engine fills them in on a match.
*/
if (matches && !matches->allocOrExpandArray(pairCount())) {
ReportOutOfMemory(cx);
return RegExpRunStatus_Error;
}
/*
* |displacement| emulates sticky mode by matching from this offset
* into the char buffer and subtracting the delta off at the end.
*/
size_t charsOffset = 0;
size_t length = input->length();
size_t origLength = length;
size_t displacement = 0;
if (sticky()) {
displacement = start;
charsOffset += displacement;
length -= displacement;
start = 0;
}
// Reset the Irregexp backtrack stack if it grows during execution.
irregexp::RegExpStackScope stackScope(cx->runtime());
if (canStringMatch) {
MOZ_ASSERT(pairCount() == 1);
int res = StringFindPattern(input, source, start + charsOffset);
if (res == -1)
return RegExpRunStatus_Success_NotFound;
if (matches) {
(*matches)[0].start = res;
(*matches)[0].limit = res + source->length();
matches->checkAgainst(origLength);
}
return RegExpRunStatus_Success;
}
do {
jit::JitCode* code = compilation(mode, input->hasLatin1Chars()).jitCode;
if (!code)
break;
RegExpRunStatus result;
{
AutoTraceLog logJIT(logger, TraceLogger_IrregexpExecute);
AutoCheckCannotGC nogc;
if (input->hasLatin1Chars()) {
const Latin1Char* chars = input->latin1Chars(nogc) + charsOffset;
result = irregexp::ExecuteCode(cx, code, chars, start, length, matches);
} else {
const char16_t* chars = input->twoByteChars(nogc) + charsOffset;
result = irregexp::ExecuteCode(cx, code, chars, start, length, matches);
}
}
if (result == RegExpRunStatus_Error) {
// An 'Error' result is returned if a stack overflow guard or
// interrupt guard failed. If CheckOverRecursed doesn't throw, break
// out and retry the regexp in the bytecode interpreter, which can
// execute while tolerating future interrupts. Otherwise, if we keep
// getting interrupted we will never finish executing the regexp.
if (!jit::CheckOverRecursed(cx))
return RegExpRunStatus_Error;
break;
}
if (result == RegExpRunStatus_Success_NotFound)
return RegExpRunStatus_Success_NotFound;
MOZ_ASSERT(result == RegExpRunStatus_Success);
if (matches) {
matches->displace(displacement);
matches->checkAgainst(origLength);
}
return RegExpRunStatus_Success;
} while (false);
// Compile bytecode for the RegExp if necessary.
if (!compileIfNecessary(cx, input, mode, ForceByteCode))
return RegExpRunStatus_Error;
//.........这里部分代码省略.........
示例6: stackScope
RegExpRunStatus
RegExpShared::execute(JSContext *cx, HandleLinearString input, size_t start,
MatchPairs *matches)
{
TraceLogger *logger = TraceLoggerForMainThread(cx->runtime());
CompilationMode mode = matches ? Normal : MatchOnly;
/* Compile the code at point-of-use. */
if (!compileIfNecessary(cx, input, mode))
return RegExpRunStatus_Error;
/*
* Ensure sufficient memory for output vector.
* No need to initialize it. The RegExp engine fills them in on a match.
*/
if (matches && !matches->allocOrExpandArray(pairCount()))
return RegExpRunStatus_Error;
/*
* |displacement| emulates sticky mode by matching from this offset
* into the char buffer and subtracting the delta off at the end.
*/
size_t charsOffset = 0;
size_t length = input->length();
size_t origLength = length;
size_t displacement = 0;
if (sticky()) {
displacement = start;
charsOffset += displacement;
length -= displacement;
start = 0;
}
// Reset the Irregexp backtrack stack if it grows during execution.
irregexp::RegExpStackScope stackScope(cx->runtime());
if (canStringMatch) {
JS_ASSERT(pairCount() == 1);
int res = StringFindPattern(input, source, start + charsOffset);
if (res == -1)
return RegExpRunStatus_Success_NotFound;
if (matches) {
(*matches)[0].start = res;
(*matches)[0].limit = res + source->length();
matches->checkAgainst(origLength);
}
return RegExpRunStatus_Success;
}
if (uint8_t *byteCode = compilation(mode, input->hasLatin1Chars()).byteCode) {
AutoTraceLog logInterpreter(logger, TraceLogger::IrregexpExecute);
AutoStableStringChars inputChars(cx);
if (!inputChars.init(cx, input))
return RegExpRunStatus_Error;
RegExpRunStatus result;
if (inputChars.isLatin1()) {
const Latin1Char *chars = inputChars.latin1Range().start().get() + charsOffset;
result = irregexp::InterpretCode(cx, byteCode, chars, start, length, matches);
} else {
const char16_t *chars = inputChars.twoByteRange().start().get() + charsOffset;
result = irregexp::InterpretCode(cx, byteCode, chars, start, length, matches);
}
if (result == RegExpRunStatus_Success && matches) {
matches->displace(displacement);
matches->checkAgainst(origLength);
}
return result;
}
while (true) {
RegExpRunStatus result;
{
AutoTraceLog logJIT(logger, TraceLogger::IrregexpExecute);
AutoCheckCannotGC nogc;
jit::JitCode *code = compilation(mode, input->hasLatin1Chars()).jitCode;
if (input->hasLatin1Chars()) {
const Latin1Char *chars = input->latin1Chars(nogc) + charsOffset;
result = irregexp::ExecuteCode(cx, code, chars, start, length, matches);
} else {
const char16_t *chars = input->twoByteChars(nogc) + charsOffset;
result = irregexp::ExecuteCode(cx, code, chars, start, length, matches);
}
}
if (result == RegExpRunStatus_Error) {
// The RegExp engine might exit with an exception if an interrupt
// was requested. Check this case and retry until a clean result is
// obtained.
bool interrupted;
{
JSRuntime::AutoLockForInterrupt lock(cx->runtime());
interrupted = cx->runtime()->interrupt;
}
//.........这里部分代码省略.........