mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2025-04-17 01:50:20 +00:00
Support add/delete annotation elements
Issue: #IAS8XN Signed-off-by: Nazarov Konstantin <nazarov.konstantin@huawei.com> Change-Id: I27fad211bc40a469505b19bbea60df1861f6cca6
This commit is contained in:
parent
7fd7038ee3
commit
97385e96aa
@ -258,4 +258,15 @@ void AnnotationData::SetOrAddElementByIndex(size_t ele_idx, AnnotationElement &&
|
|||||||
}
|
}
|
||||||
elements_[ele_idx] = std::forward<AnnotationElement>(element);
|
elements_[ele_idx] = std::forward<AnnotationElement>(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnnotationData::DeleteAnnotationElementByName(const std::string_view &annotation_elem_name)
|
||||||
|
{
|
||||||
|
auto annotation_elem_iter = std::find_if(elements_.begin(), elements_.end(),
|
||||||
|
[&](pandasm::AnnotationElement &annotation_element) -> bool {
|
||||||
|
return annotation_element.GetName() == annotation_elem_name;
|
||||||
|
});
|
||||||
|
if (annotation_elem_iter != elements_.end()) {
|
||||||
|
(void)elements_.erase(annotation_elem_iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace panda::pandasm
|
} // namespace panda::pandasm
|
||||||
|
@ -61,6 +61,8 @@ public:
|
|||||||
elements_.push_back(std::forward<AnnotationElement>(element));
|
elements_.push_back(std::forward<AnnotationElement>(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeleteAnnotationElementByName(const std::string_view &annotation_elem_name);
|
||||||
|
|
||||||
void SetOrAddElementByIndex(size_t ele_idx, AnnotationElement &&element);
|
void SetOrAddElementByIndex(size_t ele_idx, AnnotationElement &&element);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -363,6 +365,9 @@ public:
|
|||||||
case '@':
|
case '@':
|
||||||
type = Type::METHOD_HANDLE;
|
type = Type::METHOD_HANDLE;
|
||||||
break;
|
break;
|
||||||
|
case '#':
|
||||||
|
type = Type::LITERALARRAY;
|
||||||
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
default:
|
default:
|
||||||
type = Type::UNKNOWN;
|
type = Type::UNKNOWN;
|
||||||
|
@ -208,6 +208,17 @@ public:
|
|||||||
annotations_.insert(annotations_.end(), annotations.begin(), annotations.end());
|
annotations_.insert(annotations_.end(), annotations.begin(), annotations.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeleteAnnotationElementByName(std::string_view annotation_name, std::string_view annotation_elem_name)
|
||||||
|
{
|
||||||
|
auto annotation_iter = std::find_if(annotations_.begin(), annotations_.end(),
|
||||||
|
[&](pandasm::AnnotationData &annotation) -> bool {
|
||||||
|
return annotation.GetName() == annotation_name;
|
||||||
|
});
|
||||||
|
if (annotation_iter != annotations_.end()) {
|
||||||
|
annotation_iter->DeleteAnnotationElementByName(annotation_elem_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DeleteAnnotationByName(const std::string_view &annotation_name)
|
void DeleteAnnotationByName(const std::string_view &annotation_name)
|
||||||
{
|
{
|
||||||
auto annotation_iter = std::find_if(annotations_.begin(), annotations_.end(),
|
auto annotation_iter = std::find_if(annotations_.begin(), annotations_.end(),
|
||||||
@ -219,6 +230,17 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddAnnotationElementByName(const std::string_view &annotation_name, AnnotationElement &&element)
|
||||||
|
{
|
||||||
|
auto annotation_iter = std::find_if(annotations_.begin(), annotations_.end(),
|
||||||
|
[&](pandasm::AnnotationData &annotation) -> bool {
|
||||||
|
return annotation.GetName() == annotation_name;
|
||||||
|
});
|
||||||
|
if (annotation_iter != annotations_.end()) {
|
||||||
|
annotation_iter->AddElement(std::move(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SetOrAddAnnotationElementByIndex(size_t anno_idx, size_t ele_idx, AnnotationElement &&element)
|
void SetOrAddAnnotationElementByIndex(size_t anno_idx, size_t ele_idx, AnnotationElement &&element)
|
||||||
{
|
{
|
||||||
ASSERT(anno_idx < annotations_.size());
|
ASSERT(anno_idx < annotations_.size());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user