mirror of
https://github.com/godotengine/godot.git
synced 2025-10-26 11:14:17 +00:00
GDScript: Implement lambdas compilation and runtime
This commit is contained in:
parent
3155368093
commit
c201b212c7
16 changed files with 364 additions and 39 deletions
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue