GDScript: Add names for disassembling function pointers

When instructions use function pointers, it's not possible to retrieve
their original names in the disassembly. This stores the names in
vectors (in debug builds) so they can be shown.
This commit is contained in:
George Marques 2022-12-29 10:47:53 -03:00
parent 9937915ad7
commit 80e06b29e7
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
6 changed files with 82 additions and 16 deletions

View file

@ -128,7 +128,9 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
text += DADDR(3);
text += " = ";
text += DADDR(1);
text += " <operator function> ";
text += " ";
text += operator_names[_code_ptr[ip + 4]];
text += " ";
text += DADDR(2);
incr += 5;
@ -230,7 +232,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
text += "set_named validated ";
text += DADDR(1);
text += "[\"";
text += "<unknown name>";
text += setter_names[_code_ptr[ip + 3]];
text += "\"] = ";
text += DADDR(2);
@ -253,7 +255,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
text += " = ";
text += DADDR(1);
text += "[\"";
text += "<unknown name>";
text += getter_names[_code_ptr[ip + 3]];
text += "\"]";
incr += 4;
@ -398,7 +400,8 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
text += DADDR(1 + argc);
text += " = ";
text += "<unknown type>(";
text += constructors_names[_code_ptr[ip + 3 + argc]];
text += "(";
for (int i = 0; i < argc; i++) {
if (i > 0) {
text += ", ";
@ -687,7 +690,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
text += DADDR(2 + argc) + " = ";
text += DADDR(1) + ".";
text += "<unknown method>";
text += builtin_methods_names[_code_ptr[ip + 4 + argc]];
text += "(";
@ -725,12 +728,12 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
case OPCODE_CALL_UTILITY_VALIDATED: {
int instr_var_args = _code_ptr[++ip];
text += "call-utility ";
text += "call-utility validated ";
int argc = _code_ptr[ip + 1 + instr_var_args];
text += DADDR(1 + argc) + " = ";
text += "<unknown function>";
text += utilities_names[_code_ptr[ip + 3 + argc]];
text += "(";
for (int i = 0; i < argc; i++) {
@ -746,12 +749,12 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const {
case OPCODE_CALL_GDSCRIPT_UTILITY: {
int instr_var_args = _code_ptr[++ip];
text += "call-gscript-utility ";
text += "call-gdscript-utility ";
int argc = _code_ptr[ip + 1 + instr_var_args];
text += DADDR(1 + argc) + " = ";
text += "<unknown function>";
text += gds_utilities_names[_code_ptr[ip + 3 + argc]];
text += "(";
for (int i = 0; i < argc; i++) {