Go to the documentation of this file.
16 #include "util/util.h"
17 #include "util/logging.h"
18 #include "util/strutil.h"
19 #include "re2/bitmap256.h"
20 #include "re2/stringpiece.h"
37 hint_foldcase_ = foldcase&1;
81 foldcase() ?
"/i" :
"",
82 lo_, hi_, hint(),
out());
89 static_cast<int>(empty_),
out());
147 for (
int id =
start;
id <
prog->size();
id++) {
177 for (
int c = 0; c < 256; c++) {
190 prog->first_byte_ =
prog->ComputeFirstByte();
247 j->lo() == 0x00 && j->hi() == 0xFF &&
254 k->lo() == 0x00 &&
k->hi() == 0xFF) {
266 LOG(DFATAL) <<
"Unexpected opcode in IsMatch: " << ip->
opcode();
291 if (p ==
text.data())
293 else if (p[-1] ==
'\n')
299 else if (p <
text.data() +
text.size() && p[0] ==
'\n')
303 if (p ==
text.data() && p ==
text.data() +
text.size()) {
305 }
else if (p ==
text.data()) {
308 }
else if (p ==
text.data() +
text.size()) {
348 void Mark(
int lo,
int hi);
374 if (lo == 0 && hi == 255)
381 for (std::vector<std::pair<int, int>>::const_iterator
it =
ranges_.begin();
384 int lo =
it->first-1;
433 std::vector<std::pair<int, int>>::const_iterator
it =
435 [=](
const std::pair<int, int>& kv) ->
bool {
436 return kv.first == oldcolor || kv.second == oldcolor;
442 colormap_.emplace_back(oldcolor, newcolor);
453 bool marked_line_boundaries =
false;
455 bool marked_word_boundaries =
false;
457 for (
int id = 0;
id <
size();
id++) {
463 if (ip->
foldcase() && lo <= 'z' && hi >=
'a') {
470 if (foldlo <= foldhi) {
485 !marked_line_boundaries) {
488 marked_line_boundaries =
true;
491 !marked_word_boundaries) {
494 for (
bool isword : {
true,
false}) {
496 for (
int i = 0;
i < 256;
i = j) {
497 for (j =
i + 1; j < 256 &&
507 marked_word_boundaries =
true;
515 LOG(
ERROR) <<
"Using trivial bytemap.";
516 for (
int i = 0;
i < 256;
i++)
565 std::vector<int> stk;
572 std::vector<std::vector<int>> predvec;
582 MarkDominator(
i->index(), &rootmap, &predmap, &predvec, &reachable, &stk);
587 std::vector<int> flatmap(rootmap.
size());
588 std::vector<Inst> flat;
589 flat.reserve(
size());
593 flatmap[
i->value()] =
static_cast<int>(flat.size());
594 EmitList(
i->index(), &rootmap, &flat, &reachable, &stk);
595 flat.back().set_last();
598 ComputeHints(&flat, flatmap[
i->value()],
static_cast<int>(flat.size()));
607 for (
int id = 0; id < static_cast<int>(flat.size());
id++) {
631 size_ =
static_cast<int>(flat.size());
648 std::vector<std::vector<int>>* predvec,
649 SparseSet* reachable, std::vector<int>* stk) {
662 while (!stk->empty()) {
663 int id = stk->back();
673 LOG(DFATAL) <<
"unhandled opcode: " << ip->
opcode();
681 predmap->
set_new(
out,
static_cast<int>(predvec->size()));
682 predvec->emplace_back();
686 stk->push_back(ip->
out1());
712 std::vector<std::vector<int>>* predvec,
713 SparseSet* reachable, std::vector<int>* stk) {
716 stk->push_back(
root);
717 while (!stk->empty()) {
718 int id = stk->back();
733 LOG(DFATAL) <<
"unhandled opcode: " << ip->
opcode();
738 stk->push_back(ip->
out1());
758 i != reachable->
end();
762 for (
int pred : (*predvec)[predmap->
get_existing(
id)]) {
775 std::vector<Inst>* flat,
776 SparseSet* reachable, std::vector<int>* stk) {
779 stk->push_back(
root);
780 while (!stk->empty()) {
781 int id = stk->back();
791 flat->emplace_back();
800 LOG(DFATAL) <<
"unhandled opcode: " << ip->
opcode();
804 flat->emplace_back();
806 flat->back().set_out(
static_cast<int>(flat->size()));
807 flat->back().out1_ =
static_cast<uint32_t>(flat->size())+1;
811 stk->push_back(ip->
out1());
818 flat->emplace_back();
819 memmove(&flat->back(), ip,
sizeof *ip);
829 flat->emplace_back();
830 memmove(&flat->back(), ip,
sizeof *ip);
868 auto Recolor = [&](
int lo,
int hi) {
872 if (0 <= lo && !splits.
Test(lo)) {
875 colors[lo] = colors[
next];
877 if (!splits.
Test(hi)) {
880 colors[hi] = colors[
next];
900 if (ip->
foldcase() && lo <= 'z' && hi >=
'a') {
907 if (foldlo <= foldhi) {
910 Recolor(foldlo, foldhi);
static bool IsMatch(Prog *, Prog::Inst *)
std::string DumpUnanchored()
ByteMapBuilder & operator=(const ByteMapBuilder &)=delete
void InitCapture(int cap, uint32_t out)
return memset(p, 0, total)
#define DCHECK_LE(val1, val2)
void MarkSuccessors(SparseArray< int > *rootmap, SparseArray< int > *predmap, std::vector< std::vector< int >> *predvec, SparseSet *reachable, std::vector< int > *stk)
void ComputeHints(std::vector< Inst > *flat, int begin, int end)
void set_out_opcode(int out, InstOp opcode)
static bool IsWordChar(uint8_t c)
const typedef int * const_iterator
void call_once(absl::once_flag &flag, Callable &&fn, Args &&... args)
void InitAlt(uint32_t out, uint32_t out1)
std::string DumpByteMap()
bool contains(int i) const
int Recolor(int oldcolor)
void InitEmptyWidth(EmptyOp empty, uint32_t out)
static std::string FlattenedProgToString(Prog *prog, int start)
void Mark(int lo, int hi)
RefCountedPtr< grpc_tls_certificate_provider > root
#define FALLTHROUGH_INTENDED
int FindNextSetBit(int c) const
void EmitList(int root, SparseArray< int > *rootmap, std::vector< Inst > *flat, SparseSet *reachable, std::vector< int > *stk)
std::string StringPrintf(const char *format,...)
int inst_count_[kNumInst]
void InitNop(uint32_t out)
Value & get_existing(int i)
void set_start_unanchored(int start)
std::vector< std::pair< int, int > > colormap_
static std::string ProgToString(Prog *prog, Workq *q)
void set_start(int start)
iterator set_new(int i, const Value &v)
static const LogLevel ERROR
promise_detail::Loop< F > Loop(F f)
void MarkDominator(int root, SparseArray< int > *rootmap, SparseArray< int > *predmap, std::vector< std::vector< int >> *predvec, SparseSet *reachable, std::vector< int > *stk)
void Build(uint8_t *bytemap, int *bytemap_range)
void set_opcode(InstOp opcode)
static void AddToQueue(Workq *q, int id)
#define DCHECK_EQ(val1, val2)
AllocList * next[kMaxLevel]
static bool less(const IndexValue &a, const IndexValue &b)
#define DCHECK_GE(val1, val2)
bool has_index(int i) const
std::once_flag first_byte_once_
PODArray< uint16_t > list_heads_
std::vector< std::pair< int, int > > ranges_
void InitByteRange(int lo, int hi, int foldcase, uint32_t out)
static uint32_t EmptyFlags(const StringPiece &context, const char *p)
iterator insert_new(int i)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:46