当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
57 Star 30 Fork 160

OpenHarmony-SIG/arkcompiler_runtime_core
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
method_data_accessor.h 5.64 KB
一键复制 编辑 原始数据 按行查看 历史
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef LIBPANDAFILE_METHOD_DATA_ACCESSOR_H_
#define LIBPANDAFILE_METHOD_DATA_ACCESSOR_H_
#include "file.h"
#include "file_items.h"
#include "modifiers.h"
namespace panda::panda_file {
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions, hicpp-special-member-functions)
class MethodDataAccessor {
public:
enum AnnotationField : uint32_t {
IC_SIZE = 0,
FUNCTION_LENGTH,
FUNCTION_NAME,
STRING_DATA_BEGIN = FUNCTION_NAME,
STRING_DATA_END = FUNCTION_NAME
};
MethodDataAccessor(const File &panda_file, File::EntityId method_id);
~MethodDataAccessor() = default;
// quick way to get name id
static File::EntityId GetNameId(const File &panda_file, File::EntityId method_id);
// quick way to get method name
static panda_file::File::StringData GetName(const File &panda_file, File::EntityId method_id);
std::string GetFullName() const;
// quick way to get proto id
static File::EntityId GetProtoId(const File &panda_file, File::EntityId method_id);
// quick way to get class id
static File::EntityId GetClassId(const File &panda_file, File::EntityId method_id);
bool IsExternal() const
{
return is_external_;
}
bool IsStatic() const
{
return (access_flags_ & ACC_STATIC) != 0;
}
bool IsAbstract() const
{
return (access_flags_ & ACC_ABSTRACT) != 0;
}
bool IsNative() const
{
return (access_flags_ & ACC_NATIVE) != 0;
}
bool IsPublic() const
{
return (access_flags_ & ACC_PUBLIC) != 0;
}
bool IsPrivate() const
{
return (access_flags_ & ACC_PRIVATE) != 0;
}
bool IsProtected() const
{
return (access_flags_ & ACC_PROTECTED) != 0;
}
bool IsFinal() const
{
return (access_flags_ & ACC_FINAL) != 0;
}
bool IsSynthetic() const
{
return (access_flags_ & ACC_SYNTHETIC) != 0;
}
File::EntityId GetClassId() const
{
return File::EntityId(class_off_);
}
File::Index GetClassIdx() const
{
return class_idx_;
}
File::EntityId GetNameId() const
{
return File::EntityId(name_off_);
};
panda_file::File::StringData GetName() const;
File::EntityId GetProtoId() const
{
return File::EntityId(proto_off_);
}
uint32_t GetAccessFlags() const
{
return access_flags_;
}
std::optional<File::EntityId> GetCodeId();
std::optional<SourceLang> GetSourceLang();
template <class Callback>
void EnumerateRuntimeAnnotations(Callback cb);
template <typename Callback>
void EnumerateTypesInProto(Callback cb, bool skip_this = false);
std::optional<File::EntityId> GetRuntimeParamAnnotationId();
std::optional<File::EntityId> GetDebugInfoId();
template <class Callback>
void EnumerateAnnotations(Callback cb);
template <class Callback>
bool EnumerateRuntimeAnnotationsWithEarlyStop(Callback cb);
template <class Callback>
bool EnumerateAnnotationsWithEarlyStop(Callback cb);
template <class Callback>
void EnumerateTypeAnnotations(Callback cb);
template <class Callback>
void EnumerateRuntimeTypeAnnotations(Callback cb);
std::optional<size_t> GetProfileSize();
std::optional<File::EntityId> GetParamAnnotationId();
size_t GetSize()
{
if (size_ == 0) {
GetProfileSize();
}
return size_;
}
const File &GetPandaFile() const
{
return panda_file_;
}
File::EntityId GetMethodId() const
{
return method_id_;
}
uint32_t GetAnnotationsNumber();
uint32_t GetRuntimeAnnotationsNumber();
uint32_t GetTypeAnnotationsNumber();
uint32_t GetRuntimeTypeAnnotationsNumber();
uint32_t GetNumericalAnnotation(uint32_t field_id);
private:
void SkipCode();
void SkipSourceLang();
void SkipRuntimeAnnotations();
void SkipRuntimeParamAnnotation();
void SkipDebugInfo();
void SkipAnnotations();
void SkipParamAnnotation();
void SkipTypeAnnotation();
void SkipRuntimeTypeAnnotation();
const File &panda_file_;
File::EntityId method_id_;
bool is_external_;
uint16_t class_idx_;
uint16_t proto_idx_;
uint32_t class_off_;
uint32_t proto_off_;
uint32_t name_off_;
uint32_t access_flags_;
Span<const uint8_t> tagged_values_sp_ {nullptr, nullptr};
Span<const uint8_t> source_lang_sp_ {nullptr, nullptr};
Span<const uint8_t> runtime_annotations_sp_ {nullptr, nullptr};
Span<const uint8_t> runtime_param_annotation_sp_ {nullptr, nullptr};
Span<const uint8_t> debug_sp_ {nullptr, nullptr};
Span<const uint8_t> annotations_sp_ {nullptr, nullptr};
Span<const uint8_t> param_annotation_sp_ {nullptr, nullptr};
Span<const uint8_t> type_annotation_sp_ {nullptr, nullptr};
Span<const uint8_t> runtime_type_annotation_sp_ {nullptr, nullptr};
Span<const uint8_t> profile_info_sp_ {nullptr, nullptr};
size_t size_;
};
} // namespace panda::panda_file
#endif // LIBPANDAFILE_METHOD_DATA_ACCESSOR_H_
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony-sig/arkcompiler_runtime_core.git
git@gitee.com:openharmony-sig/arkcompiler_runtime_core.git
openharmony-sig
arkcompiler_runtime_core
arkcompiler_runtime_core
master

搜索帮助