| 1963 | } |
| 1964 | |
| 1965 | void GDScriptByteCodeGenerator::clear_address(const Address &p_address) { |
| 1966 | // Do not check `is_local_dirty()` here! Always clear the address since the codegen doesn't track the compiler. |
| 1967 | // Also, this method is used to initialize local variables of built-in types, since they cannot be `null`. |
| 1968 | |
| 1969 | if (p_address.type.has_type && p_address.type.kind == GDScriptDataType::BUILTIN) { |
| 1970 | switch (p_address.type.builtin_type) { |
| 1971 | case Variant::BOOL: |
| 1972 | write_assign_false(p_address); |
| 1973 | break; |
| 1974 | case Variant::DICTIONARY: |
| 1975 | if (p_address.type.has_container_element_types()) { |
| 1976 | write_construct_typed_dictionary(p_address, p_address.type.get_container_element_type_or_variant(0), p_address.type.get_container_element_type_or_variant(1), Vector<GDScriptCodeGenerator::Address>()); |
| 1977 | } else { |
| 1978 | write_construct(p_address, p_address.type.builtin_type, Vector<GDScriptCodeGenerator::Address>()); |
| 1979 | } |
| 1980 | break; |
| 1981 | case Variant::ARRAY: |
| 1982 | if (p_address.type.has_container_element_type(0)) { |
| 1983 | write_construct_typed_array(p_address, p_address.type.get_container_element_type(0), Vector<GDScriptCodeGenerator::Address>()); |
| 1984 | } else { |
| 1985 | write_construct(p_address, p_address.type.builtin_type, Vector<GDScriptCodeGenerator::Address>()); |
| 1986 | } |
| 1987 | break; |
| 1988 | case Variant::NIL: |
| 1989 | case Variant::OBJECT: |
| 1990 | write_assign_null(p_address); |
| 1991 | break; |
| 1992 | default: |
| 1993 | write_construct(p_address, p_address.type.builtin_type, Vector<GDScriptCodeGenerator::Address>()); |
| 1994 | break; |
| 1995 | } |
| 1996 | } else { |
| 1997 | write_assign_null(p_address); |
| 1998 | } |
| 1999 | |
| 2000 | if (p_address.mode == Address::LOCAL_VARIABLE) { |
| 2001 | dirty_locals.erase(p_address.address); |
| 2002 | } |
| 2003 | } |
| 2004 | |
| 2005 | bool GDScriptByteCodeGenerator::is_local_dirty(const Address &p_address) const { |
| 2006 | ERR_FAIL_COND_V(p_address.mode != Address::LOCAL_VARIABLE, false); |
no test coverage detected