| 106 | } |
| 107 | |
| 108 | void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const { |
| 109 | #define DADDR(m_ip) (_disassemble_address(_script, *this, _code_ptr[ip + m_ip])) |
| 110 | |
| 111 | for (int ip = 0; ip < _code_size;) { |
| 112 | StringBuilder text; |
| 113 | int incr = 0; |
| 114 | |
| 115 | text += " "; |
| 116 | text += itos(ip); |
| 117 | text += ": "; |
| 118 | |
| 119 | // This makes the compiler complain if some opcode is unchecked in the switch. |
| 120 | Opcode opcode = Opcode(_code_ptr[ip]); |
| 121 | |
| 122 | switch (opcode) { |
| 123 | case OPCODE_OPERATOR: { |
| 124 | constexpr int _pointer_size = sizeof(Variant::ValidatedOperatorEvaluator) / sizeof(*_code_ptr); |
| 125 | int operation = _code_ptr[ip + 4]; |
| 126 | |
| 127 | text += "operator "; |
| 128 | |
| 129 | text += DADDR(3); |
| 130 | text += " = "; |
| 131 | text += DADDR(1); |
| 132 | text += " "; |
| 133 | text += Variant::get_operator_name(Variant::Operator(operation)); |
| 134 | text += " "; |
| 135 | text += DADDR(2); |
| 136 | |
| 137 | incr += 7 + _pointer_size; |
| 138 | } break; |
| 139 | case OPCODE_OPERATOR_VALIDATED: { |
| 140 | text += "validated operator "; |
| 141 | |
| 142 | text += DADDR(3); |
| 143 | text += " = "; |
| 144 | text += DADDR(1); |
| 145 | text += " "; |
| 146 | text += operator_names[_code_ptr[ip + 4]]; |
| 147 | text += " "; |
| 148 | text += DADDR(2); |
| 149 | |
| 150 | incr += 5; |
| 151 | } break; |
| 152 | case OPCODE_TYPE_TEST_BUILTIN: { |
| 153 | text += "type test "; |
| 154 | text += DADDR(1); |
| 155 | text += " = "; |
| 156 | text += DADDR(2); |
| 157 | text += " is "; |
| 158 | text += Variant::get_type_name(Variant::Type(_code_ptr[ip + 3])); |
| 159 | |
| 160 | incr += 4; |
| 161 | } break; |
| 162 | case OPCODE_TYPE_TEST_ARRAY: { |
| 163 | text += "type test "; |
| 164 | text += DADDR(1); |
| 165 | text += " = "; |