MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / disassemble

Method disassemble

modules/gdscript/gdscript_disassembler.cpp:108–1339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108void 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 += " = ";

Callers 1

disassemble_functionFunction · 0.80

Calls 14

itosFunction · 0.85
OpcodeEnum · 0.85
print_lineFunction · 0.85
get_string_lengthMethod · 0.80
TypeEnum · 0.70
sizeMethod · 0.65
OperatorEnum · 0.50
StringNameClass · 0.50
StringClass · 0.50
is_validMethod · 0.45
get_nameMethod · 0.45

Tested by 1

disassemble_functionFunction · 0.64