From be21badc12a56c2efc807ead29c18cdb0b8e527f Mon Sep 17 00:00:00 2001 From: ctw-ian Date: Fri, 5 Aug 2022 20:18:58 +0800 Subject: [PATCH] Fix incorrect static index in class literal buffer Issue:I5L025 Signed-off-by: ctw-ian Change-Id: I67f81064365f38412b287283aa85ab96580a3cfc --- es2panda/compiler/core/emitter/emitter.cpp | 2 -- es2panda/ir/base/classDefinition.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 6 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/ir/base/classDefinition.cpp b/es2panda/ir/base/classDefinition.cpp index 03507d5551..e249bcd7f8 100644 --- a/es2panda/ir/base/classDefinition.cpp +++ b/es2panda/ir/base/classDefinition.cpp @@ -165,6 +165,10 @@ int32_t ClassDefinition::CreateClassStaticProperties(compiler::PandaGen *pg, uti break; } + if (!prop->IsStatic()) { + instancePropertyCount++; + } + literalBuf->Add(pg->Allocator()->New(name)); literalBuf->Add(nullptr); // save for method internalname literalBuf->Add(nullptr); // save for method affiliate @@ -198,10 +202,6 @@ int32_t ClassDefinition::CreateClassStaticProperties(compiler::PandaGen *pg, uti UNREACHABLE(); } } - - if (!prop->IsStatic()) { - instancePropertyCount++; - } } /* Static items are stored at the end of the buffer */ -- Gitee