diff options
Diffstat (limited to 'modules/gdscript/gdscript_function.h')
-rw-r--r-- | modules/gdscript/gdscript_function.h | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 002fc159fa..759e92d68c 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -78,17 +78,17 @@ public: if (valid && builtin_type == Variant::ARRAY && has_container_element_type(0)) { Array array = p_variant; if (array.is_typed()) { - GDScriptDataType array_container_type = get_container_element_type(0); + const GDScriptDataType &elem_type = container_element_types[0]; Variant::Type array_builtin_type = (Variant::Type)array.get_typed_builtin(); StringName array_native_type = array.get_typed_class_name(); Ref<Script> array_script_type_ref = array.get_typed_script(); if (array_script_type_ref.is_valid()) { - valid = (array_container_type.kind == SCRIPT || array_container_type.kind == GDSCRIPT) && array_container_type.script_type == array_script_type_ref.ptr(); + valid = (elem_type.kind == SCRIPT || elem_type.kind == GDSCRIPT) && elem_type.script_type == array_script_type_ref.ptr(); } else if (array_native_type != StringName()) { - valid = array_container_type.kind == NATIVE && array_container_type.native_type == array_native_type; + valid = elem_type.kind == NATIVE && elem_type.native_type == array_native_type; } else { - valid = array_container_type.kind == BUILTIN && array_container_type.builtin_type == array_builtin_type; + valid = elem_type.kind == BUILTIN && elem_type.builtin_type == array_builtin_type; } } else { valid = false; @@ -147,6 +147,25 @@ public: return false; } + bool can_contain_object() const { + if (has_type && kind == BUILTIN) { + switch (builtin_type) { + case Variant::ARRAY: + if (has_container_element_type(0)) { + return container_element_types[0].can_contain_object(); + } + return true; + case Variant::DICTIONARY: + case Variant::NIL: + case Variant::OBJECT: + return true; + default: + return false; + } + } + return true; + } + void set_container_element_type(int p_index, const GDScriptDataType &p_element_type) { ERR_FAIL_COND(p_index < 0); while (p_index >= container_element_types.size()) { @@ -218,6 +237,7 @@ public: OPCODE_SET_STATIC_VARIABLE, // Only for GDScript. OPCODE_GET_STATIC_VARIABLE, // Only for GDScript. OPCODE_ASSIGN, + OPCODE_ASSIGN_NULL, OPCODE_ASSIGN_TRUE, OPCODE_ASSIGN_FALSE, OPCODE_ASSIGN_TYPED_BUILTIN, @@ -244,6 +264,8 @@ public: OPCODE_CALL_METHOD_BIND_RET, OPCODE_CALL_BUILTIN_STATIC, OPCODE_CALL_NATIVE_STATIC, + OPCODE_CALL_NATIVE_STATIC_VALIDATED_RETURN, + OPCODE_CALL_NATIVE_STATIC_VALIDATED_NO_RETURN, OPCODE_CALL_METHOD_BIND_VALIDATED_RETURN, OPCODE_CALL_METHOD_BIND_VALIDATED_NO_RETURN, OPCODE_AWAIT, @@ -279,6 +301,7 @@ public: OPCODE_ITERATE_BEGIN_PACKED_VECTOR2_ARRAY, OPCODE_ITERATE_BEGIN_PACKED_VECTOR3_ARRAY, OPCODE_ITERATE_BEGIN_PACKED_COLOR_ARRAY, + OPCODE_ITERATE_BEGIN_PACKED_VECTOR4_ARRAY, OPCODE_ITERATE_BEGIN_OBJECT, OPCODE_ITERATE, OPCODE_ITERATE_INT, @@ -299,6 +322,7 @@ public: OPCODE_ITERATE_PACKED_VECTOR2_ARRAY, OPCODE_ITERATE_PACKED_VECTOR3_ARRAY, OPCODE_ITERATE_PACKED_COLOR_ARRAY, + OPCODE_ITERATE_PACKED_VECTOR4_ARRAY, OPCODE_ITERATE_OBJECT, OPCODE_STORE_GLOBAL, OPCODE_STORE_NAMED_GLOBAL, @@ -339,6 +363,7 @@ public: OPCODE_TYPE_ADJUST_PACKED_VECTOR2_ARRAY, OPCODE_TYPE_ADJUST_PACKED_VECTOR3_ARRAY, OPCODE_TYPE_ADJUST_PACKED_COLOR_ARRAY, + OPCODE_TYPE_ADJUST_PACKED_VECTOR4_ARRAY, OPCODE_ASSERT, OPCODE_BREAKPOINT, OPCODE_LINE, |