Skip to content

Commit

Permalink
Unify regular expression notation as RegExp
Browse files Browse the repository at this point in the history
Signed-off-by: HyukWoo Park <[email protected]>
  • Loading branch information
clover2123 authored and bbrto21 committed Aug 24, 2020
1 parent dbe6cd0 commit a96f39f
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 28 deletions.
18 changes: 9 additions & 9 deletions src/codecache/CodeCacheReaderWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ void CodeCacheWriter::storeByteCodeStream(ByteCodeBlock* block)
STORE_ATOMICSTRING_RELOC(m_propertyName);
break;
}
case LoadRegexpOpcode: {
LoadRegexp* bc = (LoadRegexp*)currentCode;
case LoadRegExpOpcode: {
LoadRegExp* bc = (LoadRegExp*)currentCode;

String* bodyString = bc->m_body;
String* optionString = bc->m_option;
Expand Down Expand Up @@ -785,8 +785,8 @@ void CodeCacheReader::loadByteCodeStream(Context* context, ByteCodeBlock* block)

InterpretedCodeBlock* codeBlock = block->codeBlock();

// mark for LoadRegexp bytecode
bool bodyStringForLoadRegexp = true;
// mark for LoadRegExp bytecode
bool bodyStringForLoadRegExp = true;

for (size_t i = 0; i < relocInfoVector.size(); i++) {
ByteCodeRelocInfo& info = relocInfoVector[i];
Expand Down Expand Up @@ -890,20 +890,20 @@ void CodeCacheReader::loadByteCodeStream(Context* context, ByteCodeBlock* block)
LOAD_ATOMICSTRING_RELOC(m_propertyName);
break;
}
case LoadRegexpOpcode: {
LoadRegexp* bc = (LoadRegexp*)currentCode;
case LoadRegExpOpcode: {
LoadRegExp* bc = (LoadRegExp*)currentCode;

String* bodyString = bc->m_body;
String* optionString = bc->m_option;

if (bodyStringForLoadRegexp) {
if (bodyStringForLoadRegExp) {
ASSERT(info.dataOffset < stringLiteralData.size());
bc->m_body = stringLiteralData[info.dataOffset];
bodyStringForLoadRegexp = false;
bodyStringForLoadRegExp = false;
} else {
ASSERT(info.dataOffset < stringLiteralData.size());
bc->m_option = stringLiteralData[info.dataOffset];
bodyStringForLoadRegexp = true;
bodyStringForLoadRegExp = true;
}
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/interpreter/ByteCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct GlobalVariableAccessCacheItem;
F(MarkEnumerateKey, 2, 0) \
F(IteratorOperation, 0, 0) \
F(GetMethod, 0, 0) \
F(LoadRegexp, 1, 0) \
F(LoadRegExp, 1, 0) \
F(WithOperation, 0, 0) \
F(ObjectDefineGetterSetter, 0, 0) \
F(CallFunctionComplexCase, 0, 0) \
Expand Down Expand Up @@ -2231,10 +2231,10 @@ class GetMethod : public ByteCode {
#endif
};

class LoadRegexp : public ByteCode {
class LoadRegExp : public ByteCode {
public:
LoadRegexp(const ByteCodeLOC& loc, const size_t registerIndex, String* body, String* opt)
: ByteCode(Opcode::LoadRegexpOpcode, loc)
LoadRegExp(const ByteCodeLOC& loc, const size_t registerIndex, String* body, String* opt)
: ByteCode(Opcode::LoadRegExpOpcode, loc)
, m_registerIndex(registerIndex)
, m_body(body)
, m_option(opt)
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter/ByteCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ void ByteCodeGenerator::relocateByteCode(ByteCodeBlock* block)
ASSIGN_STACKINDEX_IF_NEEDED(cd->m_registerIndex, stackBase, stackBaseWillBe, stackVariableSize);
break;
}
case LoadRegexpOpcode: {
LoadRegexp* cd = (LoadRegexp*)currentCode;
case LoadRegExpOpcode: {
LoadRegExp* cd = (LoadRegExp*)currentCode;
ASSIGN_STACKINDEX_IF_NEEDED(cd->m_registerIndex, stackBase, stackBaseWillBe, stackVariableSize);
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/interpreter/ByteCodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,12 +1148,12 @@ Value ByteCodeInterpreter::interpret(ExecutionState* state, ByteCodeBlock* byteC
NEXT_INSTRUCTION();
}

DEFINE_OPCODE(LoadRegexp)
DEFINE_OPCODE(LoadRegExp)
:
{
LoadRegexp* code = (LoadRegexp*)programCounter;
LoadRegExp* code = (LoadRegExp*)programCounter;
registerFile[code->m_registerIndex] = new RegExpObject(*state, code->m_body, code->m_option);
ADD_PROGRAM_COUNTER(LoadRegexp);
ADD_PROGRAM_COUNTER(LoadRegExp);
NEXT_INSTRUCTION();
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ void Scanner::scanRegExp(Scanner::ScannerResult* token)
result.body = body;
result.flags = flags;
token->setResult(Token::RegularExpressionToken, this->lineNumber, this->lineStart, start, this->index);
token->valueRegexp = result;
token->valueRegExp = result;
}

// ECMA-262 11.6.2.1 Keywords
Expand Down
4 changes: 2 additions & 2 deletions src/parser/Lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class Scanner {
, lineStart(0)
, start(0)
, end(0)
, valueRegexp()
, valueRegExp()
{
}

Expand All @@ -286,7 +286,7 @@ class Scanner {
ScannerSourceStringView valueStringLiteralData;
double valueNumber;
ScanTemplateResult* valueTemplate;
ScanRegExpResult valueRegexp;
ScanRegExpResult valueRegExp;
KeywordKind valueKeywordKind;
};

Expand Down
2 changes: 1 addition & 1 deletion src/parser/ast/RegExpLiteralNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RegExpLiteralNode : public Node {
{
codeBlock->m_stringLiteralData.pushBack(m_body);
codeBlock->m_stringLiteralData.pushBack(m_flag);
codeBlock->pushCode(LoadRegexp(ByteCodeLOC(m_loc.index), dstRegister, m_body, m_flag), context, this);
codeBlock->pushCode(LoadRegExp(ByteCodeLOC(m_loc.index), dstRegister, m_body, m_flag), context, this);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion src/parser/esprima_cpp/esprima.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ class Parser {
ALLOC_TOKEN(token);
this->nextRegexToken(token);
// raw = this->getTokenRaw(token);
return this->finalize(node, builder.createRegExpLiteralNode(token->valueRegexp.body, token->valueRegexp.flags));
return this->finalize(node, builder.createRegExpLiteralNode(token->valueRegExp.body, token->valueRegExp.flags));
}
default: {
ALLOC_TOKEN(token);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ObjectRareData::ObjectRareData(Object* obj)
m_isArrayObjectLengthWritable = true;
m_isSpreadArrayObject = false;
m_shouldUpdateEnumerateObject = false;
m_hasNonWritableLastIndexRegexpObject = false;
m_hasNonWritableLastIndexRegExpObject = false;
m_arrayObjectFastModeBufferExpandCount = 0;
m_extraData = nullptr;
m_internalSlot = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct ObjectRareData : public PointerValue {
bool m_isArrayObjectLengthWritable : 1;
bool m_isSpreadArrayObject : 1;
bool m_shouldUpdateEnumerateObject : 1; // used only for Array Object when ArrayObject::deleteOwnProperty called
bool m_hasNonWritableLastIndexRegexpObject : 1;
bool m_hasNonWritableLastIndexRegExpObject : 1;
uint8_t m_arrayObjectFastModeBufferExpandCount : 8;
void* m_extraData;
Object* m_prototype;
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/RegExpObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void RegExpObject::initWithOption(ExecutionState& state, String* source, Option

void RegExpObject::setLastIndex(ExecutionState& state, const Value& v)
{
if (UNLIKELY(hasRareData() && rareData()->m_hasNonWritableLastIndexRegexpObject && (m_option & (Option::Sticky | Option::Global)))) {
if (UNLIKELY(hasRareData() && rareData()->m_hasNonWritableLastIndexRegExpObject && (m_option & (Option::Sticky | Option::Global)))) {
Object::throwCannotWriteError(state, ObjectStructurePropertyName(state.context()->staticStrings().lastIndex));
}
m_lastIndex = v;
Expand All @@ -206,9 +206,9 @@ bool RegExpObject::defineOwnProperty(ExecutionState& state, const ObjectProperty
bool returnValue = Object::defineOwnProperty(state, P, desc);
if (!P.isUIntType() && returnValue && P.objectStructurePropertyName() == ObjectStructurePropertyName(state.context()->staticStrings().lastIndex)) {
if (!structure()->readProperty((size_t)ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER).m_descriptor.isWritable()) {
ensureRareData()->m_hasNonWritableLastIndexRegexpObject = true;
ensureRareData()->m_hasNonWritableLastIndexRegExpObject = true;
} else {
ensureRareData()->m_hasNonWritableLastIndexRegexpObject = false;
ensureRareData()->m_hasNonWritableLastIndexRegExpObject = false;
}
}
return returnValue;
Expand Down

0 comments on commit a96f39f

Please sign in to comment.