feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -1640,13 +1640,12 @@ void GDScriptAnalyzer::resolve_annotation(GDScriptParser::AnnotationNode *p_anno
|
|||
|
||||
const MethodInfo &annotation_info = parser->valid_annotations[p_annotation->name].info;
|
||||
|
||||
const List<PropertyInfo>::Element *E = annotation_info.arguments.front();
|
||||
for (int i = 0; i < p_annotation->arguments.size(); i++) {
|
||||
for (int64_t i = 0, j = 0; i < p_annotation->arguments.size(); i++) {
|
||||
GDScriptParser::ExpressionNode *argument = p_annotation->arguments[i];
|
||||
const PropertyInfo &argument_info = E->get();
|
||||
const PropertyInfo &argument_info = annotation_info.arguments[j];
|
||||
|
||||
if (E->next() != nullptr) {
|
||||
E = E->next();
|
||||
if (j + 1 < annotation_info.arguments.size()) {
|
||||
++j;
|
||||
}
|
||||
|
||||
reduce_expression(argument);
|
||||
|
|
@ -1715,6 +1714,12 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
|
|||
static_context = p_function->is_static;
|
||||
}
|
||||
|
||||
MethodInfo method_info;
|
||||
method_info.name = function_name;
|
||||
if (p_function->is_static) {
|
||||
method_info.flags |= MethodFlags::METHOD_FLAG_STATIC;
|
||||
}
|
||||
|
||||
GDScriptParser::DataType prev_datatype = p_function->get_datatype();
|
||||
|
||||
GDScriptParser::DataType resolving_datatype;
|
||||
|
|
@ -1734,6 +1739,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
|
|||
|
||||
for (int i = 0; i < p_function->parameters.size(); i++) {
|
||||
resolve_parameter(p_function->parameters[i]);
|
||||
method_info.arguments.push_back(p_function->parameters[i]->get_datatype().to_property_info(p_function->parameters[i]->identifier->name));
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (p_function->parameters[i]->usages == 0 && !String(p_function->parameters[i]->identifier->name).begins_with("_")) {
|
||||
parser->push_warning(p_function->parameters[i]->identifier, GDScriptWarning::UNUSED_PARAMETER, function_visible_name, p_function->parameters[i]->identifier->name);
|
||||
|
|
@ -1797,7 +1803,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
|
|||
GDScriptParser::DataType parent_return_type;
|
||||
List<GDScriptParser::DataType> parameters_types;
|
||||
int default_par_count = 0;
|
||||
BitField<MethodFlags> method_flags;
|
||||
BitField<MethodFlags> method_flags = {};
|
||||
StringName native_base;
|
||||
if (!p_is_lambda && get_function_signature(p_function, false, base_type, function_name, parent_return_type, parameters_types, default_par_count, method_flags, &native_base)) {
|
||||
bool valid = p_function->is_static == method_flags.has_flag(METHOD_FLAG_STATIC);
|
||||
|
|
@ -1884,6 +1890,10 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
|
|||
}
|
||||
#endif
|
||||
|
||||
method_info.default_arguments.append_array(p_function->default_arg_values);
|
||||
method_info.return_val = p_function->get_datatype().to_property_info("");
|
||||
p_function->info = method_info;
|
||||
|
||||
if (p_function->get_datatype().is_resolving()) {
|
||||
p_function->set_datatype(prev_datatype);
|
||||
}
|
||||
|
|
@ -2158,7 +2168,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) {
|
|||
GDScriptParser::IdentifierNode *callee = static_cast<GDScriptParser::IdentifierNode *>(call->callee);
|
||||
if (callee->name == "range") {
|
||||
list_resolved = true;
|
||||
if (call->arguments.size() < 1) {
|
||||
if (call->arguments.is_empty()) {
|
||||
push_error(R"*(Invalid call for "range()" function. Expected at least 1 argument, none given.)*", call->callee);
|
||||
} else if (call->arguments.size() > 3) {
|
||||
push_error(vformat(R"*(Invalid call for "range()" function. Expected at most 3 arguments, %d given.)*", call->arguments.size()), call->callee);
|
||||
|
|
@ -2266,7 +2276,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) {
|
|||
GDScriptParser::DataType return_type;
|
||||
List<GDScriptParser::DataType> par_types;
|
||||
int default_arg_count = 0;
|
||||
BitField<MethodFlags> method_flags;
|
||||
BitField<MethodFlags> method_flags = {};
|
||||
if (get_function_signature(p_for->list, false, list_type, CoreStringName(_iter_get), return_type, par_types, default_arg_count, method_flags)) {
|
||||
variable_type = return_type;
|
||||
variable_type.type_source = list_type.type_source;
|
||||
|
|
@ -3323,28 +3333,24 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|||
|
||||
bool types_match = true;
|
||||
|
||||
{
|
||||
List<PropertyInfo>::ConstIterator arg_itr = info.arguments.begin();
|
||||
for (int i = 0; i < p_call->arguments.size(); ++arg_itr, ++i) {
|
||||
GDScriptParser::DataType par_type = type_from_property(*arg_itr, true);
|
||||
GDScriptParser::DataType arg_type = p_call->arguments[i]->get_datatype();
|
||||
if (!is_type_compatible(par_type, arg_type, true)) {
|
||||
types_match = false;
|
||||
break;
|
||||
for (int64_t i = 0; i < p_call->arguments.size(); ++i) {
|
||||
GDScriptParser::DataType par_type = type_from_property(info.arguments[i], true);
|
||||
GDScriptParser::DataType arg_type = p_call->arguments[i]->get_datatype();
|
||||
if (!is_type_compatible(par_type, arg_type, true)) {
|
||||
types_match = false;
|
||||
break;
|
||||
#ifdef DEBUG_ENABLED
|
||||
} else {
|
||||
if (par_type.builtin_type == Variant::INT && arg_type.builtin_type == Variant::FLOAT && builtin_type != Variant::INT) {
|
||||
parser->push_warning(p_call, GDScriptWarning::NARROWING_CONVERSION, function_name);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (par_type.builtin_type == Variant::INT && arg_type.builtin_type == Variant::FLOAT && builtin_type != Variant::INT) {
|
||||
parser->push_warning(p_call, GDScriptWarning::NARROWING_CONVERSION, function_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (types_match) {
|
||||
List<PropertyInfo>::ConstIterator arg_itr = info.arguments.begin();
|
||||
for (int i = 0; i < p_call->arguments.size(); ++arg_itr, ++i) {
|
||||
GDScriptParser::DataType par_type = type_from_property(*arg_itr, true);
|
||||
for (int64_t i = 0; i < p_call->arguments.size(); ++i) {
|
||||
GDScriptParser::DataType par_type = type_from_property(info.arguments[i], true);
|
||||
if (p_call->arguments[i]->is_constant) {
|
||||
update_const_expression_builtin_type(p_call->arguments[i], par_type, "pass");
|
||||
}
|
||||
|
|
@ -3561,7 +3567,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|||
}
|
||||
|
||||
int default_arg_count = 0;
|
||||
BitField<MethodFlags> method_flags;
|
||||
BitField<MethodFlags> method_flags = {};
|
||||
GDScriptParser::DataType return_type;
|
||||
List<GDScriptParser::DataType> par_types;
|
||||
|
||||
|
|
@ -5574,7 +5580,7 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo
|
|||
result.set_container_element_type(0, elem_type);
|
||||
} else if (p_property.type == Variant::DICTIONARY && p_property.hint == PROPERTY_HINT_DICTIONARY_TYPE) {
|
||||
// Check element type.
|
||||
StringName key_elem_type_name = p_property.hint_string.get_slice(";", 0);
|
||||
StringName key_elem_type_name = p_property.hint_string.get_slicec(';', 0);
|
||||
GDScriptParser::DataType key_elem_type;
|
||||
key_elem_type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
|
||||
|
|
@ -5599,7 +5605,7 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo
|
|||
}
|
||||
key_elem_type.is_constant = false;
|
||||
|
||||
StringName value_elem_type_name = p_property.hint_string.get_slice(";", 1);
|
||||
StringName value_elem_type_name = p_property.hint_string.get_slicec(';', 1);
|
||||
GDScriptParser::DataType value_elem_type;
|
||||
value_elem_type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue