14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_JSPANDAFILE_LITERAL_DATA_EXTRACTOR_H 174514f5e3Sopenharmony_ci#define ECMASCRIPT_JSPANDAFILE_LITERAL_DATA_EXTRACTOR_H 184514f5e3Sopenharmony_ci 194514f5e3Sopenharmony_ci#include "ecmascript/jspandafile/js_pandafile.h" 204514f5e3Sopenharmony_ci#include "ecmascript/js_tagged_value-inl.h" 214514f5e3Sopenharmony_ci#include "libpandafile/literal_data_accessor-inl.h" 224514f5e3Sopenharmony_ci 234514f5e3Sopenharmony_cinamespace panda::ecmascript { 244514f5e3Sopenharmony_ciclass LiteralDataExtractor { 254514f5e3Sopenharmony_cipublic: 264514f5e3Sopenharmony_ci LiteralDataExtractor() = default; 274514f5e3Sopenharmony_ci virtual ~LiteralDataExtractor() = default; 284514f5e3Sopenharmony_ci 294514f5e3Sopenharmony_ci DEFAULT_NOEXCEPT_MOVE_SEMANTIC(LiteralDataExtractor); 304514f5e3Sopenharmony_ci DEFAULT_COPY_SEMANTIC(LiteralDataExtractor); 314514f5e3Sopenharmony_ci 324514f5e3Sopenharmony_ci static constexpr uint32_t LITERALARRAY_VALUE_LOW_BOUNDARY = 100; 334514f5e3Sopenharmony_ci 344514f5e3Sopenharmony_ci // Parameter 'size_t index' is for old isa, and 'EntityId id' for new isa. 354514f5e3Sopenharmony_ci static void ExtractObjectDatas(JSThread *thread, const JSPandaFile *jsPandaFile, size_t index, 364514f5e3Sopenharmony_ci JSMutableHandle<TaggedArray> elements, JSMutableHandle<TaggedArray> properties, 374514f5e3Sopenharmony_ci JSHandle<ConstantPool> constpool, const CString &entryPoint = ""); 384514f5e3Sopenharmony_ci static PUBLIC_API void ExtractObjectDatas(JSThread *thread, const JSPandaFile *jsPandaFile, EntityId id, 394514f5e3Sopenharmony_ci JSMutableHandle<TaggedArray> elements, 404514f5e3Sopenharmony_ci JSMutableHandle<TaggedArray> properties, 414514f5e3Sopenharmony_ci JSHandle<ConstantPool> constpool, const CString &entryPoint = "", 424514f5e3Sopenharmony_ci bool isLoadedAOT = false, 434514f5e3Sopenharmony_ci JSHandle<AOTLiteralInfo> entryIndexes = JSHandle<AOTLiteralInfo>()); 444514f5e3Sopenharmony_ci 454514f5e3Sopenharmony_ci static JSHandle<TaggedArray> GetDatasIgnoreType(JSThread *thread, const JSPandaFile *jsPandaFile, size_t index, 464514f5e3Sopenharmony_ci JSHandle<ConstantPool> constpool, const CString &entryPoint = ""); 474514f5e3Sopenharmony_ci static PUBLIC_API JSHandle<TaggedArray> GetDatasIgnoreType(JSThread *thread, const JSPandaFile *jsPandaFile, 484514f5e3Sopenharmony_ci EntityId id, JSHandle<ConstantPool> constpool, const CString &entryPoint = "", 494514f5e3Sopenharmony_ci bool isLoadedAOT = false, JSHandle<AOTLiteralInfo> entryIndexes = JSHandle<AOTLiteralInfo>(), 504514f5e3Sopenharmony_ci ElementsKind *newKind = nullptr, JSHandle<JSTaggedValue> sendableEnv = JSHandle<JSTaggedValue>(), 514514f5e3Sopenharmony_ci ClassKind classKind = ClassKind::NON_SENDABLE); 524514f5e3Sopenharmony_ci static PUBLIC_API JSHandle<TaggedArray> GetDatasIgnoreTypeForClass(JSThread *thread, const JSPandaFile *jsPandaFile, 534514f5e3Sopenharmony_ci EntityId id, JSHandle<ConstantPool> constpool, const CString &entryPoint = "", 544514f5e3Sopenharmony_ci bool isLoadedAOT = false, JSHandle<AOTLiteralInfo> entryIndexes = JSHandle<AOTLiteralInfo>(), 554514f5e3Sopenharmony_ci ElementsKind *newKind = nullptr, JSHandle<JSTaggedValue> sendableEnv = JSHandle<JSTaggedValue>(), 564514f5e3Sopenharmony_ci ClassKind classKind = ClassKind::NON_SENDABLE); 574514f5e3Sopenharmony_ci 584514f5e3Sopenharmony_ci static JSHandle<TaggedArray> GetDatasIgnoreTypeForClass(JSThread *thread, const JSPandaFile *jsPandaFile, 594514f5e3Sopenharmony_ci size_t index, JSHandle<ConstantPool> constpool, 604514f5e3Sopenharmony_ci const CString &entryPoint = ""); 614514f5e3Sopenharmony_ci 624514f5e3Sopenharmony_ci static JSHandle<JSFunction> DefineMethodInLiteral(JSThread *thread, const JSPandaFile *jsPandaFile, 634514f5e3Sopenharmony_ci uint32_t offset, JSHandle<ConstantPool> constpool, 644514f5e3Sopenharmony_ci FunctionKind kind, uint16_t length, 654514f5e3Sopenharmony_ci const CString &entryPoint = "", 664514f5e3Sopenharmony_ci bool isLoadedAOT = false, uint32_t entryIndex = 0, 674514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> sendableEnv = JSHandle<JSTaggedValue>(), 684514f5e3Sopenharmony_ci ClassKind classKind = ClassKind::NON_SENDABLE); 694514f5e3Sopenharmony_ci 704514f5e3Sopenharmony_ci static void PUBLIC_API GetMethodOffsets(const JSPandaFile *jsPandaFile, size_t index, 714514f5e3Sopenharmony_ci std::vector<uint32_t> &methodOffsets); 724514f5e3Sopenharmony_ci 734514f5e3Sopenharmony_ci static void PUBLIC_API GetMethodOffsets(const JSPandaFile *jsPandaFile, EntityId id, 744514f5e3Sopenharmony_ci std::vector<uint32_t> &methodOffsets); 754514f5e3Sopenharmony_ciprivate: 764514f5e3Sopenharmony_ci static JSHandle<FunctionTemplate> DefineFunctionTemplate(JSThread *thread, const JSPandaFile *jsPandaFile, 774514f5e3Sopenharmony_ci uint32_t offset, JSHandle<ConstantPool> constpool, FunctionKind kind, uint16_t length, 784514f5e3Sopenharmony_ci const CString &entryPoint = "", bool isLoadedAOT = false, uint32_t entryIndex = 0, 794514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> sendableEnv = JSHandle<JSTaggedValue>(), ClassKind classKind = ClassKind::NON_SENDABLE); 804514f5e3Sopenharmony_ci 814514f5e3Sopenharmony_ci static JSHandle<JSFunction> CreateJSFunctionInLiteral(EcmaVM *vm, const JSHandle<Method> &method, 824514f5e3Sopenharmony_ci FunctionKind kind, ClassKind classKind); 834514f5e3Sopenharmony_ci static JSHandle<TaggedArray> EnumerateLiteralVals(JSThread *thread, panda_file::LiteralDataAccessor &lda, 844514f5e3Sopenharmony_ci const JSPandaFile *jsPandaFile, size_t index, JSHandle<ConstantPool> constpool, 854514f5e3Sopenharmony_ci const CString &entryPoint = ""); 864514f5e3Sopenharmony_ci}; 874514f5e3Sopenharmony_ci} // namespace panda::ecmascript 884514f5e3Sopenharmony_ci#endif // ECMASCRIPT_JSPANDAFILE_LITERAL_DATA_EXTRACTOR_H 89