mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Remove trivial try-catch statements
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
parent
30ae0db273
commit
3f8ce198c9
5 changed files with 166 additions and 287 deletions
|
|
@ -1236,21 +1236,15 @@ StringRef* DebuggerOperationsRef::BreakpointOperations::eval(StringRef* sourceCo
|
|||
|
||||
debugger->setStopState(ESCARGOT_DEBUGGER_IN_EVAL_MODE);
|
||||
|
||||
try {
|
||||
Value asValue(toImpl(sourceCode));
|
||||
Value evalResult(Value::ForceUninitialized);
|
||||
evalResult = state->context()->globalObject()->evalLocal(*state, asValue, state->thisValue(), reinterpret_cast<ByteCodeBlock*>(weakCodeRef())->m_codeBlock, true);
|
||||
Value asValue(toImpl(sourceCode));
|
||||
Value evalResult(Value::ForceUninitialized);
|
||||
evalResult = state->context()->globalObject()->evalLocal(*state, asValue, state->thisValue(), reinterpret_cast<ByteCodeBlock*>(weakCodeRef())->m_codeBlock, true);
|
||||
|
||||
if (evalResult.isObject()) {
|
||||
result = nullptr;
|
||||
objectIndex = putObject(toRef(evalResult.asObject()));
|
||||
} else {
|
||||
result = evalResult.toStringWithoutException(*state);
|
||||
}
|
||||
} catch (const Value& val) {
|
||||
result = val.toStringWithoutException(*state);
|
||||
|
||||
isError = true;
|
||||
if (evalResult.isObject()) {
|
||||
result = nullptr;
|
||||
objectIndex = putObject(toRef(evalResult.asObject()));
|
||||
} else {
|
||||
result = evalResult.toStringWithoutException(*state);
|
||||
}
|
||||
|
||||
debugger->setStopState(ESCARGOT_DEBUGGER_IN_WAIT_MODE);
|
||||
|
|
@ -1364,13 +1358,9 @@ static void fillObjectProperties(ExecutionState* state, Object* object, Object::
|
|||
|
||||
result[start + i].key = toRef(keys[i].toStringWithoutException(*state));
|
||||
|
||||
try {
|
||||
ObjectGetResult value = object->getOwnProperty(*state, propertyName);
|
||||
ObjectGetResult value = object->getOwnProperty(*state, propertyName);
|
||||
|
||||
result[start + i].value = toRef(value.value(*state, Value(object)));
|
||||
} catch (const Value& val) {
|
||||
// The value field is optional, and not filled on error.
|
||||
}
|
||||
result[start + i].value = toRef(value.value(*state, Value(object)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1385,14 +1375,10 @@ static void fillRecordProperties(ExecutionState* state, EnvironmentRecord* recor
|
|||
|
||||
result[i].key = toRef(name.string());
|
||||
|
||||
try {
|
||||
EnvironmentRecord::GetBindingValueResult value = record->getBindingValue(*state, name);
|
||||
ASSERT(value.m_hasBindingValue);
|
||||
EnvironmentRecord::GetBindingValueResult value = record->getBindingValue(*state, name);
|
||||
ASSERT(value.m_hasBindingValue);
|
||||
|
||||
result[i].value = toRef(value.m_value);
|
||||
} catch (const Value& val) {
|
||||
// The value field is optional, and not filled on error.
|
||||
}
|
||||
result[i].value = toRef(value.m_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1407,14 +1393,10 @@ static void fillRecordProperties(ExecutionState* state, ModuleEnvironmentRecord*
|
|||
|
||||
result[i].key = toRef(name.string());
|
||||
|
||||
try {
|
||||
EnvironmentRecord::GetBindingValueResult value = record->getBindingValue(*state, name);
|
||||
ASSERT(value.m_hasBindingValue);
|
||||
EnvironmentRecord::GetBindingValueResult value = record->getBindingValue(*state, name);
|
||||
ASSERT(value.m_hasBindingValue);
|
||||
|
||||
result[i].value = toRef(value.m_value);
|
||||
} catch (const Value& val) {
|
||||
// The value field is optional, and not filled on error.
|
||||
}
|
||||
result[i].value = toRef(value.m_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1699,154 +1699,102 @@ void Scanner::scanTemplate(Scanner::ScannerResult* token, bool head)
|
|||
size_t indexForError = this->index;
|
||||
bool tail = false;
|
||||
|
||||
try {
|
||||
while (!this->eof()) {
|
||||
char16_t ch = this->peekCharWithoutEOF();
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
if (ch == '`') {
|
||||
tail = true;
|
||||
while (!this->eof()) {
|
||||
char16_t ch = this->peekCharWithoutEOF();
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
if (ch == '`') {
|
||||
tail = true;
|
||||
terminated = true;
|
||||
break;
|
||||
} else if (ch == '$') {
|
||||
if (this->peekChar() == '{') {
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
terminated = true;
|
||||
break;
|
||||
} else if (ch == '$') {
|
||||
if (this->peekChar() == '{') {
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
terminated = true;
|
||||
break;
|
||||
}
|
||||
cooked += ch;
|
||||
raw += ch;
|
||||
} else if (ch == '\\') {
|
||||
raw += ch;
|
||||
ch = this->peekChar();
|
||||
if (!isLineTerminator(ch)) {
|
||||
auto currentIndex = this->index;
|
||||
++this->index;
|
||||
switch (ch) {
|
||||
case 'n':
|
||||
cooked += '\n';
|
||||
break;
|
||||
case 'r':
|
||||
cooked += '\r';
|
||||
break;
|
||||
case 't':
|
||||
cooked += '\t';
|
||||
break;
|
||||
case 'u':
|
||||
if (this->peekChar() == '{') {
|
||||
++this->index;
|
||||
cooked += this->scanUnicodeCodePointEscape();
|
||||
} else {
|
||||
const size_t restore = this->index;
|
||||
const char32_t unescaped = this->scanHexEscape(ch);
|
||||
if (unescaped != EMPTY_CODE_POINT) {
|
||||
ParserCharPiece piece(unescaped);
|
||||
cooked += UTF16StringDataNonGCStd(piece.data, piece.length);
|
||||
} else {
|
||||
this->throwUnexpectedToken(Messages::InvalidHexEscapeSequence);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'x': {
|
||||
const char32_t unescaped = this->scanHexEscape(ch);
|
||||
if (unescaped == EMPTY_CODE_POINT) {
|
||||
this->throwUnexpectedToken(Messages::InvalidHexEscapeSequence);
|
||||
}
|
||||
ParserCharPiece piece(unescaped);
|
||||
cooked += UTF16StringDataNonGCStd(piece.data, piece.length);
|
||||
break;
|
||||
}
|
||||
case 'b':
|
||||
cooked += '\b';
|
||||
break;
|
||||
case 'f':
|
||||
cooked += '\f';
|
||||
break;
|
||||
case 'v':
|
||||
cooked += '\v';
|
||||
break;
|
||||
default:
|
||||
if (ch == '0') {
|
||||
if (isDecimalDigit(this->peekChar())) {
|
||||
// Illegal: \01 \02 and so on
|
||||
this->throwUnexpectedToken(Messages::TemplateOctalLiteral);
|
||||
}
|
||||
cooked += (char16_t)'\0';
|
||||
} else if (isOctalDigit(ch)) {
|
||||
// Illegal: \1 \2
|
||||
this->throwUnexpectedToken(Messages::TemplateOctalLiteral);
|
||||
} else {
|
||||
cooked += ch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
auto endIndex = this->index;
|
||||
for (size_t i = currentIndex; i < endIndex; i++) {
|
||||
raw += this->sourceCharAt(i);
|
||||
}
|
||||
} else {
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
++this->lineNumber;
|
||||
if (ch == '\r' && this->peekChar() == '\n') {
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
}
|
||||
if (ch == 0x2028 || ch == 0x2029) {
|
||||
raw += ch;
|
||||
} else {
|
||||
raw += '\n';
|
||||
}
|
||||
this->lineStart = this->index;
|
||||
}
|
||||
} else if (isLineTerminator(ch)) {
|
||||
++this->lineNumber;
|
||||
if (ch == '\r' && this->peekChar() == '\n') {
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
}
|
||||
if (ch == 0x2028 || ch == 0x2029) {
|
||||
raw += ch;
|
||||
cooked += ch;
|
||||
} else {
|
||||
raw += '\n';
|
||||
}
|
||||
cooked += ch;
|
||||
raw += ch;
|
||||
} else if (ch == '\\') {
|
||||
raw += ch;
|
||||
ch = this->peekChar();
|
||||
if (!isLineTerminator(ch)) {
|
||||
auto currentIndex = this->index;
|
||||
++this->index;
|
||||
switch (ch) {
|
||||
case 'n':
|
||||
cooked += '\n';
|
||||
}
|
||||
this->lineStart = this->index;
|
||||
} else {
|
||||
cooked += ch;
|
||||
raw += ch;
|
||||
}
|
||||
}
|
||||
|
||||
if (!terminated) {
|
||||
this->throwUnexpectedToken();
|
||||
}
|
||||
} catch (esprima::Error* err) {
|
||||
error = new (GC) esprima::Error(*err);
|
||||
delete err;
|
||||
this->index = indexForError;
|
||||
|
||||
while (!this->eof()) {
|
||||
char16_t ch = this->peekCharWithoutEOF();
|
||||
++this->index;
|
||||
if (ch == '`') {
|
||||
tail = true;
|
||||
terminated = true;
|
||||
break;
|
||||
} else if (ch == '$') {
|
||||
if (this->peekChar() == '{') {
|
||||
++this->index;
|
||||
terminated = true;
|
||||
break;
|
||||
case 'r':
|
||||
cooked += '\r';
|
||||
break;
|
||||
case 't':
|
||||
cooked += '\t';
|
||||
break;
|
||||
case 'u':
|
||||
if (this->peekChar() == '{') {
|
||||
++this->index;
|
||||
cooked += this->scanUnicodeCodePointEscape();
|
||||
} else {
|
||||
const size_t restore = this->index;
|
||||
const char32_t unescaped = this->scanHexEscape(ch);
|
||||
if (unescaped != EMPTY_CODE_POINT) {
|
||||
ParserCharPiece piece(unescaped);
|
||||
cooked += UTF16StringDataNonGCStd(piece.data, piece.length);
|
||||
} else {
|
||||
// ignore exception
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'x': {
|
||||
const char32_t unescaped = this->scanHexEscape(ch);
|
||||
if (unescaped == EMPTY_CODE_POINT) {
|
||||
// ignore exception
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
}
|
||||
ParserCharPiece piece(unescaped);
|
||||
cooked += UTF16StringDataNonGCStd(piece.data, piece.length);
|
||||
break;
|
||||
}
|
||||
cooked += ch;
|
||||
raw += ch;
|
||||
} else if (isLineTerminator(ch)) {
|
||||
case 'b':
|
||||
cooked += '\b';
|
||||
break;
|
||||
case 'f':
|
||||
cooked += '\f';
|
||||
break;
|
||||
case 'v':
|
||||
cooked += '\v';
|
||||
break;
|
||||
default:
|
||||
if (ch == '0') {
|
||||
if (isDecimalDigit(this->peekChar())) {
|
||||
// Illegal: \01 \02 and so on
|
||||
// ignore exception
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
}
|
||||
cooked += (char16_t)'\0';
|
||||
} else if (isOctalDigit(ch)) {
|
||||
// Illegal: \1 \2
|
||||
// ignore exception
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
} else {
|
||||
cooked += ch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
auto endIndex = this->index;
|
||||
for (size_t i = currentIndex; i < endIndex; i++) {
|
||||
raw += this->sourceCharAt(i);
|
||||
}
|
||||
} else {
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
++this->lineNumber;
|
||||
if (ch == '\r' && this->peekChar() == '\n') {
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
}
|
||||
if (ch == 0x2028 || ch == 0x2029) {
|
||||
raw += ch;
|
||||
|
|
@ -1854,12 +1802,32 @@ void Scanner::scanTemplate(Scanner::ScannerResult* token, bool head)
|
|||
raw += '\n';
|
||||
}
|
||||
this->lineStart = this->index;
|
||||
} else {
|
||||
raw += ch;
|
||||
}
|
||||
} else if (isLineTerminator(ch)) {
|
||||
++this->lineNumber;
|
||||
if (ch == '\r' && this->peekChar() == '\n') {
|
||||
++this->index;
|
||||
indexForError = this->index;
|
||||
}
|
||||
if (ch == 0x2028 || ch == 0x2029) {
|
||||
raw += ch;
|
||||
cooked += ch;
|
||||
} else {
|
||||
raw += '\n';
|
||||
cooked += '\n';
|
||||
}
|
||||
this->lineStart = this->index;
|
||||
} else {
|
||||
cooked += ch;
|
||||
raw += ch;
|
||||
}
|
||||
}
|
||||
|
||||
if (!terminated) {
|
||||
// ignore exception
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
ScanTemplateResult* result = new ScanTemplateResult();
|
||||
result->head = head;
|
||||
result->tail = tail;
|
||||
|
|
|
|||
|
|
@ -953,11 +953,8 @@ Script::ModuleExecutionResult Script::innerModuleEvaluation(ExecutionState& stat
|
|||
ModuleEnvironmentRecord* moduleRecord = md->m_moduleRecord;
|
||||
moduleRecord->createBinding(state, state.context()->staticStrings().stringStarDefaultStar, false, false, false);
|
||||
|
||||
try {
|
||||
moduleRecord->initializeBinding(state, state.context()->staticStrings().stringStarDefaultStar, JSON::parse(state, sourceCode(), Value()));
|
||||
} catch (const Value& e) {
|
||||
md->m_evaluationError = EncodedValue(e);
|
||||
}
|
||||
// ignore exception
|
||||
moduleRecord->initializeBinding(state, state.context()->staticStrings().stringStarDefaultStar, JSON::parse(state, sourceCode(), Value()));
|
||||
|
||||
} else if (md->m_pendingAsyncDependencies.hasValue() && md->m_pendingAsyncDependencies.value() > 0) {
|
||||
// If module.[[PendingAsyncDependencies]] > 0, set module.[[AsyncEvaluating]] to true.
|
||||
|
|
@ -1139,13 +1136,8 @@ Script::ModuleExecutionResult Script::moduleExecute(ExecutionState& state, Optio
|
|||
bool gotException = false;
|
||||
|
||||
if (LIKELY(!m_topCodeBlock->isAsync())) {
|
||||
try {
|
||||
Interpreter::interpret(newState, byteCodeBlock, reinterpret_cast<size_t>(byteCodeBlock->m_code.data()), registerFile);
|
||||
} catch (const Value& e) {
|
||||
resultValue = e;
|
||||
gotException = true;
|
||||
}
|
||||
|
||||
// ignore exception
|
||||
Interpreter::interpret(newState, byteCodeBlock, reinterpret_cast<size_t>(byteCodeBlock->m_code.data()), registerFile);
|
||||
clearStack<512>();
|
||||
|
||||
// we give up program bytecodeblock after first excution for reducing memory usage
|
||||
|
|
|
|||
|
|
@ -423,37 +423,27 @@ ScriptParser::InitializeScriptResult ScriptParser::initializeScript(String* orig
|
|||
|
||||
// Generate ByteCode
|
||||
if (LIKELY(needByteCodeGeneration)) {
|
||||
try {
|
||||
#if defined(ENABLE_CODE_CACHE)
|
||||
// Store cache
|
||||
if (cacheable) {
|
||||
codeCache->prepareCacheWriting(srcHash);
|
||||
// Store cache
|
||||
if (cacheable) {
|
||||
codeCache->prepareCacheWriting(srcHash);
|
||||
|
||||
// For storing cache, CodeBlockTree is firstly saved
|
||||
codeCache->storeCodeBlockTree(topCodeBlock, m_codeBlockCacheInfo);
|
||||
// For storing cache, CodeBlockTree is firstly saved
|
||||
codeCache->storeCodeBlockTree(topCodeBlock, m_codeBlockCacheInfo);
|
||||
|
||||
// After CodeBlockTree, ByteCode and StringTable are stored sequentially
|
||||
topCodeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(m_context, topCodeBlock, programNode, inWith, true);
|
||||
// After CodeBlockTree, ByteCode and StringTable are stored sequentially
|
||||
topCodeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(m_context, topCodeBlock, programNode, inWith, true);
|
||||
|
||||
codeCache->postCacheWriting(srcHash);
|
||||
deleteCodeBlockCacheInfo();
|
||||
codeCache->postCacheWriting(srcHash);
|
||||
deleteCodeBlockCacheInfo();
|
||||
|
||||
ESCARGOT_LOG_INFO("[CodeCache] Store CodeCache Done (%s)\n", srcName->toUTF8StringData().data());
|
||||
} else {
|
||||
topCodeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(m_context, topCodeBlock, programNode, inWith, false);
|
||||
}
|
||||
#else
|
||||
topCodeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(m_context, topCodeBlock, programNode, inWith);
|
||||
#endif
|
||||
} catch (const char* message) {
|
||||
m_context->astAllocator().reset();
|
||||
GC_enable();
|
||||
|
||||
ScriptParser::InitializeScriptResult result;
|
||||
result.parseErrorCode = ErrorCode::SyntaxError;
|
||||
result.parseErrorMessage = String::fromASCII(message, strlen(message));
|
||||
return result;
|
||||
ESCARGOT_LOG_INFO("[CodeCache] Store CodeCache Done (%s)\n", srcName->toUTF8StringData().data());
|
||||
} else {
|
||||
topCodeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(m_context, topCodeBlock, programNode, inWith, false);
|
||||
}
|
||||
#else
|
||||
topCodeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(m_context, topCodeBlock, programNode, inWith);
|
||||
#endif
|
||||
}
|
||||
|
||||
// reset ASTAllocator
|
||||
|
|
@ -502,17 +492,7 @@ void ScriptParser::generateFunctionByteCode(ExecutionState& state, InterpretedCo
|
|||
}
|
||||
|
||||
// Generate ByteCode
|
||||
try {
|
||||
codeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(state.context(), codeBlock, functionNode);
|
||||
} catch (const char* message) {
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
// reset ASTAllocator
|
||||
m_context->astAllocator().reset();
|
||||
GC_enable();
|
||||
// ignore exception
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, message);
|
||||
RELEASE_ASSERT_NOT_REACHED();
|
||||
}
|
||||
codeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(state.context(), codeBlock, functionNode);
|
||||
|
||||
// reset ASTAllocator
|
||||
m_context->astAllocator().reset();
|
||||
|
|
@ -586,45 +566,28 @@ ScriptParser::InitializeScriptResult ScriptParser::initializeScriptWithDebugger(
|
|||
Script* script = nullptr;
|
||||
|
||||
// Parsing
|
||||
try {
|
||||
ASTClassInfo* outerClassInfo = esprima::generateClassInfoFrom(m_context, parentCodeBlock);
|
||||
ASTClassInfo* outerClassInfo = esprima::generateClassInfoFrom(m_context, parentCodeBlock);
|
||||
|
||||
programNode = esprima::parseProgram(m_context, sourceView, outerClassInfo, isModule, strictFromOutside, inWith, SIZE_MAX, allowSC, allowSP, allowNewTarget, allowArguments);
|
||||
programNode = esprima::parseProgram(m_context, sourceView, outerClassInfo, isModule, strictFromOutside, inWith, SIZE_MAX, allowSC, allowSP, allowNewTarget, allowArguments);
|
||||
|
||||
script = new Script(srcName, source, programNode->moduleData(), !parentCodeBlock, originLineOffset);
|
||||
if (parentCodeBlock) {
|
||||
programNode->scopeContext()->m_hasEval = parentCodeBlock->hasEval();
|
||||
programNode->scopeContext()->m_hasWith = parentCodeBlock->hasWith();
|
||||
programNode->scopeContext()->m_isClassConstructor = parentCodeBlock->isClassConstructor();
|
||||
programNode->scopeContext()->m_isDerivedClassConstructor = parentCodeBlock->isDerivedClassConstructor();
|
||||
programNode->scopeContext()->m_isClassMethod = parentCodeBlock->isClassMethod();
|
||||
programNode->scopeContext()->m_isClassStaticMethod = parentCodeBlock->isClassStaticMethod();
|
||||
programNode->scopeContext()->m_allowSuperCall = parentCodeBlock->allowSuperCall();
|
||||
programNode->scopeContext()->m_allowSuperProperty = parentCodeBlock->allowSuperProperty();
|
||||
topCodeBlock = generateCodeBlockTreeFromASTWalker(m_context, sourceView, script, programNode->scopeContext(), parentCodeBlock, isEvalMode, isEvalCodeInFunction);
|
||||
} else {
|
||||
topCodeBlock = generateCodeBlockTreeFromAST(m_context, sourceView, script, programNode, isEvalMode, isEvalCodeInFunction);
|
||||
}
|
||||
|
||||
generateCodeBlockTreeFromASTWalkerPostProcess(topCodeBlock);
|
||||
} catch (esprima::Error* orgError) {
|
||||
// reset ASTAllocator
|
||||
m_context->astAllocator().reset();
|
||||
|
||||
if (m_context->debuggerEnabled()) {
|
||||
m_context->debugger()->parseCompleted(originSource ? originSource : source, srcName, originLineOffset, orgError->message);
|
||||
m_context->debugger()->clearParsingData();
|
||||
m_context->debugger()->setInDebuggingCodeMode(false);
|
||||
}
|
||||
|
||||
GC_enable();
|
||||
|
||||
ScriptParser::InitializeScriptResult result;
|
||||
result.parseErrorCode = orgError->errorCode;
|
||||
result.parseErrorMessage = orgError->message;
|
||||
return result;
|
||||
script = new Script(srcName, source, programNode->moduleData(), !parentCodeBlock, originLineOffset);
|
||||
if (parentCodeBlock) {
|
||||
programNode->scopeContext()->m_hasEval = parentCodeBlock->hasEval();
|
||||
programNode->scopeContext()->m_hasWith = parentCodeBlock->hasWith();
|
||||
programNode->scopeContext()->m_isClassConstructor = parentCodeBlock->isClassConstructor();
|
||||
programNode->scopeContext()->m_isDerivedClassConstructor = parentCodeBlock->isDerivedClassConstructor();
|
||||
programNode->scopeContext()->m_isClassMethod = parentCodeBlock->isClassMethod();
|
||||
programNode->scopeContext()->m_isClassStaticMethod = parentCodeBlock->isClassStaticMethod();
|
||||
programNode->scopeContext()->m_allowSuperCall = parentCodeBlock->allowSuperCall();
|
||||
programNode->scopeContext()->m_allowSuperProperty = parentCodeBlock->allowSuperProperty();
|
||||
topCodeBlock = generateCodeBlockTreeFromASTWalker(m_context, sourceView, script, programNode->scopeContext(), parentCodeBlock, isEvalMode, isEvalCodeInFunction);
|
||||
} else {
|
||||
topCodeBlock = generateCodeBlockTreeFromAST(m_context, sourceView, script, programNode, isEvalMode, isEvalCodeInFunction);
|
||||
}
|
||||
|
||||
generateCodeBlockTreeFromASTWalkerPostProcess(topCodeBlock);
|
||||
|
||||
|
||||
// dump Code Block
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
|
|
@ -638,41 +601,22 @@ ScriptParser::InitializeScriptResult ScriptParser::initializeScriptWithDebugger(
|
|||
script->m_topCodeBlock = topCodeBlock;
|
||||
|
||||
// Generate ByteCode
|
||||
try {
|
||||
topCodeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(m_context, topCodeBlock, programNode, inWith);
|
||||
topCodeBlock->m_byteCodeBlock = ByteCodeGenerator::generateByteCode(m_context, topCodeBlock, programNode, inWith);
|
||||
|
||||
// reset ASTAllocator
|
||||
m_context->astAllocator().reset();
|
||||
// reset ASTAllocator
|
||||
m_context->astAllocator().reset();
|
||||
|
||||
Debugger* debugger = m_context->debugger();
|
||||
if (debugger != nullptr) {
|
||||
recursivelyGenerateChildrenByteCode(topCodeBlock);
|
||||
Debugger* debugger = m_context->debugger();
|
||||
if (debugger != nullptr) {
|
||||
recursivelyGenerateChildrenByteCode(topCodeBlock);
|
||||
|
||||
debugger->parseCompleted(originSource ? originSource : source, srcName, originLineOffset);
|
||||
debugger->clearParsingData();
|
||||
debugger->setInDebuggingCodeMode(false);
|
||||
}
|
||||
|
||||
GC_enable();
|
||||
} catch (const char* message) {
|
||||
m_context->astAllocator().reset();
|
||||
|
||||
String* msg = String::fromASCII(message, strlen(message));
|
||||
|
||||
if (m_context->debuggerEnabled()) {
|
||||
m_context->debugger()->parseCompleted(originSource ? originSource : source, srcName, originLineOffset, msg);
|
||||
m_context->debugger()->clearParsingData();
|
||||
m_context->debugger()->setInDebuggingCodeMode(false);
|
||||
}
|
||||
|
||||
GC_enable();
|
||||
|
||||
ScriptParser::InitializeScriptResult result;
|
||||
result.parseErrorCode = ErrorCode::SyntaxError;
|
||||
result.parseErrorMessage = msg;
|
||||
return result;
|
||||
debugger->parseCompleted(originSource ? originSource : source, srcName, originLineOffset);
|
||||
debugger->clearParsingData();
|
||||
debugger->setInDebuggingCodeMode(false);
|
||||
}
|
||||
|
||||
GC_enable();
|
||||
|
||||
ScriptParser::InitializeScriptResult result;
|
||||
result.script = script;
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -283,16 +283,9 @@ RegExpObject::RegExpCacheEntry& RegExpObject::getCacheEntryAndCompileIfNeeded(Ex
|
|||
} else {
|
||||
const char* yarrError = nullptr;
|
||||
JSC::Yarr::YarrPattern* yarrPattern = nullptr;
|
||||
try {
|
||||
JSC::Yarr::ErrorCode errorCode = JSC::Yarr::ErrorCode::NoError;
|
||||
yarrPattern = JSC::Yarr::YarrPattern::createYarrPattern(source, (JSC::Yarr::RegExpFlags)option, errorCode);
|
||||
yarrError = JSC::Yarr::errorMessage(errorCode);
|
||||
} catch (const std::bad_alloc& e) {
|
||||
// Return Exception Done!
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, "got too complicated RegExp pattern to process");
|
||||
auto iter = cache->insert(std::make_pair(RegExpCacheKey(source, option), RegExpCacheEntry())).first;
|
||||
return iter.value();
|
||||
}
|
||||
JSC::Yarr::ErrorCode errorCode = JSC::Yarr::ErrorCode::NoError;
|
||||
yarrPattern = JSC::Yarr::YarrPattern::createYarrPattern(source, (JSC::Yarr::RegExpFlags)option, errorCode);
|
||||
yarrError = JSC::Yarr::errorMessage(errorCode);
|
||||
auto iter = cache->insert(std::make_pair(RegExpCacheKey(source, option), RegExpCacheEntry(yarrError, yarrPattern))).first;
|
||||
return iter.value();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue