@@ -92,11 +92,10 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
9292 }
9393
9494 GDScriptDataType result;
95- result.has_type = true ;
9695
9796 switch (p_datatype.kind ) {
9897 case GDScriptParser::DataType::VARIANT: {
99- result.has_type = false ;
98+ result.kind = GDScriptDataType::VARIANT ;
10099 } break ;
101100 case GDScriptParser::DataType::BUILTIN: {
102101 result.kind = GDScriptDataType::BUILTIN;
@@ -207,7 +206,7 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
207206}
208207
209208static bool _is_exact_type (const PropertyInfo &p_par_type, const GDScriptDataType &p_arg_type) {
210- if (!p_arg_type.has_type ) {
209+ if (!p_arg_type.has_type () ) {
211210 return false ;
212211 }
213212 if (p_par_type.type == Variant::NIL) {
@@ -583,7 +582,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
583582 GDScriptDataType cast_type = _gdtype_from_datatype (cn->get_datatype (), codegen.script , false );
584583
585584 GDScriptCodeGenerator::Address result;
586- if (cast_type.has_type ) {
585+ if (cast_type.has_type () ) {
587586 // Create temporary for result first since it will be deleted last.
588587 result = codegen.add_temporary (cast_type);
589588
@@ -692,7 +691,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
692691 }
693692 if (is_awaited) {
694693 gen->write_call_async (result, base, call->function_name , arguments);
695- } else if (base.type .has_type && base.type .kind != GDScriptDataType::BUILTIN) {
694+ } else if (base.type .kind != GDScriptDataType::VARIANT && base.type .kind != GDScriptDataType::BUILTIN) {
696695 // Native method, use faster path.
697696 StringName class_name;
698697 if (base.type .kind == GDScriptDataType::NATIVE) {
@@ -712,7 +711,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
712711 } else {
713712 gen->write_call (result, base, call->function_name , arguments);
714713 }
715- } else if (base.type .has_type && base. type . kind == GDScriptDataType::BUILTIN) {
714+ } else if (base.type .kind == GDScriptDataType::BUILTIN) {
716715 gen->write_call_builtin_type (result, base, base.type .builtin_type , call->function_name , arguments);
717716 } else {
718717 gen->write_call (result, base, call->function_name , arguments);
@@ -967,7 +966,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
967966 return GDScriptCodeGenerator::Address ();
968967 }
969968
970- if (test_type.has_type ) {
969+ if (test_type.has_type () ) {
971970 gen->write_type_test (result, operand, test_type);
972971 } else {
973972 gen->write_assign_true (result);
@@ -1067,7 +1066,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
10671066
10681067 // Get at (potential) root stack pos, so it can be returned.
10691068 GDScriptCodeGenerator::Address base = _parse_expression (codegen, r_error, chain.back ()->get ()->base );
1070- const bool base_known_type = base.type .has_type ;
1069+ const bool base_known_type = base.type .has_type () ;
10711070 const bool base_is_shared = Variant::is_type_shared (base.type .builtin_type );
10721071
10731072 if (r_error) {
@@ -1171,7 +1170,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
11711170
11721171 // Set back the values into their bases.
11731172 for (const ChainInfo &info : set_chain) {
1174- bool known_type = assigned.type .has_type ;
1173+ bool known_type = assigned.type .has_type () ;
11751174 bool is_shared = Variant::is_type_shared (assigned.type .builtin_type );
11761175
11771176 if (!known_type || !is_shared) {
@@ -1197,7 +1196,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
11971196 assigned = info.base ;
11981197 }
11991198
1200- bool known_type = assigned.type .has_type ;
1199+ bool known_type = assigned.type .has_type () ;
12011200 bool is_shared = Variant::is_type_shared (assigned.type .builtin_type );
12021201
12031202 if (!known_type || !is_shared) {
@@ -1445,7 +1444,6 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_match_pattern(CodeGen &c
14451444
14461445 // Equality is always a boolean.
14471446 GDScriptDataType equality_type;
1448- equality_type.has_type = true ;
14491447 equality_type.kind = GDScriptDataType::BUILTIN;
14501448 equality_type.builtin_type = Variant::BOOL;
14511449
@@ -1526,7 +1524,6 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_match_pattern(CodeGen &c
15261524
15271525 // Equality is always a boolean.
15281526 GDScriptDataType equality_type;
1529- equality_type.has_type = true ;
15301527 equality_type.kind = GDScriptDataType::BUILTIN;
15311528 equality_type.builtin_type = Variant::BOOL;
15321529
@@ -1611,7 +1608,6 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_match_pattern(CodeGen &c
16111608
16121609 // Equality is always a boolean.
16131610 GDScriptDataType temp_type;
1614- temp_type.has_type = true ;
16151611 temp_type.kind = GDScriptDataType::BUILTIN;
16161612 temp_type.builtin_type = Variant::BOOL;
16171613
@@ -1709,7 +1705,6 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_match_pattern(CodeGen &c
17091705
17101706 // Equality is always a boolean.
17111707 GDScriptDataType temp_type;
1712- temp_type.has_type = true ;
17131708 temp_type.kind = GDScriptDataType::BUILTIN;
17141709 temp_type.builtin_type = Variant::BOOL;
17151710
@@ -1929,7 +1924,6 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui
19291924
19301925 // Then, let's save the type of the value in the stack too, so we can reuse for later comparisons.
19311926 GDScriptDataType typeof_type;
1932- typeof_type.has_type = true ;
19331927 typeof_type.kind = GDScriptDataType::BUILTIN;
19341928 typeof_type.builtin_type = Variant::INT;
19351929 GDScriptCodeGenerator::Address type = codegen.add_local (" @match_type" , typeof_type);
@@ -2236,7 +2230,7 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui
22362230 codegen.generator ->pop_temporary ();
22372231 }
22382232 initialized = true ;
2239- } else if (( local_type.has_type && local_type. kind == GDScriptDataType::BUILTIN) || codegen.generator ->is_local_dirty (local)) {
2233+ } else if (local_type.kind == GDScriptDataType::BUILTIN || codegen.generator ->is_local_dirty (local)) {
22402234 // Initialize with default for the type. Built-in types must always be cleared (they cannot be `null`).
22412235 // Objects and untyped variables are assigned to `null` only if the stack address has been reused and not cleared.
22422236 codegen.generator ->clear_address (local);
@@ -2303,7 +2297,6 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
23032297 bool is_static = false ;
23042298 Variant rpc_config;
23052299 GDScriptDataType return_type;
2306- return_type.has_type = true ;
23072300 return_type.kind = GDScriptDataType::BUILTIN;
23082301 return_type.builtin_type = Variant::NIL;
23092302
@@ -2383,7 +2376,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
23832376 }
23842377
23852378 GDScriptDataType field_type = _gdtype_from_datatype (field->get_datatype (), codegen.script );
2386- if (field_type.has_type ) {
2379+ if (field_type.has_type () ) {
23872380 codegen.generator ->write_newline (field->start_line );
23882381
23892382 GDScriptCodeGenerator::Address dst_address (GDScriptCodeGenerator::Address::MEMBER, codegen.script ->member_indices [field->identifier ->name ].index , field_type);
@@ -2522,7 +2515,6 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
25222515 method_info.return_val = p_func->get_datatype ().to_property_info (String ());
25232516 } else {
25242517 gd_function->return_type = GDScriptDataType ();
2525- gd_function->return_type .has_type = true ;
25262518 gd_function->return_type .kind = GDScriptDataType::BUILTIN;
25272519 gd_function->return_type .builtin_type = Variant::NIL;
25282520 }
@@ -2555,7 +2547,6 @@ GDScriptFunction *GDScriptCompiler::_make_static_initializer(Error &r_error, GDS
25552547 bool is_static = true ;
25562548 Variant rpc_config;
25572549 GDScriptDataType return_type;
2558- return_type.has_type = true ;
25592550 return_type.kind = GDScriptDataType::BUILTIN;
25602551 return_type.builtin_type = Variant::NIL;
25612552
@@ -2581,7 +2572,7 @@ GDScriptFunction *GDScriptCompiler::_make_static_initializer(Error &r_error, GDS
25812572 }
25822573
25832574 GDScriptDataType field_type = _gdtype_from_datatype (field->get_datatype (), codegen.script );
2584- if (field_type.has_type ) {
2575+ if (field_type.has_type () ) {
25852576 codegen.generator ->write_newline (field->start_line );
25862577
25872578 if (field_type.builtin_type == Variant::ARRAY && field_type.has_container_element_type (0 )) {
@@ -2876,7 +2867,7 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP
28762867 PropertyInfo export_info = variable->export_info ;
28772868
28782869 if (variable->exported ) {
2879- if (!minfo.data_type .has_type ) {
2870+ if (!minfo.data_type .has_type () ) {
28802871 prop_info.type = export_info.type ;
28812872 prop_info.class_name = export_info.class_name ;
28822873 }
@@ -3071,7 +3062,6 @@ Error GDScriptCompiler::_compile_class(GDScript *p_script, const GDScriptParser:
30713062 p_script->placeholders .erase (psi); // remove placeholder
30723063
30733064 GDScriptInstance *instance = memnew (GDScriptInstance);
3074- instance->base_ref_counted = Object::cast_to<RefCounted>(E->get ());
30753065 instance->members .resize (p_script->member_indices .size ());
30763066 instance->script = Ref<GDScript>(p_script);
30773067 instance->owner = E->get ();
0 commit comments