Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
dart::RegExpCompiler Class Reference
Inheritance diagram for dart::RegExpCompiler:
dart::ValueObject

Public Member Functions

 RegExpCompiler (intptr_t capture_count, bool is_one_byte)
 
intptr_t AllocateRegister ()
 
intptr_t UnicodeLookaroundStackRegister ()
 
intptr_t UnicodeLookaroundPositionRegister ()
 
RegExpEngine::CompilationResult Assemble (IRRegExpMacroAssembler *assembler, RegExpNode *start, intptr_t capture_count, const String &pattern)
 
RegExpEngine::CompilationResult Assemble (BytecodeRegExpMacroAssembler *assembler, RegExpNode *start, intptr_t capture_count, const String &pattern)
 
void AddWork (RegExpNode *node)
 
RegExpMacroAssemblermacro_assembler ()
 
EndNodeaccept ()
 
intptr_t recursion_depth ()
 
void IncrementRecursionDepth ()
 
void DecrementRecursionDepth ()
 
void SetRegExpTooBig ()
 
bool one_byte () const
 
bool read_backward ()
 
void set_read_backward (bool value)
 
FrequencyCollatorfrequency_collator ()
 
intptr_t current_expansion_factor ()
 
void set_current_expansion_factor (intptr_t value)
 
Zonezone () const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Static Public Attributes

static constexpr intptr_t kImplementationOffset = 0
 
static constexpr intptr_t kNumberOfRegistersOffset = 0
 
static constexpr intptr_t kCodeOffset = 1
 
static constexpr intptr_t kMaxRecursion = 100
 
static constexpr intptr_t kNoRegister = -1
 

Detailed Description

Definition at line 292 of file regexp.cc.

Constructor & Destructor Documentation

◆ RegExpCompiler()

dart::RegExpCompiler::RegExpCompiler ( intptr_t  capture_count,
bool  is_one_byte 
)

Definition at line 390 of file regexp.cc.

391 : next_register_(2 * (capture_count + 1)),
392 unicode_lookaround_stack_register_(kNoRegister),
393 unicode_lookaround_position_register_(kNoRegister),
394 work_list_(nullptr),
395 recursion_depth_(0),
396 is_one_byte_(is_one_byte),
397 reg_exp_too_big_(false),
398 read_backward_(false),
399 current_expansion_factor_(1),
400 zone_(Thread::Current()->zone()) {
401 accept_ = new (Z) EndNode(EndNode::ACCEPT, Z);
402}
Zone * zone() const
Definition: regexp.cc:353
static constexpr intptr_t kNoRegister
Definition: regexp.cc:355
static Thread * Current()
Definition: thread.h:362
#define Z
Definition: regexp.cc:26

Member Function Documentation

◆ accept()

EndNode * dart::RegExpCompiler::accept ( )
inline

Definition at line 334 of file regexp.cc.

334{ return accept_; }

◆ AddWork()

void dart::RegExpCompiler::AddWork ( RegExpNode node)
inline

Definition at line 327 of file regexp.cc.

327{ work_list_->Add(node); }

◆ AllocateRegister()

intptr_t dart::RegExpCompiler::AllocateRegister ( )
inline

Definition at line 296 of file regexp.cc.

296{ return next_register_++; }

◆ Assemble() [1/2]

RegExpEngine::CompilationResult dart::RegExpCompiler::Assemble ( BytecodeRegExpMacroAssembler assembler,
RegExpNode start,
intptr_t  capture_count,
const String pattern 
)

Definition at line 436 of file regexp.cc.

440 {
441 macro_assembler->set_slow_safe(false /* use_slow_safe_regexp_compiler */);
442 macro_assembler_ = macro_assembler;
443
444 ZoneGrowableArray<RegExpNode*> work_list(0);
445 work_list_ = &work_list;
446 BlockLabel fail;
447 macro_assembler_->PushBacktrack(&fail);
448 Trace new_trace;
449 start->Emit(this, &new_trace);
450 macro_assembler_->BindBlock(&fail);
451 macro_assembler_->Fail();
452 while (!work_list.is_empty()) {
453 work_list.RemoveLast()->Emit(this, &new_trace);
454 }
455 if (reg_exp_too_big_) return IrregexpRegExpTooBig();
456
457 TypedData& bytecode = TypedData::ZoneHandle(macro_assembler->GetBytecode());
458 return RegExpEngine::CompilationResult(&bytecode, next_register_);
459}
static void fail(const SkString &err)
Definition: DM.cpp:234
static Object & ZoneHandle()
Definition: object.h:419
RegExpMacroAssembler * macro_assembler()
Definition: regexp.cc:333
virtual void BindBlock(BlockLabel *label)=0
virtual void PushBacktrack(BlockLabel *label)=0
static RegExpEngine::CompilationResult IrregexpRegExpTooBig()
Definition: regexp.cc:384

◆ Assemble() [2/2]

RegExpEngine::CompilationResult dart::RegExpCompiler::Assemble ( IRRegExpMacroAssembler assembler,
RegExpNode start,
intptr_t  capture_count,
const String pattern 
)

Definition at line 405 of file regexp.cc.

