From 24c21967bb6dfaf38bcd15b1c21e28122c2d1aae Mon Sep 17 00:00:00 2001 From: ctw-ian Date: Fri, 5 Aug 2022 10:44:20 +0800 Subject: [PATCH] Fix token scanning Issue:I5KTWO Signed-off-by: ctw-ian Change-Id: Icaeffc38814de3e23699c2432bd7e2c67333f47a --- es2panda/compiler/core/emitter/emitter.cpp | 2 -- es2panda/parser/expressionParser.cpp | 2 ++ es2panda/parser/parserImpl.cpp | 1 + es2panda/parser/statementParser.cpp | 8 ++++++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/es2panda/compiler/core/emitter/emitter.cpp b/es2panda/compiler/core/emitter/emitter.cpp index ecec4eead8..31e8a224a9 100644 --- a/es2panda/compiler/core/emitter/emitter.cpp +++ b/es2panda/compiler/core/emitter/emitter.cpp @@ -208,8 +208,6 @@ void FunctionEmitter::GenInstructionDebugInfo(const IRNode *ins, panda::pandasm: constexpr size_t INVALID_LINE = -1; constexpr uint32_t INVALID_COL = -1; - ASSERT(astNode != nullptr); - if (astNode == FIRST_NODE_OF_FUNCTION) { astNode = pg_->Debuginfo().firstStmt; if (!astNode) { diff --git a/es2panda/parser/expressionParser.cpp b/es2panda/parser/expressionParser.cpp index 5f33b377dc..598226d6bf 100644 --- a/es2panda/parser/expressionParser.cpp +++ b/es2panda/parser/expressionParser.cpp @@ -2032,6 +2032,7 @@ ir::Expression *ParserImpl::ParsePropertyValue(const ir::PropertyKind *propertyK ir::ScriptFunction *methodDefinitonNode = ParseFunction(*methodStatus | ParserStatus::FUNCTION | ParserStatus::ALLOW_SUPER); + lexer_->NextToken(); methodDefinitonNode->AddFlag(ir::ScriptFunctionFlags::METHOD); size_t paramsSize = methodDefinitonNode->Params().size(); @@ -2330,6 +2331,7 @@ ir::FunctionExpression *ParserImpl::ParseFunctionExpression(ParserStatus newStat } ir::ScriptFunction *functionNode = ParseFunction(newStatus); + lexer_->NextToken(); functionNode->SetStart(startLoc); if (ident) { diff --git a/es2panda/parser/parserImpl.cpp b/es2panda/parser/parserImpl.cpp index 83da26513a..3344f0ba2d 100644 --- a/es2panda/parser/parserImpl.cpp +++ b/es2panda/parser/parserImpl.cpp @@ -2006,6 +2006,7 @@ ir::MethodDefinition *ParserImpl::ParseClassMethod(ClassElmentDescriptor *desc, } ir::ScriptFunction *func = ParseFunction(desc->newStatus, isDeclare); + lexer_->NextToken(); if (func->IsOverload() && !decorators.empty()) { ThrowSyntaxError("A decorator can only decorate a method implementation, not an overload.", diff --git a/es2panda/parser/statementParser.cpp b/es2panda/parser/statementParser.cpp index 4118364e21..17a9d2d75c 100644 --- a/es2panda/parser/statementParser.cpp +++ b/es2panda/parser/statementParser.cpp @@ -797,14 +797,15 @@ ir::BlockStatement *ParserImpl::ParseBlockStatement(binder::Scope *scope) blockNode->SetRange({startLoc, lexer_->GetToken().End()}); scope->BindNode(blockNode); - lexer_->NextToken(); return blockNode; } ir::BlockStatement *ParserImpl::ParseBlockStatement() { auto localCtx = binder::LexicalScope(Binder()); - return ParseBlockStatement(localCtx.GetScope()); + auto *blockNode = ParseBlockStatement(localCtx.GetScope()); + lexer_->NextToken(); + return blockNode; } ir::BreakStatement *ParserImpl::ParseBreakStatement() @@ -984,6 +985,7 @@ ir::FunctionDeclaration *ParserImpl::ParseFunctionDeclaration(bool canBeAnonymou lexer_->GetToken().Type() != lexer::TokenType::KEYW_AWAIT) { if (canBeAnonymous) { ir::ScriptFunction *func = ParseFunction(newStatus, isDeclare); + lexer_->NextToken(); func->SetStart(startLoc); func->SetAsExportDefault(); @@ -1013,6 +1015,7 @@ ir::FunctionDeclaration *ParserImpl::ParseFunctionDeclaration(bool canBeAnonymou newStatus |= ParserStatus::FUNCTION_DECLARATION; ir::ScriptFunction *func = ParseFunction(newStatus, isDeclare); + lexer_->NextToken(); func->SetIdent(identNode); func->SetStart(startLoc); @@ -1646,6 +1649,7 @@ ir::CatchClause *ParserImpl::ParseCatchClause() catchScope->AssignParamScope(catchParamScope); ir::BlockStatement *catchBlock = ParseBlockStatement(catchScope); + lexer_->NextToken(); lexer::SourcePosition endLoc = catchBlock->End(); auto *catchClause = AllocNode(catchScope, param, catchBlock); -- Gitee