|
@@ -84,7 +84,7 @@ void GDScriptCompiler::_set_error(const String &p_error, const GDScriptParser::N
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::DataType &p_datatype, GDScript *p_owner) {
|
|
|
|
|
|
+GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::DataType &p_datatype, GDScript *p_owner, bool p_handle_metatype) {
|
|
if (!p_datatype.is_set() || !p_datatype.is_hard_type() || p_datatype.is_coroutine) {
|
|
if (!p_datatype.is_set() || !p_datatype.is_hard_type() || p_datatype.is_coroutine) {
|
|
return GDScriptDataType();
|
|
return GDScriptDataType();
|
|
}
|
|
}
|
|
@@ -101,11 +101,25 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
} break;
|
|
} break;
|
|
case GDScriptParser::DataType::NATIVE: {
|
|
case GDScriptParser::DataType::NATIVE: {
|
|
|
|
+ if (p_handle_metatype && p_datatype.is_meta_type) {
|
|
|
|
+ result.kind = GDScriptDataType::NATIVE;
|
|
|
|
+ result.builtin_type = Variant::OBJECT;
|
|
|
|
+ result.native_type = GDScriptNativeClass::get_class_static();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
result.kind = GDScriptDataType::NATIVE;
|
|
result.kind = GDScriptDataType::NATIVE;
|
|
result.native_type = p_datatype.native_type;
|
|
result.native_type = p_datatype.native_type;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
} break;
|
|
} break;
|
|
case GDScriptParser::DataType::SCRIPT: {
|
|
case GDScriptParser::DataType::SCRIPT: {
|
|
|
|
+ if (p_handle_metatype && p_datatype.is_meta_type) {
|
|
|
|
+ result.kind = GDScriptDataType::NATIVE;
|
|
|
|
+ result.builtin_type = Variant::OBJECT;
|
|
|
|
+ result.native_type = p_datatype.script_type.is_valid() ? p_datatype.script_type->get_class() : Script::get_class_static();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
result.kind = GDScriptDataType::SCRIPT;
|
|
result.kind = GDScriptDataType::SCRIPT;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
result.script_type_ref = p_datatype.script_type;
|
|
result.script_type_ref = p_datatype.script_type;
|
|
@@ -113,6 +127,13 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
|
|
result.native_type = p_datatype.native_type;
|
|
result.native_type = p_datatype.native_type;
|
|
} break;
|
|
} break;
|
|
case GDScriptParser::DataType::CLASS: {
|
|
case GDScriptParser::DataType::CLASS: {
|
|
|
|
+ if (p_handle_metatype && p_datatype.is_meta_type) {
|
|
|
|
+ result.kind = GDScriptDataType::NATIVE;
|
|
|
|
+ result.builtin_type = Variant::OBJECT;
|
|
|
|
+ result.native_type = GDScript::get_class_static();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
result.kind = GDScriptDataType::GDSCRIPT;
|
|
result.kind = GDScriptDataType::GDSCRIPT;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
result.native_type = p_datatype.native_type;
|
|
result.native_type = p_datatype.native_type;
|
|
@@ -148,6 +169,12 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
|
|
}
|
|
}
|
|
} break;
|
|
} break;
|
|
case GDScriptParser::DataType::ENUM:
|
|
case GDScriptParser::DataType::ENUM:
|
|
|
|
+ if (p_handle_metatype && p_datatype.is_meta_type) {
|
|
|
|
+ result.kind = GDScriptDataType::BUILTIN;
|
|
|
|
+ result.builtin_type = Variant::DICTIONARY;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
result.kind = GDScriptDataType::BUILTIN;
|
|
result.kind = GDScriptDataType::BUILTIN;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
result.builtin_type = p_datatype.builtin_type;
|
|
break;
|
|
break;
|
|
@@ -159,7 +186,7 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
|
|
}
|
|
}
|
|
|
|
|
|
if (p_datatype.has_container_element_type()) {
|
|
if (p_datatype.has_container_element_type()) {
|
|
- result.set_container_element_type(_gdtype_from_datatype(p_datatype.get_container_element_type(), p_owner));
|
|
|
|
|
|
+ result.set_container_element_type(_gdtype_from_datatype(p_datatype.get_container_element_type(), p_owner, false));
|
|
}
|
|
}
|
|
|
|
|
|
return result;
|
|
return result;
|
|
@@ -533,7 +560,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
|
} break;
|
|
} break;
|
|
case GDScriptParser::Node::CAST: {
|
|
case GDScriptParser::Node::CAST: {
|
|
const GDScriptParser::CastNode *cn = static_cast<const GDScriptParser::CastNode *>(p_expression);
|
|
const GDScriptParser::CastNode *cn = static_cast<const GDScriptParser::CastNode *>(p_expression);
|
|
- GDScriptDataType cast_type = _gdtype_from_datatype(cn->get_datatype(), codegen.script);
|
|
|
|
|
|
+ GDScriptDataType cast_type = _gdtype_from_datatype(cn->get_datatype(), codegen.script, false);
|
|
|
|
|
|
GDScriptCodeGenerator::Address result;
|
|
GDScriptCodeGenerator::Address result;
|
|
if (cast_type.has_type) {
|
|
if (cast_type.has_type) {
|
|
@@ -911,7 +938,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
|
GDScriptCodeGenerator::Address result = codegen.add_temporary(_gdtype_from_datatype(type_test->get_datatype(), codegen.script));
|
|
GDScriptCodeGenerator::Address result = codegen.add_temporary(_gdtype_from_datatype(type_test->get_datatype(), codegen.script));
|
|
|
|
|
|
GDScriptCodeGenerator::Address operand = _parse_expression(codegen, r_error, type_test->operand);
|
|
GDScriptCodeGenerator::Address operand = _parse_expression(codegen, r_error, type_test->operand);
|
|
- GDScriptDataType test_type = _gdtype_from_datatype(type_test->test_datatype, codegen.script);
|
|
|
|
|
|
+ GDScriptDataType test_type = _gdtype_from_datatype(type_test->test_datatype, codegen.script, false);
|
|
if (r_error) {
|
|
if (r_error) {
|
|
return GDScriptCodeGenerator::Address();
|
|
return GDScriptCodeGenerator::Address();
|
|
}
|
|
}
|
|
@@ -2587,7 +2614,7 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- GDScriptDataType base_type = _gdtype_from_datatype(p_class->base_type, p_script);
|
|
|
|
|
|
+ GDScriptDataType base_type = _gdtype_from_datatype(p_class->base_type, p_script, false);
|
|
|
|
|
|
int native_idx = GDScriptLanguage::get_singleton()->get_global_map()[base_type.native_type];
|
|
int native_idx = GDScriptLanguage::get_singleton()->get_global_map()[base_type.native_type];
|
|
p_script->native = GDScriptLanguage::get_singleton()->get_global_array()[native_idx];
|
|
p_script->native = GDScriptLanguage::get_singleton()->get_global_array()[native_idx];
|