/**
* Copyright (c) 2024-2026 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.
*/
#include "assembly-function.h"
#include "assembly-ins.h"
namespace panda::pandasm {
std::set<std::string> panda::pandasm::Function::CollectStringsFromFunctionInsns() const {
std::set<std::string> function_strings {};
for (const auto &panda_insn : this->ins) {
switch (panda_insn->GetOpcode()) {
% Panda::instructions.group_by(&:mnemonic).each do |mnemonic, group|
% insn = group[index_of_max(group.map(&:format).map(&:size))]
% if (insn.properties.include?('string_id') || insn.properties.include?('method_id'))
case Opcode::<%= insn.asm_token %>: {
% num_id = 0
% property_idx_start = 0
% insn.operands.each do |op|
% if op.id?
% id_properties = insn.properties.slice(property_idx_start, insn.properties.length - property_idx_start)
% id_properties.each_with_index do |prop, prop_idx|
% if prop == 'string_id'
function_strings.insert(panda_insn->Ids()[<%= num_id %>]);
% property_idx_start += prop_idx + 1
% num_id += 1
% break
% elsif prop == 'method_id'
function_strings.insert(panda_insn->Ids()[<%= num_id %>]);
% property_idx_start += prop_idx + 1
% num_id += 1
% break
% elsif prop == 'literalarray_id'
% property_idx_start += prop_idx + 1
% num_id += 1
% break
% else
% next
% end
% end
% else
% next
% end
% end
break;
}
% else
% next
% end
% end
default:
break;
}
}
return function_strings;
}
} // namespace panda::pandasm