5302 {
5303 ASSERT(!FLAG_interpret_irregexp);
5305
5306 const Function&
function = parsed_function->function();
5307 const intptr_t specialization_cid =
function.string_specialization_cid();
5308 const bool is_sticky =
function.is_sticky_specialization();
5309 const bool is_one_byte = (specialization_cid == kOneByteStringCid);
5312
5313 ASSERT(!regexp.IsNull());
5314 ASSERT(!pattern.IsNull());
5315
5316 const bool is_global = regexp.flags().IsGlobal();
5317 const bool is_unicode = regexp.flags().IsUnicode();
5318
5319 RegExpCompiler
compiler(
data->capture_count, is_one_byte);
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331 RegExpNode* captured_body =
5333
5334 RegExpNode* node = captured_body;
5335 const bool is_end_anchored =
data->tree->IsAnchoredAtEnd();
5336 const bool is_start_anchored =
data->tree->IsAnchoredAtStart();
5337 intptr_t max_length =
data->tree->max_match();
5338 if (!is_start_anchored && !is_sticky) {
5339
5340
5343 new (zone) RegExpCharacterClass(
'*', RegExpFlags()), &
compiler,
5344 captured_body,
data->contains_anchor);
5345
5346 if (
data->contains_anchor) {
5347
5348
5349 ChoiceNode* first_step_node = new (zone) ChoiceNode(2, zone);
5350 first_step_node->AddAlternative(GuardedAlternative(captured_body));
5351 first_step_node->AddAlternative(GuardedAlternative(new (zone) TextNode(
5352 new (zone) RegExpCharacterClass('*', RegExpFlags()),
5353 false, loop_node)));
5354 node = first_step_node;
5355 } else {
5356 node = loop_node;
5357 }
5358 }
5359 if (is_one_byte) {
5361
5362
5363 if (node != nullptr) {
5365 }
5366 } else if (is_unicode && (is_global || is_sticky)) {
5368 }
5369
5372 Analysis analysis(is_one_byte);
5373 analysis.EnsureAnalyzed(node);
5374 if (analysis.has_failed()) {
5375 const char* error_message = analysis.error_message();
5376 return CompilationResult(error_message);
5377 }
5378
5379
5380
5381 IRRegExpMacroAssembler* macro_assembler = new (zone)
5382 IRRegExpMacroAssembler(specialization_cid,
data->capture_count,
5383 parsed_function, ic_data_array, osr_id, zone);
5384
5385
5386
5387 const intptr_t kMaxBacksearchLimit = 1024;
5388 if (is_end_anchored && !is_start_anchored && !is_sticky &&
5389 max_length < kMaxBacksearchLimit) {
5390 macro_assembler->SetCurrentPositionFromEnd(max_length);
5391 }
5392
5393 if (is_global) {
5395 if (
data->tree->min_match() > 0) {
5397 } else if (is_unicode) {
5399 }
5400 macro_assembler->set_global_mode(
mode);
5401 }
5402
5403 RegExpEngine::CompilationResult
result =
5404 compiler.Assemble(macro_assembler, node,
data->capture_count, pattern);
5405
5406 if (FLAG_trace_irregexp) {
5407 macro_assembler->PrintBlocks();
5408 }
5409
5411}
static Thread * Current()
Dart_NativeFunction function