diff options
author | George Marques <george@gmarqu.es> | 2021-09-17 12:29:40 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-17 12:29:40 -0300 |
commit | b8fdeb64678444103a9b6c96ef3ae2c65ad02b2f (patch) | |
tree | 389bf2391b69a8eb0178b468975c046151352851 /modules/gdscript/gdscript_parser.cpp | |
parent | 4d61cb9c35fe30244e3c818623dcd043c6846cdb (diff) | |
parent | 10c9c2ccd44b7d96e570f668deb2a8531a92bdc6 (diff) | |
download | redot-engine-b8fdeb64678444103a9b6c96ef3ae2c65ad02b2f.tar.gz |
Merge pull request #51671 from RandomShaper/fix_gdscript_crash
Fix some GDScript bugs
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index d555be1e8d..b443e43846 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3587,6 +3587,39 @@ String GDScriptParser::DataType::to_string() const { ERR_FAIL_V_MSG("<unresolved type", "Kind set outside the enum range."); } +static Variant::Type _variant_type_to_typed_array_element_type(Variant::Type p_type) { + switch (p_type) { + case Variant::PACKED_BYTE_ARRAY: + case Variant::PACKED_INT32_ARRAY: + case Variant::PACKED_INT64_ARRAY: + return Variant::INT; + case Variant::PACKED_FLOAT32_ARRAY: + case Variant::PACKED_FLOAT64_ARRAY: + return Variant::FLOAT; + case Variant::PACKED_STRING_ARRAY: + return Variant::STRING; + case Variant::PACKED_VECTOR2_ARRAY: + return Variant::VECTOR2; + case Variant::PACKED_VECTOR3_ARRAY: + return Variant::VECTOR3; + case Variant::PACKED_COLOR_ARRAY: + return Variant::COLOR; + default: + return Variant::NIL; + } +} + +bool GDScriptParser::DataType::is_typed_container_type() const { + return kind == GDScriptParser::DataType::BUILTIN && _variant_type_to_typed_array_element_type(builtin_type) != Variant::NIL; +} + +GDScriptParser::DataType GDScriptParser::DataType::get_typed_container_type() const { + GDScriptParser::DataType type; + type.kind = GDScriptParser::DataType::BUILTIN; + type.builtin_type = _variant_type_to_typed_array_element_type(builtin_type); + return type; +} + /*---------- PRETTY PRINT FOR DEBUG ----------*/ #ifdef DEBUG_ENABLED |