Skip to content

Commit f8be967

Browse files
committed
Refactor to use enum class InstTag
1 parent d0626c0 commit f8be967

File tree

3 files changed

+94
-94
lines changed

3 files changed

+94
-94
lines changed

lib/Parser/RegexCompileTime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace UnifiedRegex
5454
}
5555

5656
#define EMIT(compiler, T, ...) (new (compiler.Emit(sizeof(T))) T(__VA_ARGS__))
57-
#define L2I(O, label) LabelToInstPointer<O##Inst>(Inst::O, label)
57+
#define L2I(O, label) LabelToInstPointer<O##Inst>(Inst::InstTag::O, label)
5858

5959
// Remember: The machine address of an instruction is no longer valid after a subsequent emit,
6060
// so all label fixups must be done using Compiler::GetFixup / Compiler::DoFixup

lib/Parser/RegexRuntime.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace UnifiedRegex
3434

3535
#define PUSH(contStack, T, ...) (new (contStack.Push<T>()) T(__VA_ARGS__))
3636
#define PUSHA(assertionStack, T, ...) (new (assertionStack.Push()) T(__VA_ARGS__))
37-
#define L2I(O, label) LabelToInstPointer<O##Inst>(Inst::O, label)
37+
#define L2I(O, label) LabelToInstPointer<O##Inst>(Inst::InstTag::O, label)
3838

3939
#define FAIL_PARAMETERS input, inputOffset, instPointer, contStack, assertionStack, qcTicks
4040
#define HARDFAIL_PARAMETERS(mode) input, inputLength, matchStart, inputOffset, instPointer, contStack, assertionStack, qcTicks, mode
@@ -1252,9 +1252,9 @@ namespace UnifiedRegex
12521252
// ----------------------------------------------------------------------
12531253

12541254
template <>
1255-
BOITestInst<true>::BOITestInst() : Inst(BOIHardFailTest) {}
1255+
BOITestInst<true>::BOITestInst() : Inst(InstTag::BOIHardFailTest) {}
12561256
template <>
1257-
BOITestInst<false>::BOITestInst() : Inst(BOITest) {}
1257+
BOITestInst<false>::BOITestInst() : Inst(InstTag::BOITest) {}
12581258

12591259
template <bool canHardFail>
12601260
inline bool BOITestInst<canHardFail>::Exec(REGEX_INST_EXEC_PARAMETERS) const
@@ -1300,9 +1300,9 @@ namespace UnifiedRegex
13001300
// ----------------------------------------------------------------------
13011301

13021302
template <>
1303-
EOITestInst<true>::EOITestInst() : Inst(EOIHardFailTest) {}
1303+
EOITestInst<true>::EOITestInst() : Inst(InstTag::EOIHardFailTest) {}
13041304
template <>
1305-
EOITestInst<false>::EOITestInst() : Inst(EOITest) {}
1305+
EOITestInst<false>::EOITestInst() : Inst(InstTag::EOITest) {}
13061306

13071307
template <bool canHardFail>
13081308
inline bool EOITestInst<canHardFail>::Exec(REGEX_INST_EXEC_PARAMETERS) const
@@ -1402,9 +1402,9 @@ namespace UnifiedRegex
14021402
// ----------------------------------------------------------------------
14031403

14041404
template <>
1405-
WordBoundaryTestInst<true>::WordBoundaryTestInst() : Inst(NegatedWordBoundaryTest) {}
1405+
WordBoundaryTestInst<true>::WordBoundaryTestInst() : Inst(InstTag::NegatedWordBoundaryTest) {}
14061406
template <>
1407-
WordBoundaryTestInst<false>::WordBoundaryTestInst() : Inst(WordBoundaryTest) {}
1407+
WordBoundaryTestInst<false>::WordBoundaryTestInst() : Inst(InstTag::WordBoundaryTest) {}
14081408

14091409
template <bool isNegation>
14101410
inline bool WordBoundaryTestInst<isNegation>::Exec(REGEX_INST_EXEC_PARAMETERS) const
@@ -5089,16 +5089,16 @@ namespace UnifiedRegex
50895089
}
50905090

50915091
#if DBG
5092-
const uint32 instTags[] = {
5093-
#define M(TagName) Inst::TagName,
5092+
const Inst::InstTag instTags[] = {
5093+
#define M(TagName) Inst::InstTag::TagName,
50945094
#define MTemplate(TagName, ...) M(TagName)
50955095
#include "RegexOpCodes.h"
50965096
#undef M
50975097
#undef MTemplate
50985098
};
50995099

5100-
const uint32 minInstTag = instTags[0];
5101-
const uint32 maxInstTag = instTags[(sizeof(instTags) / sizeof(uint32)) - 1];
5100+
const Inst::InstTag minInstTag = instTags[0];
5101+
const Inst::InstTag maxInstTag = instTags[(sizeof(instTags) / sizeof(Inst::InstTag)) - 1];
51025102
#endif
51035103

51045104
inline void Matcher::Run(const Char* const input, const CharCount inputLength, CharCount &matchStart, CharCount &nextSyncInputOffset, ContStack &contStack, AssertionStack &assertionStack, uint &qcTicks, bool firstIteration)
@@ -5124,7 +5124,7 @@ namespace UnifiedRegex
51245124
switch (tag)
51255125
{
51265126
#define MBase(TagName, ClassName) \
5127-
case Inst::TagName: \
5127+
case Inst::InstTag::TagName: \
51285128
if (((const ClassName *)inst)->Exec(*this, input, inputLength, matchStart, inputOffset, nextSyncInputOffset, instPointer, contStack, assertionStack, qcTicks, firstIteration)) { return; } \
51295129
break;
51305130
#define M(TagName) MBase(TagName, TagName##Inst)
@@ -5601,7 +5601,7 @@ namespace UnifiedRegex
56015601
switch (inst->tag)
56025602
{
56035603
#define MBase(TagName, ClassName) \
5604-
case Inst::TagName: \
5604+
case Inst::InstTag::TagName: \
56055605
{ \
56065606
const ClassName *actualInst = static_cast<const ClassName *>(inst); \
56075607
actualInst->Print(w, InstPointerToLabel(instPointer), program->rep.insts.litbuf); \
@@ -5720,7 +5720,7 @@ namespace UnifiedRegex
57205720
switch(inst->tag)
57215721
{
57225722
#define MBase(TagName, ClassName) \
5723-
case Inst::TagName: \
5723+
case Inst::InstTag::TagName: \
57245724
{ \
57255725
const auto actualInst = static_cast<ClassName *>(inst); \
57265726
actualInst->FreeBody(rtAllocator); \
@@ -5782,7 +5782,7 @@ namespace UnifiedRegex
57825782
switch (inst->tag)
57835783
{
57845784
#define MBase(TagName, ClassName) \
5785-
case Inst::TagName: \
5785+
case Inst::InstTag::TagName: \
57865786
{ \
57875787
const ClassName *actualInst = static_cast<const ClassName *>(inst); \
57885788
curr += actualInst->Print(w, (Label)(isBaselineMode ? i++ : curr - rep.insts.insts), rep.insts.litbuf); \

0 commit comments

Comments
 (0)