409 {
410 macro_assembler->set_slow_safe(false /* use_slow_safe_regexp_compiler */);
411 macro_assembler_ = macro_assembler;
412
413 ZoneGrowableArray<RegExpNode*> work_list(0);
414 work_list_ = &work_list;
415 BlockLabel fail;
416 macro_assembler_->PushBacktrack(&fail);
417 Trace new_trace;
418 start->Emit(this, &new_trace);
419 macro_assembler_->BindBlock(&fail);
420 macro_assembler_->Fail();
421 while (!work_list.is_empty()) {
422 work_list.RemoveLast()->Emit(this, &new_trace);
423 }
424 if (reg_exp_too_big_) return IrregexpRegExpTooBig();
425
426 macro_assembler->GenerateBacktrackBlock();
427 macro_assembler->FinalizeRegistersArray();
428
429 return RegExpEngine::CompilationResult(
430 macro_assembler->backtrack_goto(), macro_assembler->graph_entry(),
431 macro_assembler->num_blocks(), macro_assembler->num_stack_locals(),
432 next_register_);
433}

◆ current_expansion_factor()

intptr_t dart::RegExpCompiler::current_expansion_factor ( )
inline

Definition at line 348 of file regexp.cc.

348{ return current_expansion_factor_; }

◆ DecrementRecursionDepth()

void dart::RegExpCompiler::DecrementRecursionDepth ( )
inline

Definition at line 339 of file regexp.cc.

339{ recursion_depth_--; }

◆ frequency_collator()

FrequencyCollator * dart::RegExpCompiler::frequency_collator ( )
inline

Definition at line 346 of file regexp.cc.

346{ return &frequency_collator_; }

◆ IncrementRecursionDepth()

void dart::RegExpCompiler::IncrementRecursionDepth ( )
inline

Definition at line 338 of file regexp.cc.

338{ recursion_depth_++; }

◆ macro_assembler()

RegExpMacroAssembler * dart::RegExpCompiler::macro_assembler ( )
inline

Definition at line 333 of file regexp.cc.

333{ return macro_assembler_; }

◆ one_byte()

bool dart::RegExpCompiler::one_byte ( ) const
inline

Definition at line 343 of file regexp.cc.

343{ return is_one_byte_; }

◆ read_backward()

bool dart::RegExpCompiler::read_backward ( )
inline

Definition at line 344 of file regexp.cc.

344{ return read_backward_; }

◆ recursion_depth()

intptr_t dart::RegExpCompiler::recursion_depth ( )
inline

Definition at line 337 of file regexp.cc.

337{ return recursion_depth_; }

◆ set_current_expansion_factor()

void dart::RegExpCompiler::set_current_expansion_factor ( intptr_t  value)
inline

Definition at line 349 of file regexp.cc.

349 {
350 current_expansion_factor_ = value;
351 }
uint8_t value

◆ set_read_backward()

void dart::RegExpCompiler::set_read_backward ( bool  value)
inline

Definition at line 345 of file regexp.cc.

345{ read_backward_ = value; }

◆ SetRegExpTooBig()

void dart::RegExpCompiler::SetRegExpTooBig ( )
inline

Definition at line 341 of file regexp.cc.

341{ reg_exp_too_big_ = true; }

◆ UnicodeLookaroundPositionRegister()

intptr_t dart::RegExpCompiler::UnicodeLookaroundPositionRegister ( )
inline

Definition at line 307 of file regexp.cc.

307 {
308 if (unicode_lookaround_position_register_ == kNoRegister) {
309 unicode_lookaround_position_register_ = AllocateRegister();
310 }
311 return unicode_lookaround_position_register_;
312 }
intptr_t AllocateRegister()
Definition: regexp.cc:296

◆ UnicodeLookaroundStackRegister()

intptr_t dart::RegExpCompiler::UnicodeLookaroundStackRegister ( )
inline

Definition at line 300 of file regexp.cc.

300 {
301 if (unicode_lookaround_stack_register_ == kNoRegister) {
302 unicode_lookaround_stack_register_ = AllocateRegister();
303 }
304 return unicode_lookaround_stack_register_;
305 }

◆ zone()

Zone * dart::RegExpCompiler::zone ( ) const
inline

Definition at line 353 of file regexp.cc.

353{ return zone_; }

Member Data Documentation

◆ kCodeOffset

constexpr intptr_t dart::RegExpCompiler::kCodeOffset = 1
staticconstexpr

Definition at line 331 of file regexp.cc.

◆ kImplementationOffset

constexpr intptr_t dart::RegExpCompiler::kImplementationOffset = 0
staticconstexpr

Definition at line 329 of file regexp.cc.

◆ kMaxRecursion

constexpr intptr_t dart::RegExpCompiler::kMaxRecursion = 100
staticconstexpr

Definition at line 336 of file regexp.cc.

◆ kNoRegister

constexpr intptr_t dart::RegExpCompiler::kNoRegister = -1
staticconstexpr

Definition at line 355 of file regexp.cc.

◆ kNumberOfRegistersOffset

constexpr intptr_t dart::RegExpCompiler::kNumberOfRegistersOffset = 0
staticconstexpr

Definition at line 330 of file regexp.cc.


The documentation for this class was generated from the following file: