MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / write_cast

Method write_cast

modules/gdscript/gdscript_byte_codegen.cpp:1046–1075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044}
1045
1046void 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
1077GDScriptByteCodeGenerator::CallTarget GDScriptByteCodeGenerator::get_call_target(const GDScriptCodeGenerator::Address &p_target, Variant::Type p_type) {
1078 if (p_target.mode == Address::NIL) {

Callers 1

_parse_expressionMethod · 0.80

Calls 1

get_global_arrayMethod · 0.80

Tested by

no test coverage detected