| 1044 | } |
| 1045 | |
| 1046 | void GDScriptByteCodeGenerator::write_cast(const Address &p_target, const Address &p_source, const GDScriptDataType &p_type) { |
| 1047 | int index = 0; |
| 1048 | |
| 1049 | switch (p_type.kind) { |
| 1050 | case GDScriptDataType::BUILTIN: { |
| 1051 | append_opcode(GDScriptFunction::OPCODE_CAST_TO_BUILTIN); |
| 1052 | index = p_type.builtin_type; |
| 1053 | } break; |
| 1054 | case GDScriptDataType::NATIVE: { |
| 1055 | int class_idx = GDScriptLanguage::get_singleton()->get_global_map()[p_type.native_type]; |
| 1056 | Variant nc = GDScriptLanguage::get_singleton()->get_global_array()[class_idx]; |
| 1057 | append_opcode(GDScriptFunction::OPCODE_CAST_TO_NATIVE); |
| 1058 | index = get_constant_pos(nc) | (GDScriptFunction::ADDR_TYPE_CONSTANT << GDScriptFunction::ADDR_BITS); |
| 1059 | } break; |
| 1060 | case GDScriptDataType::SCRIPT: |
| 1061 | case GDScriptDataType::GDSCRIPT: { |
| 1062 | Variant script = p_type.script_type; |
| 1063 | int idx = get_constant_pos(script) | (GDScriptFunction::ADDR_TYPE_CONSTANT << GDScriptFunction::ADDR_BITS); |
| 1064 | append_opcode(GDScriptFunction::OPCODE_CAST_TO_SCRIPT); |
| 1065 | index = idx; |
| 1066 | } break; |
| 1067 | default: { |
| 1068 | return; |
| 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | append(p_source); |
| 1073 | append(p_target); |
| 1074 | append(index); |
| 1075 | } |
| 1076 | |
| 1077 | GDScriptByteCodeGenerator::CallTarget GDScriptByteCodeGenerator::get_call_target(const GDScriptCodeGenerator::Address &p_target, Variant::Type p_type) { |
| 1078 | if (p_target.mode == Address::NIL) { |
no test coverage detected