|
@@ -1494,19 +1494,16 @@ void GDScriptByteCodeGenerator::start_for(const GDScriptDataType &p_iterator_typ
|
|
for_container_variables.push_back(container);
|
|
for_container_variables.push_back(container);
|
|
}
|
|
}
|
|
|
|
|
|
-void GDScriptByteCodeGenerator::write_for_assignment(const Address &p_variable, const Address &p_list) {
|
|
|
|
|
|
+void GDScriptByteCodeGenerator::write_for_assignment(const Address &p_list) {
|
|
const Address &container = for_container_variables.back()->get();
|
|
const Address &container = for_container_variables.back()->get();
|
|
|
|
|
|
// Assign container.
|
|
// Assign container.
|
|
append_opcode(GDScriptFunction::OPCODE_ASSIGN);
|
|
append_opcode(GDScriptFunction::OPCODE_ASSIGN);
|
|
append(container);
|
|
append(container);
|
|
append(p_list);
|
|
append(p_list);
|
|
-
|
|
|
|
- for_iterator_variables.push_back(p_variable);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-void GDScriptByteCodeGenerator::write_for() {
|
|
|
|
- const Address &iterator = for_iterator_variables.back()->get();
|
|
|
|
|
|
+void GDScriptByteCodeGenerator::write_for(const Address &p_variable, bool p_use_conversion) {
|
|
const Address &counter = for_counter_variables.back()->get();
|
|
const Address &counter = for_counter_variables.back()->get();
|
|
const Address &container = for_container_variables.back()->get();
|
|
const Address &container = for_container_variables.back()->get();
|
|
|
|
|
|
@@ -1599,11 +1596,16 @@ void GDScriptByteCodeGenerator::write_for() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Address temp;
|
|
|
|
+ if (p_use_conversion) {
|
|
|
|
+ temp = Address(Address::LOCAL_VARIABLE, add_local("@iterator_temp", GDScriptDataType()));
|
|
|
|
+ }
|
|
|
|
+
|
|
// Begin loop.
|
|
// Begin loop.
|
|
append_opcode(begin_opcode);
|
|
append_opcode(begin_opcode);
|
|
append(counter);
|
|
append(counter);
|
|
append(container);
|
|
append(container);
|
|
- append(iterator);
|
|
|
|
|
|
+ append(p_use_conversion ? temp : p_variable);
|
|
for_jmp_addrs.push_back(opcodes.size());
|
|
for_jmp_addrs.push_back(opcodes.size());
|
|
append(0); // End of loop address, will be patched.
|
|
append(0); // End of loop address, will be patched.
|
|
append_opcode(GDScriptFunction::OPCODE_JUMP);
|
|
append_opcode(GDScriptFunction::OPCODE_JUMP);
|
|
@@ -1615,9 +1617,17 @@ void GDScriptByteCodeGenerator::write_for() {
|
|
append_opcode(iterate_opcode);
|
|
append_opcode(iterate_opcode);
|
|
append(counter);
|
|
append(counter);
|
|
append(container);
|
|
append(container);
|
|
- append(iterator);
|
|
|
|
|
|
+ append(p_use_conversion ? temp : p_variable);
|
|
for_jmp_addrs.push_back(opcodes.size());
|
|
for_jmp_addrs.push_back(opcodes.size());
|
|
append(0); // Jump destination, will be patched.
|
|
append(0); // Jump destination, will be patched.
|
|
|
|
+
|
|
|
|
+ if (p_use_conversion) {
|
|
|
|
+ write_assign_with_conversion(p_variable, temp);
|
|
|
|
+ const GDScriptDataType &type = p_variable.type;
|
|
|
|
+ if (type.kind != GDScriptDataType::BUILTIN || type.builtin_type == Variant::ARRAY || type.builtin_type == Variant::DICTIONARY) {
|
|
|
|
+ write_assign_false(temp); // Can contain RefCounted, so clear it.
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void GDScriptByteCodeGenerator::write_endfor() {
|
|
void GDScriptByteCodeGenerator::write_endfor() {
|
|
@@ -1639,7 +1649,6 @@ void GDScriptByteCodeGenerator::write_endfor() {
|
|
current_breaks_to_patch.pop_back();
|
|
current_breaks_to_patch.pop_back();
|
|
|
|
|
|
// Pop state.
|
|
// Pop state.
|
|
- for_iterator_variables.pop_back();
|
|
|
|
for_counter_variables.pop_back();
|
|
for_counter_variables.pop_back();
|
|
for_container_variables.pop_back();
|
|
for_container_variables.pop_back();
|
|
}
|
|
}
|