• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include "assembly-parser.h"
17
18namespace panda::pandasm {
19inline std::string OperandTypePrint(panda::pandasm::Opcode op) {
20    switch (op) {
21% Panda::instructions.group_by(&:mnemonic).each do |mnemonic, group|
22%    insn = group.first
23%    operands = insn.operands
24%    properties = insn.properties
25        case Opcode::<%= group.first.asm_token%>: {
26%    operands_list = operands.map do |op|
27%        if op.reg?
28%            'reg'
29%        elsif op.imm?
30%            properties.include?('jump') ? 'label' : 'imm'
31%        elsif op.id?
32%            if properties.include?('type_id')
33%                'type'
34%            elsif properties.include?('string_id')
35%                'string'
36%            elsif properties.include?('method_id')
37%                'call'
38%            else
39%                'id'
40%            end
41%        end
42%    end.join('_')
43%    operands_list = 'none' if operands_list == ''
44                return "<%= operands_list%>";
45        };
46%end
47        default:
48            return "undefined";
49    }
50}
51}
52