diff options
author | George Marques <george@gmarqu.es> | 2021-03-28 11:03:13 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2021-04-28 11:09:38 -0300 |
commit | c201b212c7d188c15de78c4d4150e9d7337b6983 (patch) | |
tree | a66e15980bebbe5322e458c10457889ff4d515e8 /modules/gdscript/gdscript_disassembler.cpp | |
parent | 3155368093875e644b1adbfa29bb584134c52a89 (diff) | |
download | redot-engine-c201b212c7d188c15de78c4d4150e9d7337b6983.tar.gz |
GDScript: Implement lambdas compilation and runtime
Diffstat (limited to 'modules/gdscript/gdscript_disassembler.cpp')
-rw-r--r-- | modules/gdscript/gdscript_disassembler.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_disassembler.cpp b/modules/gdscript/gdscript_disassembler.cpp index 0d0afcc741..789af57b4c 100644 --- a/modules/gdscript/gdscript_disassembler.cpp +++ b/modules/gdscript/gdscript_disassembler.cpp @@ -721,7 +721,7 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const { text += "await "; text += DADDR(1); - incr += 2; + incr = 2; } break; case OPCODE_AWAIT_RESUME: { text += "await resume "; @@ -729,6 +729,25 @@ void GDScriptFunction::disassemble(const Vector<String> &p_code_lines) const { incr = 2; } break; + case OPCODE_CREATE_LAMBDA: { + int captures_count = _code_ptr[ip + 1 + instr_var_args]; + GDScriptFunction *lambda = _lambdas_ptr[_code_ptr[ip + 2 + instr_var_args]]; + + text += DADDR(1 + captures_count); + text += "create lambda from "; + text += lambda->name.operator String(); + text += "function, captures ("; + + for (int i = 0; i < captures_count; i++) { + if (i > 0) { + text += ", "; + } + text += DADDR(1 + i); + } + text += ")"; + + incr = 3 + captures_count; + } break; case OPCODE_JUMP: { text += "jump "; text += itos(_code_ptr[ip + 1]); |