Eliminate duplicated code

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
HyukWoo Park 2023-03-27 10:34:52 +09:00 committed by Patrick Kim
commit de4c7eb0db
14 changed files with 129 additions and 290 deletions

View file

@ -1722,23 +1722,22 @@ public:
// wrap right expression with arrow function
result = this->finalize(startNode, builder.createArrowFunctionExpressionNode(subCodeBlockIndex));
} else {
auto startNode = this->createNode();
auto node = this->createNode();
InterpretedCodeBlock* currentTarget = this->codeBlock;
size_t orgIndex = this->lookahead.start;
InterpretedCodeBlock* childBlock = currentTarget->childBlockAt(this->subCodeBlockIndex);
this->scanner->index = childBlock->src().length() + childBlock->functionStart().index - currentTarget->functionStart().index;
this->scanner->lineNumber = childBlock->functionStart().line;
this->scanner->lineStart = childBlock->functionStart().index - childBlock->functionStart().column;
this->scanner->lineNumber = childBlock->functionStart().line;
this->lookahead.lineNumber = this->scanner->lineNumber;
this->lookahead.lineStart = this->scanner->lineStart;
this->lookahead.lineNumber = this->scanner->lineNumber;
this->nextToken();
// increase subCodeBlockIndex because parsing of an internal function is skipped
this->subCodeBlockIndex++;
result = this->finalize(startNode, builder.createArrowFunctionExpressionNode(subCodeBlockIndex));
result = this->finalize(node, builder.createArrowFunctionExpressionNode(subCodeBlockIndex));
}
return result;
@ -3605,7 +3604,6 @@ public:
} else {
auto startNode = this->createNode();
InterpretedCodeBlock* currentTarget = this->codeBlock;
size_t orgIndex = this->lookahead.start;
InterpretedCodeBlock* childBlock = currentTarget->childBlockAt(this->subCodeBlockIndex);
this->scanner->index = childBlock->src().length() + childBlock->functionStart().index - currentTarget->functionStart().index;