Godot Engine – Multi-platform 2D and 3D game engine
Replace `Vector` with `LocalVector` in GDScript AST
HolonProduction64db4e560b3c
diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp b/modules/gdscript/editor/gdscript_translation_parser_plugin.cppindex 0dd707b5e73..f1913541d35 100644--- a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp+++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp@@ -34,6 +34,7 @@#include "../gdscript_analyzer.h"#include "core/io/resource_loader.h"+#include "core/templates/fixed_vector.h"void GDScriptEditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_extensions) const {r_extensions->push_back(GDScriptLanguage::get_singleton()->get_extension());@@ -140,8 +141,7 @@ void GDScriptEditorTranslationParserPlugin::_add_id_ctx_plural(const Vector<Stri}void GDScriptEditorTranslationParserPlugin::_traverse_class(const GDScriptParser::ClassNode *p_class) {- for (int i = 0; i < p_class->members.size(); i++) {- const GDScriptParser::ClassNode::Member &m = p_class->members[i];+ for (const GDScriptParser::ClassNode::Member &m : p_class->members) {// Other member types can't contain translatable strings.switch (m.type) {case GDScriptParser::ClassNode::Member::CLASS:@@ -168,8 +168,8 @@ void GDScriptEditorTranslationParserPlugin::_traverse_function(const GDScriptParreturn;}- for (int i = 0; i < p_func->parameters.size(); i++) {- _assess_expression(p_func->parameters[i]->initializer);+ for (const GDScriptParser::ParameterNode *param : p_func->parameters) {+ _assess_expression(param->initializer);}_traverse_block(p_func->body);}@@ -179,10 +179,8 @@ void GDScriptEditorTranslationParserPlugin::_traverse_block(const GDScriptParserreturn;}- const Vector<GDScriptParser::Node *> &statements = p_suite->statements;- for (int i = 0; i < statements.size(); i++) {- const GDScriptParser::Node *statement = statements[i];-+ const LocalVector<GDScriptParser::Node *> &statements = p_suite->statements;+ for (const GDScriptParser::Node *statement : statements) {// BREAK, BREAKPOINT, CONSTANT, CONTINUE, and PASS are skipped because they can't contain translatable strings.switch (statement->type) {case GDScriptParser::Node::ASSERT: {@@ -207,9 +205,9 @@ void GDScriptEditorTranslationParserPlugin::_traverse_block(const GDScriptParsercase GDScriptParser::Node::MATCH: {const GDScriptParser::MatchNode *match_node = static_cast<const GDScriptParser::MatchNode *>(statement);_assess_expression(match_node->test);- for (int j = 0; j < match_node->branches.size(); j++) {- _traverse_block(match_node->branches[j]->guard_body);- _traverse_block(match_node->branches[j]->block);+ for (const GDScriptParser::MatchBranchNode *branch : match_node->branches) {+ _traverse_block(branch->guard_body);+ _traverse_block(branch->block);}} break;case GDScriptParser::Node::RETURN: {@@ -243,8 +241,8 @@ void GDScriptEditorTranslationParserPlugin::_assess_expression(const GDScriptParswitch (p_expression->type) {case GDScriptParser::Node::ARRAY: {const GDScriptParser::ArrayNode *array_node = static_cast<const GDScriptParser::ArrayNode *>(p_expression);- for (int i = 0; i < array_node->elements.size(); i++) {- _assess_expression(array_node->elements[i]);+ for (GDScriptParser::ExpressionNode *expr : array_node->elements) {+ _assess_expression(expr);}} break;case GDScriptParser::Node::ASSIGNMENT: {@@ -266,9 +264,9 @@ void GDScriptEditorTranslationParserPlugin::_assess_expression(const GDScriptPar} break;case GDScriptParser::Node::DICTIONARY: {const GDScriptParser::DictionaryNode *dict_node = static_cast<const GDScriptParser::DictionaryNode *>(p_expression);- for (int i = 0; i < dict_node->elements.size(); i++) {- _assess_expression(dict_node->elements[i].key);- _assess_expression(dict_node->elements[i].value);+ for (const GDScriptParser::DictionaryNode::Pair &element : dict_node->elements) {+ _assess_expression(element.key);+ _assess_expression(element.value);}} break;case GDScriptParser::Node::LAMBDA: {@@ -327,8 +325,8 @@ void GDScriptEditorTranslationParserPlugin::_assess_assignment(const GDScriptParvoid GDScriptEditorTranslationParserPlugin::_assess_call(const GDScriptParser::CallNode *p_call) {_assess_expression(p_call->callee);- for (int i = 0; i < p_call->arguments.size(); i++) {- _assess_expression(p_call->arguments[i]);+ for (GDScriptParser::ExpressionNode *arg : p_call->arguments) {+ _assess_expression(arg);}// Extract the translatable strings coming from function calls. For example:@@ -343,7 +341,7 @@ void GDScriptEditorTranslationParserPlugin::_assess_call(const GDScriptParser::Cif (function_name == tr_func || function_name == atr_func) {// Extract from `tr(id, ctx)` or `atr(id, ctx)`.- for (int i = 0; i < p_call->arguments.size(); i++) {+ for (uint32_t i = 0; i < p_call->arguments.size(); i++) {if (_is_constant_string(p_call->arguments[i])) {id_ctx_plural.write[i] = p_call->arguments[i]->reduced_value;} else {@@ -356,11 +354,8 @@ void GDScriptEditorTranslationParserPlugin::_assess_call(const GDScriptParser::C}} else if (function_name == trn_func || function_name == atrn_func) {// Extract from `tr_n(id, plural, n, ctx)` or `atr_n(id, plural, n, ctx)`.- Vector<int> indices;- indices.push_back(0);- indices.push_back(3);- indices.push_back(1);- for (int i = 0; i < indices.size(); i++) {+ FixedVector<uint32_t, 3> indices = { 0, 3, 1 };+ for (uint32_t i = 0; i < indices.size(); i++) {if (indices[i] >= p_call->arguments.size()) {continue;}@@ -429,8 +424,8 @@ void GDScriptEditorTranslationParserPlugin::_extract_fd_filter_array(const GDScr}if (array_node) {- for (int i = 0; i < array_node->elements.size(); i++) {- _extract_fd_filter_string(array_node->elements[i], array_node->elements[i]->start_line);+ for (GDScriptParser::ExpressionNode *expr : array_node->elements) {+ _extract_fd_filter_string(expr, expr->start_line);}}}diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cppindex 03949a330d4..a3451b2cd55 100644--- a/modules/gdscript/gdscript.cpp+++ b/modules/gdscript/gdscript.cpp@@ -561,9 +561,7 @@ bool GDScript::_update_exports(bool *r_err, bool p_recursive_call, PlaceHolderScmembers_cache.push_back(get_class_category());- for (int i = 0; i < c->members.size(); i++) {- const GDScriptParser::ClassNode::Member &member = c->members[i];-+ for (const GDScriptParser::ClassNode::Member &member : c->members) {switch (member.type) {case GDScriptParser::ClassNode::Member::VARIABLE: {if (!member.variable->exported) {@@ -2791,7 +2789,7 @@ String GDScriptLanguage::_get_global_class_name(const String &p_path, String *r_while (extend_classes.size() > 0) {bool found = false;- for (int i = 0; i < subclass->members.size(); i++) {+ for (uint32_t i = 0; i < subclass->members.size(); i++) {if (subclass->members[i].type != GDScriptParser::ClassNode::Member::CLASS) {continue;}diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cppindex 199657754d3..1cdaac920f2 100644--- a/modules/gdscript/gdscript_analyzer.cpp+++ b/modules/gdscript/gdscript_analyzer.cpp@@ -235,18 +235,17 @@ static GDScriptParser::DataType make_builtin_meta_type(Variant::Type p_type) {bool GDScriptAnalyzer::has_member_name_conflict_in_script_class(const StringName &p_member_name, const GDScriptParser::ClassNode *p_class, const GDScriptParser::Node *p_member) {if (p_class->members_indices.has(p_member_name)) {- int index = p_class->members_indices[p_member_name];- const GDScriptParser::ClassNode::Member *member = &p_class->members[index];-- if (member->type == GDScriptParser::ClassNode::Member::VARIABLE ||- member->type == GDScriptParser::ClassNode::Member::CONSTANT ||- member->type == GDScriptParser::ClassNode::Member::ENUM ||- member->type == GDScriptParser::ClassNode::Member::ENUM_VALUE ||- member->type == GDScriptParser::ClassNode::Member::CLASS ||- member->type == GDScriptParser::ClassNode::Member::SIGNAL) {+ const GDScriptParser::ClassNode::Member &member = p_class->get_member(p_member_name);++ if (member.type == GDScriptParser::ClassNode::Member::VARIABLE ||+ member.type == GDScriptParser::ClassNode::Member::CONSTANT ||+ member.type == GDScriptParser::ClassNode::Member::ENUM ||+ member.type == GDScriptParser::ClassNode::Member::ENUM_VALUE ||+ member.type == GDScriptParser::ClassNode::Member::CLASS ||+ member.type == GDScriptParser::ClassNode::Member::SIGNAL) {return true;}- if (p_member->type != GDScriptParser::Node::FUNCTION && member->type == GDScriptParser::ClassNode::Member::FUNCTION) {+ if (p_member->type != GDScriptParser::Node::FUNCTION && member.type == GDScriptParser::ClassNode::Member::FUNCTION) {return true;}}@@ -653,9 +652,9 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_cError err = OK;if (p_recursive) {- for (int i = 0; i < p_class->members.size(); i++) {- if (p_class->members[i].type == GDScriptParser::ClassNode::Member::CLASS) {- const Error inner_err = resolve_class_inheritance(p_class->members[i].m_class, true);+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {+ if (member.type == GDScriptParser::ClassNode::Member::CLASS) {+ const Error inner_err = resolve_class_inheritance(member.m_class, true);if (inner_err != OK && err == OK) {err = inner_err;}@@ -922,7 +921,7 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Typeif (p_type->type_chain.size() > 1) {if (result.kind == GDScriptParser::DataType::CLASS) {- for (int i = 1; i < p_type->type_chain.size(); i++) {+ for (uint32_t i = 1; i < p_type->type_chain.size(); i++) {GDScriptParser::DataType base = result;reduce_identifier_from_base(p_type->type_chain[i], &base);result = p_type->type_chain[i]->type_constraint;@@ -979,10 +978,10 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,resolve_class_member(p_class, p_class->members_indices[p_name], p_source);}-void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class, int p_index, const GDScriptParser::Node *p_source) {- ERR_FAIL_INDEX(p_index, p_class->members.size());+void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class, uint32_t p_index, const GDScriptParser::Node *p_source) {+ ERR_FAIL_UNSIGNED_INDEX(p_index, p_class->members.size());- GDScriptParser::ClassNode::Member &member = p_class->members.write[p_index];+ GDScriptParser::ClassNode::Member &member = p_class->members[p_index];if (p_source == nullptr && parser->has_class(p_class)) {p_source = member.get_source_node();}@@ -1141,8 +1140,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,// MethodInfo inline so it's a tiny bit more efficient.MethodInfo mi = MethodInfo(member.signal->identifier->name);- for (int j = 0; j < member.signal->parameters.size(); j++) {- GDScriptParser::ParameterNode *param = member.signal->parameters[j];+ for (GDScriptParser::ParameterNode *param : member.signal->parameters) {GDScriptParser::DataType param_type = type_from_metatype(resolve_datatype(param->datatype_specifier));param->type_constraint = param_type;#ifdef DEBUG_ENABLED@@ -1172,9 +1170,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,current_enum = member.m_enum;Dictionary dictionary;- for (int j = 0; j < member.m_enum->values.size(); j++) {- GDScriptParser::EnumNode::Value &element = member.m_enum->values.write[j];-+ for (GDScriptParser::EnumNode::Value &element : member.m_enum->values) {if (element.custom_value) {reduce_expression(element.custom_value);if (!element.custom_value->is_constant) {@@ -1257,7 +1253,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,}// Also update the original references.- member.enum_value.parent_enum->values.set(member.enum_value.index, member.enum_value);+ member.enum_value.parent_enum->values[member.enum_value.index] = member.enum_value;member.enum_value.identifier->type_constraint = make_class_enum_type(UNNAMED_ENUM, p_class, parser->script_path, false);} break;@@ -1329,7 +1325,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clasresolve_class_interface(base_class, p_class);}- for (int i = 0; i < p_class->members.size(); i++) {+ for (uint32_t i = 0; i < p_class->members.size(); i++) {resolve_class_member(p_class, i);#ifdef DEBUG_ENABLED@@ -1361,8 +1357,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clasresolve_class_interface(p_class);if (p_recursive) {- for (int i = 0; i < p_class->members.size(); i++) {- GDScriptParser::ClassNode::Member member = p_class->members[i];+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {if (member.type == GDScriptParser::ClassNode::Member::CLASS) {resolve_class_interface(member.m_class, true);}@@ -1420,8 +1415,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co}// Do functions, properties, and groups now.- for (int i = 0; i < p_class->members.size(); i++) {- GDScriptParser::ClassNode::Member member = p_class->members[i];+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {if (member.type == GDScriptParser::ClassNode::Member::FUNCTION) {// Apply annotations.for (GDScriptParser::AnnotationNode *&E : member.function->annotations) {@@ -1453,8 +1447,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co}// Check unused variables and datatypes of property getters and setters.- for (int i = 0; i < p_class->members.size(); i++) {- GDScriptParser::ClassNode::Member member = p_class->members[i];+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {if (member.type == GDScriptParser::ClassNode::Member::VARIABLE) {#ifdef DEBUG_ENABLEDif (member.variable->usages == 0 && String(member.variable->identifier->name).begins_with("_")) {@@ -1589,8 +1582,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, boresolve_class_body(p_class);if (p_recursive) {- for (int i = 0; i < p_class->members.size(); i++) {- GDScriptParser::ClassNode::Member member = p_class->members[i];+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {if (member.type == GDScriptParser::ClassNode::Member::CLASS) {resolve_class_body(member.m_class, true);}@@ -1695,7 +1687,7 @@ void GDScriptAnalyzer::resolve_annotation(GDScriptParser::AnnotationNode *p_annoconst MethodInfo &annotation_info = parser->valid_annotations[p_annotation->name].info;- for (int64_t i = 0, j = 0; i < p_annotation->arguments.size(); i++) {+ for (uint32_t i = 0, j = 0; i < p_annotation->arguments.size(); i++) {GDScriptParser::ExpressionNode *argument = p_annotation->arguments[i];const PropertyInfo &argument_info = annotation_info.arguments[j];@@ -1785,20 +1777,20 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *int default_value_count = 0;#endif // TOOLS_ENABLED- 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]->type_constraint.to_property_info(p_function->parameters[i]->identifier->name));+ for (GDScriptParser::ParameterNode *param : p_function->parameters) {+ resolve_parameter(param);+ method_info.arguments.push_back(param->type_constraint.to_property_info(param->identifier->name));#ifdef DEBUG_ENABLED- is_shadowing(p_function->parameters[i]->identifier, "function parameter", true);+ is_shadowing(param->identifier, "function parameter", true);#endif // DEBUG_ENABLED- if (p_function->parameters[i]->initializer) {+ if (param->initializer) {#ifdef TOOLS_ENABLEDdefault_value_count++;#endif // TOOLS_ENABLED- if (p_function->parameters[i]->initializer->is_constant) {- p_function->default_arg_values.push_back(p_function->parameters[i]->initializer->reduced_value);+ if (param->initializer->is_constant) {+ p_function->default_arg_values.push_back(param->initializer->reduced_value);} else {p_function->default_arg_values.push_back(Variant()); // Prevent shift.}@@ -1917,7 +1909,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *valid = valid && current_min_argc <= parent_min_argc && parent_max_argc <= current_max_argc;if (valid) {- int i = 0;+ uint32_t i = 0;for (const GDScriptParser::DataType &parent_par_type : parameters_types) {if (i >= p_function->parameters.size()) {break;@@ -2082,8 +2074,7 @@ void GDScriptAnalyzer::decide_pattern_type(GDScriptParser::PatternNode &p_patter}void GDScriptAnalyzer::resolve_suite(GDScriptParser::SuiteNode *p_suite, bool p_is_root) {- for (int i = 0; i < p_suite->statements.size(); i++) {- GDScriptParser::Node *stmt = p_suite->statements[i];+ for (GDScriptParser::Node *stmt : p_suite->statements) {// Apply annotations.for (GDScriptParser::AnnotationNode *&E : stmt->annotations) {resolve_annotation(E);@@ -2485,8 +2476,8 @@ void GDScriptAnalyzer::resolve_assert(GDScriptParser::AssertNode *p_assert) {void GDScriptAnalyzer::resolve_match(GDScriptParser::MatchNode *p_match) {reduce_expression(p_match->test);- for (int i = 0; i < p_match->branches.size(); i++) {- resolve_match_branch(p_match->branches[i], p_match->test);+ for (GDScriptParser::MatchBranchNode *branch : p_match->branches) {+ resolve_match_branch(branch, p_match->test);}}@@ -2497,8 +2488,8 @@ void GDScriptAnalyzer::resolve_match_branch(GDScriptParser::MatchBranchNode *p_mE->apply(parser, p_match_branch, nullptr); // TODO: Provide `p_class`.}- for (int i = 0; i < p_match_branch->patterns.size(); i++) {- resolve_match_pattern(p_match_branch->patterns[i], p_match_test);+ for (GDScriptParser::PatternNode *pattern : p_match_branch->patterns) {+ resolve_match_pattern(pattern, p_match_test);}if (p_match_branch->guard_body) {@@ -2564,24 +2555,24 @@ void GDScriptAnalyzer::resolve_match_pattern(GDScriptParser::PatternNode *p_matc#endif // DEBUG_ENABLEDbreak;case GDScriptParser::PatternNode::PT_ARRAY:- for (int i = 0; i < p_match_pattern->array.size(); i++) {- resolve_match_pattern(p_match_pattern->array[i], nullptr);- decide_pattern_type(*p_match_pattern, p_match_pattern->array[i]);+ for (GDScriptParser::PatternNode *element_pattern : p_match_pattern->array) {+ resolve_match_pattern(element_pattern, nullptr);+ decide_pattern_type(*p_match_pattern, element_pattern);}result = p_match_pattern->type_constraint;break;case GDScriptParser::PatternNode::PT_DICTIONARY:- for (int i = 0; i < p_match_pattern->dictionary.size(); i++) {- if (p_match_pattern->dictionary[i].key) {- reduce_expression(p_match_pattern->dictionary[i].key);- if (!p_match_pattern->dictionary[i].key->is_constant) {- push_error(R"(Expression in dictionary pattern key must be a constant.)", p_match_pattern->dictionary[i].key);+ for (const GDScriptParser::PatternNode::Pair &element_pattern : p_match_pattern->dictionary) {+ if (element_pattern.key) {+ reduce_expression(element_pattern.key);+ if (!element_pattern.key->is_constant) {+ push_error(R"(Expression in dictionary pattern key must be a constant.)", element_pattern.key);}}- if (p_match_pattern->dictionary[i].value_pattern) {- resolve_match_pattern(p_match_pattern->dictionary[i].value_pattern, nullptr);- decide_pattern_type(*p_match_pattern, p_match_pattern->dictionary[i].value_pattern);+ if (element_pattern.value_pattern) {+ resolve_match_pattern(element_pattern.value_pattern, nullptr);+ decide_pattern_type(*p_match_pattern, element_pattern.value_pattern);}}result = p_match_pattern->type_constraint;@@ -2776,8 +2767,7 @@ void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expre}void GDScriptAnalyzer::reduce_array(GDScriptParser::ArrayNode *p_array) {- for (int i = 0; i < p_array->elements.size(); i++) {- GDScriptParser::ExpressionNode *element = p_array->elements[i];+ for (GDScriptParser::ExpressionNode *element : p_array->elements) {reduce_expression(element);}@@ -2859,8 +2849,7 @@ void GDScriptAnalyzer::update_array_literal_element_type(GDScriptParser::ArrayNoGDScriptParser::DataType expected_type = p_element_type;expected_type.container_element_types.clear(); // Nested types (like `Array[Array[int]]`) are not currently supported.- for (int i = 0; i < p_array->elements.size(); i++) {- GDScriptParser::ExpressionNode *element_node = p_array->elements[i];+ for (GDScriptParser::ExpressionNode *element_node : p_array->elements) {if (element_node->is_constant) {update_const_expression_builtin_type(element_node, expected_type, "include");}@@ -2892,7 +2881,7 @@ void GDScriptAnalyzer::update_dictionary_literal_element_type(GDScriptParser::Diexpected_key_type.container_element_types.clear(); // Nested types (like `Dictionary[String, Array[int]]`) are not currently supported.expected_value_type.container_element_types.clear();- for (int i = 0; i < p_dictionary->elements.size(); i++) {+ for (uint32_t i = 0; i < p_dictionary->elements.size(); i++) {GDScriptParser::ExpressionNode *key_element_node = p_dictionary->elements[i].key;if (key_element_node->is_constant) {update_const_expression_builtin_type(key_element_node, expected_key_type, "include");@@ -3320,7 +3309,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_abool all_is_constant = true;HashMap<int, GDScriptParser::ArrayNode *> arrays; // For array literal to potentially type when passing.HashMap<int, GDScriptParser::DictionaryNode *> dictionaries; // Same, but for dictionaries.- for (int i = 0; i < p_call->arguments.size(); i++) {+ for (uint32_t i = 0; i < p_call->arguments.size(); i++) {reduce_expression(p_call->arguments[i]);if (p_call->arguments[i]->type == GDScriptParser::Node::ARRAY) {arrays[i] = static_cast<GDScriptParser::ArrayNode *>(p_call->arguments[i]);@@ -3365,8 +3354,8 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a// Construct here.Vector<const Variant *> args;- for (int i = 0; i < p_call->arguments.size(); i++) {- args.push_back(&(p_call->arguments[i]->reduced_value));+ for (const GDScriptParser::ExpressionNode *arg : p_call->arguments) {+ args.push_back(&(arg->reduced_value));}Callable::CallError err;@@ -3381,7 +3370,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_abreak;case Callable::CallError::CALL_ERROR_INVALID_METHOD: {String signature = Variant::get_type_name(builtin_type) + "(";- for (int i = 0; i < p_call->arguments.size(); i++) {+ for (uint32_t i = 0; i < p_call->arguments.size(); i++) {if (i > 0) {signature += ", ";}@@ -3454,7 +3443,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_abool types_match = true;- for (int64_t i = 0; i < p_call->arguments.size(); ++i) {+ for (uint32_t i = 0; i < p_call->arguments.size(); ++i) {GDScriptParser::DataType par_type = type_from_property(info.arguments[i], true, p_call);GDScriptParser::DataType arg_type = p_call->arguments[i]->type_constraint;if (!is_type_compatible(par_type, arg_type, true)) {@@ -3470,7 +3459,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a}if (types_match) {- for (int64_t i = 0; i < p_call->arguments.size(); ++i) {+ for (uint32_t i = 0; i < p_call->arguments.size(); ++i) {GDScriptParser::DataType par_type = type_from_property(info.arguments[i], true, p_call);if (p_call->arguments[i]->is_constant) {update_const_expression_builtin_type(p_call->arguments[i], par_type, "pass");@@ -3493,7 +3482,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_aif (!match) {String signature = Variant::get_type_name(builtin_type) + "(";- for (int i = 0; i < p_call->arguments.size(); i++) {+ for (uint32_t i = 0; i < p_call->arguments.size(); i++) {if (i > 0) {signature += ", ";}@@ -3535,8 +3524,8 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_aif (all_is_constant && GDScriptUtilityFunctions::is_function_constant(function_name)) {// Can call on compilation.Vector<const Variant *> args;- for (int i = 0; i < p_call->arguments.size(); i++) {- args.push_back(&(p_call->arguments[i]->reduced_value));+ for (const GDScriptParser::ExpressionNode *arg : p_call->arguments) {+ args.push_back(&(arg->reduced_value));}Variant value;@@ -3586,8 +3575,8 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_aif (all_is_constant && Variant::get_utility_function_type(function_name) == Variant::UTILITY_FUNC_TYPE_MATH) {// Can call on compilation.Vector<const Variant *> args;- for (int i = 0; i < p_call->arguments.size(); i++) {- args.push_back(&(p_call->arguments[i]->reduced_value));+ for (const GDScriptParser::ExpressionNode *arg : p_call->arguments) {+ args.push_back(&(arg->reduced_value));}Variant value;@@ -3921,8 +3910,7 @@ void GDScriptAnalyzer::reduce_cast(GDScriptParser::CastNode *p_cast) {void GDScriptAnalyzer::reduce_dictionary(GDScriptParser::DictionaryNode *p_dictionary) {HashMap<Variant, GDScriptParser::ExpressionNode *, HashMapHasherDefault, StringLikeVariantComparator> elements;- for (int i = 0; i < p_dictionary->elements.size(); i++) {- const GDScriptParser::DictionaryNode::Pair &element = p_dictionary->elements[i];+ for (const GDScriptParser::DictionaryNode::Pair &element : p_dictionary->elements) {if (p_dictionary->style == GDScriptParser::DictionaryNode::PYTHON_DICT) {reduce_expression(element.key);}@@ -4469,8 +4457,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident// Check if we are inside an enum. This allows enum values to access other elements of the same enum.if (current_enum) {- for (int i = 0; i < current_enum->values.size(); i++) {- const GDScriptParser::EnumNode::Value &element = current_enum->values[i];+ for (const GDScriptParser::EnumNode::Value &element : current_enum->values) {if (element.identifier->name == p_identifier->name) {StringName enum_name = current_enum->identifier ? current_enum->identifier->name : UNNAMED_ENUM;GDScriptParser::DataType type = make_class_enum_type(enum_name, parser->current_class, parser->script_path, false);@@ -5402,7 +5389,7 @@ Variant GDScriptAnalyzer::make_array_reduced_value(GDScriptParser::ArrayNode *p_Array array = p_array->type_constraint.has_container_element_type(0) ? make_array_from_element_datatype(p_array->type_constraint.get_container_element_type(0)) : Array();array.resize(p_array->elements.size());- for (int i = 0; i < p_array->elements.size(); i++) {+ for (uint32_t i = 0; i < p_array->elements.size(); i++) {GDScriptParser::ExpressionNode *element = p_array->elements[i];bool is_element_value_reduced = false;@@ -5425,9 +5412,7 @@ Variant GDScriptAnalyzer::make_dictionary_reduced_value(GDScriptParser::Dictiona? make_dictionary_from_element_datatype(p_dictionary->type_constraint.get_container_element_type_or_variant(0), p_dictionary->type_constraint.get_container_element_type_or_variant(1)): Dictionary();- for (int i = 0; i < p_dictionary->elements.size(); i++) {- const GDScriptParser::DictionaryNode::Pair &element = p_dictionary->elements[i];-+ for (const GDScriptParser::DictionaryNode::Pair &element : p_dictionary->elements) {bool is_element_key_reduced = false;Variant element_key = make_expression_reduced_value(element.key, is_element_key_reduced);if (!is_element_key_reduced) {@@ -5501,7 +5486,7 @@ Variant GDScriptAnalyzer::make_call_reduced_value(GDScriptParser::CallNode *p_caVector<Variant> args;args.resize(p_call->arguments.size());const Variant **argptrs = (const Variant **)alloca(sizeof(const Variant *) * args.size());- for (int i = 0; i < p_call->arguments.size(); i++) {+ for (uint32_t i = 0; i < p_call->arguments.size(); i++) {bool is_arg_value_reduced = false;Variant arg_value = make_expression_reduced_value(p_call->arguments[i], is_arg_value_reduced);if (!is_arg_value_reduced) {@@ -6066,9 +6051,9 @@ bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, boif (p_is_constructor || found_function->is_static) {r_method_flags.set_flag(METHOD_FLAG_STATIC);}- for (int i = 0; i < found_function->parameters.size(); i++) {- r_par_types.push_back(found_function->parameters[i]->type_constraint);- if (found_function->parameters[i]->initializer != nullptr) {+ for (GDScriptParser::ParameterNode *param : found_function->parameters) {+ r_par_types.push_back(param->type_constraint);+ if (param->initializer != nullptr) {r_default_arg_count++;}}@@ -6151,16 +6136,16 @@ void GDScriptAnalyzer::validate_call_arg(const MethodInfo &p_method, const GDScr}void GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p_par_types, int p_default_args_count, bool p_is_vararg, const GDScriptParser::CallNode *p_call) {- if (p_call->arguments.size() < p_par_types.size() - p_default_args_count) {+ if (p_call->arguments.size() < (uint32_t)(p_par_types.size() - p_default_args_count)) {push_error(vformat(R"*(Too few arguments for "%s()" call. Expected at least %d but received %d.)*", p_call->function_name, p_par_types.size() - p_default_args_count, p_call->arguments.size()), p_call);}- if (!p_is_vararg && p_call->arguments.size() > p_par_types.size()) {+ if (!p_is_vararg && p_call->arguments.size() > (uint32_t)p_par_types.size()) {push_error(vformat(R"*(Too many arguments for "%s()" call. Expected at most %d but received %d.)*", p_call->function_name, p_par_types.size(), p_call->arguments.size()), p_call->arguments[p_par_types.size()]);}List<GDScriptParser::DataType>::ConstIterator par_itr = p_par_types.begin();- for (int i = 0; i < p_call->arguments.size(); ++par_itr, ++i) {- if (i >= p_par_types.size()) {+ for (uint32_t i = 0; i < p_call->arguments.size(); ++par_itr, ++i) {+ if (i >= (uint32_t)p_par_types.size()) {// Already on vararg place.break;}@@ -6667,26 +6652,26 @@ void GDScriptAnalyzer::resolve_pending_lambda_bodies() {resolve_function_body(lambda->function, true);- int captures_amount = lambda->captures.size();+ uint32_t captures_amount = lambda->captures.size();if (captures_amount > 0) {// Create space for lambda parameters.// At the beginning to not mess with optional parameters.- int param_count = lambda->function->parameters.size();+ int64_t param_count = lambda->function->parameters.size();lambda->function->parameters.resize(param_count + captures_amount);- for (int i = param_count - 1; i >= 0; i--) {- lambda->function->parameters.write[i + captures_amount] = lambda->function->parameters[i];+ for (int64_t i = param_count - 1; i >= 0; i--) {+ lambda->function->parameters[i + captures_amount] = lambda->function->parameters[i];lambda->function->parameters_indices[lambda->function->parameters[i]->identifier->name] = i + captures_amount;}// Add captures as extra parameters at the beginning.- for (int i = 0; i < lambda->captures.size(); i++) {+ for (uint32_t i = 0; i < lambda->captures.size(); i++) {GDScriptParser::IdentifierNode *capture = lambda->captures[i];GDScriptParser::ParameterNode *capture_param = parser->alloc_node<GDScriptParser::ParameterNode>();capture_param->identifier = capture;capture_param->usages = capture->usages;capture_param->type_constraint = capture->type_constraint;- lambda->function->parameters.write[i] = capture_param;+ lambda->function->parameters[i] = capture_param;lambda->function->parameters_indices[capture->name] = i;}}diff --git a/modules/gdscript/gdscript_analyzer.h b/modules/gdscript/gdscript_analyzer.hindex b1b546831a6..73276e43547 100644--- a/modules/gdscript/gdscript_analyzer.h+++ b/modules/gdscript/gdscript_analyzer.h@@ -72,7 +72,7 @@ class GDScriptAnalyzer {void resolve_annotation(GDScriptParser::AnnotationNode *p_annotation);void resolve_class_member(GDScriptParser::ClassNode *p_class, const StringName &p_name, const GDScriptParser::Node *p_source = nullptr);- void resolve_class_member(GDScriptParser::ClassNode *p_class, int p_index, const GDScriptParser::Node *p_source = nullptr);+ void resolve_class_member(GDScriptParser::ClassNode *p_class, uint32_t p_index, const GDScriptParser::Node *p_source = nullptr);void resolve_class_interface(GDScriptParser::ClassNode *p_class, const GDScriptParser::Node *p_source = nullptr);void resolve_class_interface(GDScriptParser::ClassNode *p_class, bool p_recursive);void resolve_class_body(GDScriptParser::ClassNode *p_class, const GDScriptParser::Node *p_source = nullptr);diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cppindex c2f9aa27ad3..677dbdc288e 100644--- a/modules/gdscript/gdscript_compiler.cpp+++ b/modules/gdscript/gdscript_compiler.cpp@@ -506,8 +506,8 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &codeGDScriptDataType array_type = _gdtype_from_datatype(an->type_constraint, codegen.script);GDScriptCodeGenerator::Address result = codegen.add_temporary(array_type);- for (int i = 0; i < an->elements.size(); i++) {- GDScriptCodeGenerator::Address val = _parse_expression(codegen, r_error, an->elements[i]);+ for (GDScriptParser::ExpressionNode *expr : an->elements) {+ GDScriptCodeGenerator::Address val = _parse_expression(codegen, r_error, expr);if (r_error) {return GDScriptCodeGenerator::Address();}@@ -536,27 +536,27 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &codeGDScriptDataType dict_type = _gdtype_from_datatype(dn->type_constraint, codegen.script);GDScriptCodeGenerator::Address result = codegen.add_temporary(dict_type);- for (int i = 0; i < dn->elements.size(); i++) {+ for (const GDScriptParser::DictionaryNode::Pair &E : dn->elements) {// Key.GDScriptCodeGenerator::Address element;switch (dn->style) {case GDScriptParser::DictionaryNode::PYTHON_DICT:// Python-style: key is any expression.- element = _parse_expression(codegen, r_error, dn->elements[i].key);+ element = _parse_expression(codegen, r_error, E.key);if (r_error) {return GDScriptCodeGenerator::Address();}break;case GDScriptParser::DictionaryNode::LUA_TABLE:// Lua-style: key is an identifier interpreted as StringName.- StringName key = dn->elements[i].key->reduced_value.operator StringName();+ StringName key = E.key->reduced_value.operator StringName();element = codegen.add_constant(key);break;}elements.push_back(element);- element = _parse_expression(codegen, r_error, dn->elements[i].value);+ element = _parse_expression(codegen, r_error, E.value);if (r_error) {return GDScriptCodeGenerator::Address();}@@ -615,7 +615,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code}Vector<GDScriptCodeGenerator::Address> arguments;- for (int i = 0; i < call->arguments.size(); i++) {+ for (uint32_t i = 0; i < call->arguments.size(); i++) {GDScriptCodeGenerator::Address arg = _parse_expression(codegen, r_error, call->arguments[i]);if (r_error) {return GDScriptCodeGenerator::Address();@@ -1402,7 +1402,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &codeVector<GDScriptCodeGenerator::Address> captures;captures.resize(lambda->captures.size());- for (int i = 0; i < lambda->captures.size(); i++) {+ for (uint32_t i = 0; i < lambda->captures.size(); i++) {captures.write[i] = _parse_expression(codegen, r_error, lambda->captures[i]);if (r_error) {return GDScriptCodeGenerator::Address();@@ -1648,7 +1648,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_match_pattern(CodeGen &cGDScriptCodeGenerator::Address element_type_addr = codegen.add_temporary();// Evaluate element by element.- for (int i = 0; i < p_pattern->array.size(); i++) {+ for (uint32_t i = 0; i < p_pattern->array.size(); i++) {if (p_pattern->array[i]->pattern_type == GDScriptParser::PatternNode::PT_REST) {// Don't want to access an extra element of the user array.break;@@ -1745,8 +1745,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_match_pattern(CodeGen &cGDScriptCodeGenerator::Address element_type_addr = codegen.add_temporary();// Evaluate element by element.- for (int i = 0; i < p_pattern->dictionary.size(); i++) {- const GDScriptParser::PatternNode::Pair &element = p_pattern->dictionary[i];+ for (const GDScriptParser::PatternNode::Pair &element : p_pattern->dictionary) {if (element.value_pattern && element.value_pattern->pattern_type == GDScriptParser::PatternNode::PT_REST) {// Ignore rest pattern.break;@@ -1869,12 +1868,12 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_match_pattern(CodeGen &cList<GDScriptCodeGenerator::Address> GDScriptCompiler::_add_block_locals(CodeGen &codegen, const GDScriptParser::SuiteNode *p_block) {List<GDScriptCodeGenerator::Address> addresses;- for (int i = 0; i < p_block->locals.size(); i++) {- if (p_block->locals[i].type == GDScriptParser::SuiteNode::Local::PARAMETER || p_block->locals[i].type == GDScriptParser::SuiteNode::Local::FOR_VARIABLE) {+ for (const GDScriptParser::SuiteNode::Local &local : p_block->locals) {+ if (local.type == GDScriptParser::SuiteNode::Local::PARAMETER || local.type == GDScriptParser::SuiteNode::Local::FOR_VARIABLE) {// Parameters are added directly from function and loop variables are declared explicitly.continue;}- addresses.push_back(codegen.add_local(p_block->locals[i].name, _gdtype_from_datatype(p_block->locals[i].get_datatype(), codegen.script)));+ addresses.push_back(codegen.add_local(local.name, _gdtype_from_datatype(local.get_datatype(), codegen.script)));}return addresses;}@@ -1900,9 +1899,7 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Suiblock_locals = _add_block_locals(codegen, p_block);}- for (int i = 0; i < p_block->statements.size(); i++) {- const GDScriptParser::Node *s = p_block->statements[i];-+ for (const GDScriptParser::Node *s : p_block->statements) {gen->write_newline(s->start_line);switch (s->type) {@@ -1938,7 +1935,7 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui// Now we can actually start testing.// For each branch.- for (int j = 0; j < match->branches.size(); j++) {+ for (uint32_t j = 0; j < match->branches.size(); j++) {if (j > 0) {// Use `else` to not check the next branch after matching.gen->write_else();@@ -1955,7 +1952,7 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui// For each pattern in branch.GDScriptCodeGenerator::Address pattern_result = codegen.add_temporary();- for (int k = 0; k < branch->patterns.size(); k++) {+ for (uint32_t k = 0; k < branch->patterns.size(); k++) {pattern_result = _parse_match_pattern(codegen, err, branch->patterns[k], value, type, pattern_result, k == 0, false);if (err != OK) {return err;@@ -2000,7 +1997,7 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui}// End all nested `if`s.- for (int j = 0; j < match->branches.size(); j++) {+ for (uint32_t j = 0; j < match->branches.size(); j++) {gen->write_endif();}@@ -2339,8 +2336,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_GDScriptCodeGenerator::Address vararg_addr;if (p_func) {- for (int i = 0; i < p_func->parameters.size(); i++) {- const GDScriptParser::ParameterNode *parameter = p_func->parameters[i];+ for (const GDScriptParser::ParameterNode *parameter : p_func->parameters) {GDScriptDataType par_type = _gdtype_from_datatype(parameter->type_constraint, p_script);uint32_t par_addr = codegen.generator->add_parameter(parameter->identifier->name, parameter->initializer != nullptr, par_type);codegen.parameters[parameter->identifier->name] = GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::FUNCTION_PARAMETER, par_addr, par_type);@@ -2400,11 +2396,11 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_if (!p_for_lambda && (is_implicit_initializer || is_implicit_ready)) {// Initialize class fields.- for (int i = 0; i < p_class->members.size(); i++) {- if (p_class->members[i].type != GDScriptParser::ClassNode::Member::VARIABLE) {+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {+ if (member.type != GDScriptParser::ClassNode::Member::VARIABLE) {continue;}- const GDScriptParser::VariableNode *field = p_class->members[i].variable;+ const GDScriptParser::VariableNode *field = member.variable;if (field->is_static) {continue;}@@ -2442,7 +2438,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_if (p_func) {if (optional_parameters > 0) {codegen.generator->start_parameters();- for (int i = p_func->parameters.size() - optional_parameters; i < p_func->parameters.size(); i++) {+ for (uint32_t i = p_func->parameters.size() - optional_parameters; i < p_func->parameters.size(); i++) {const GDScriptParser::ParameterNode *parameter = p_func->parameters[i];GDScriptCodeGenerator::Address src_addr = _parse_expression(codegen, r_error, parameter->initializer);if (r_error) {@@ -2593,12 +2589,12 @@ GDScriptFunction *GDScriptCompiler::_make_static_initializer(Error &r_error, GDS}}- for (int i = 0; i < p_class->members.size(); i++) {+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {// Initialize static fields.- if (p_class->members[i].type != GDScriptParser::ClassNode::Member::VARIABLE) {+ if (member.type != GDScriptParser::ClassNode::Member::VARIABLE) {continue;}- const GDScriptParser::VariableNode *field = p_class->members[i].variable;+ const GDScriptParser::VariableNode *field = member.variable;if (!field->is_static) {continue;}@@ -2822,8 +2818,7 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptPp_script->rpc_config = p_script->base->rpc_config.duplicate();}- for (int i = 0; i < p_class->members.size(); i++) {- const GDScriptParser::ClassNode::Member &member = p_class->members[i];+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {switch (member.type) {case GDScriptParser::ClassNode::Member::VARIABLE: {const GDScriptParser::VariableNode *variable = member.variable;@@ -2976,8 +2971,7 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptPparsing_classes.erase(p_script);// Populate inner classes.- for (int i = 0; i < p_class->members.size(); i++) {- const GDScriptParser::ClassNode::Member &member = p_class->members[i];+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {if (member.type != member.CLASS) {continue;}@@ -2999,8 +2993,7 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptPError GDScriptCompiler::_compile_class(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {// Compile member functions, getters, and setters.- for (int i = 0; i < p_class->members.size(); i++) {- const GDScriptParser::ClassNode::Member &member = p_class->members[i];+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {if (member.type == member.FUNCTION) {const GDScriptParser::FunctionNode *function = member.function;Error err = OK;@@ -3061,11 +3054,11 @@ Error GDScriptCompiler::_compile_class(GDScript *p_script, const GDScriptParser:has_static_data = p_class->has_static_data;- for (int i = 0; i < p_class->members.size(); i++) {- if (p_class->members[i].type != GDScriptParser::ClassNode::Member::CLASS) {+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {+ if (member.type != GDScriptParser::ClassNode::Member::CLASS) {continue;}- const GDScriptParser::ClassNode *inner_class = p_class->members[i].m_class;+ const GDScriptParser::ClassNode *inner_class = member.m_class;StringName name = inner_class->identifier->name;GDScript *subclass = p_script->subclasses[name].ptr();@@ -3108,11 +3101,11 @@ void GDScriptCompiler::make_scripts(GDScript *p_script, const GDScriptParser::Clp_script->subclasses.clear();- for (int i = 0; i < p_class->members.size(); i++) {- if (p_class->members[i].type != GDScriptParser::ClassNode::Member::CLASS) {+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {+ if (member.type != GDScriptParser::ClassNode::Member::CLASS) {continue;}- const GDScriptParser::ClassNode *inner_class = p_class->members[i].m_class;+ const GDScriptParser::ClassNode *inner_class = member.m_class;StringName name = inner_class->identifier->name;Ref<GDScript> subclass;diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cppindex cf2c49846a3..24ecba0f57c 100644--- a/modules/gdscript/gdscript_editor.cpp+++ b/modules/gdscript/gdscript_editor.cpp@@ -155,13 +155,13 @@ Vector<ScriptLanguage::ScriptTemplate> GDScriptLanguage::get_built_in_templates(}static void get_function_names_recursively(const GDScriptParser::ClassNode *p_class, const String &p_prefix, HashMap<int, String> &r_funcs) {- for (int i = 0; i < p_class->members.size(); i++) {- if (p_class->members[i].type == GDScriptParser::ClassNode::Member::FUNCTION) {- const GDScriptParser::FunctionNode *function = p_class->members[i].function;+ for (const GDScriptParser::ClassNode::Member &member : p_class->members) {+ if (member.type == GDScriptParser::ClassNode::Member::FUNCTION) {+ const GDScriptParser::FunctionNode *function = member.function;r_funcs[function->start_line] = p_prefix.is_empty() ? String(function->identifier->name) : p_prefix + "." + String(function->identifier->name);- } else if (p_class->members[i].type == GDScriptParser::ClassNode::Member::CLASS) {- String new_prefix = p_class->members[i].m_class->identifier->name;- get_function_names_recursively(p_class->members[i].m_class, p_prefix.is_empty() ? new_prefix : p_prefix + "." + new_prefix, r_funcs);+ } else if (member.type == GDScriptParser::ClassNode::Member::CLASS) {+ String new_prefix = member.m_class->identifier->name;+ get_function_names_recursively(member.m_class, p_prefix.is_empty() ? new_prefix : p_prefix + "." + new_prefix, r_funcs);}}}@@ -822,7 +822,7 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx, boolreturn arghint;}-static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_function, int p_arg_idx, bool p_just_args = false) {+static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_function, uint32_t p_arg_idx, bool p_just_args = false) {String arghint;if (p_just_args) {@@ -835,7 +835,7 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio}}- for (int i = 0; i < p_function->parameters.size(); i++) {+ for (uint32_t i = 0; i < p_function->parameters.size(); i++) {if (i > 0) {arghint += ", ";}@@ -995,7 +995,7 @@ static void _get_directory_contents(const GDScriptParser::Node *p_current, Edito}}-static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, String &r_arghint) {+static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, uint32_t p_argument, const String p_quote_style, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, String &r_arghint) {ERR_FAIL_NULL(p_annotation);const GDScriptParser::Node *existing_argument = p_annotation->arguments.size() > p_argument ? p_annotation->arguments[p_argument] : nullptr;@@ -1160,8 +1160,7 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completioconst GDScriptParser::ClassNode *current = p_context.current_class;int location_offset = 0;while (current) {- for (int i = 0; i < current->members.size(); i++) {- const GDScriptParser::ClassNode::Member &member = current->members[i];+ for (const GDScriptParser::ClassNode::Member &member : current->members) {switch (member.type) {case GDScriptParser::ClassNode::Member::CLASS: {ScriptLanguage::CodeCompletionOption option(member.m_class->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS, ScriptLanguage::LOCATION_LOCAL + location_offset);@@ -1213,14 +1212,14 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio}static void _find_identifiers_in_suite(const GDScriptParser::SuiteNode *p_suite, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth = 0) {- for (int i = 0; i < p_suite->locals.size(); i++) {+ for (const GDScriptParser::SuiteNode::Local &local : p_suite->locals) {ScriptLanguage::CodeCompletionOption option;int location = p_recursion_depth == 0 ? ScriptLanguage::LOCATION_LOCAL : (p_recursion_depth | ScriptLanguage::LOCATION_PARENT_MASK);- if (p_suite->locals[i].type == GDScriptParser::SuiteNode::Local::CONSTANT) {- option = ScriptLanguage::CodeCompletionOption(p_suite->locals[i].name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, location);- option.default_value = p_suite->locals[i].constant->initializer->reduced_value;+ if (local.type == GDScriptParser::SuiteNode::Local::CONSTANT) {+ option = ScriptLanguage::CodeCompletionOption(local.name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, location);+ option.default_value = local.constant->initializer->reduced_value;} else {- option = ScriptLanguage::CodeCompletionOption(p_suite->locals[i].name, ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE, location);+ option = ScriptLanguage::CodeCompletionOption(local.name, ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE, location);}r_result.insert(option.display, option);}@@ -1239,9 +1238,8 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,const GDScriptParser::ClassNode *clss = p_class;int classes_processed = 0;while (clss) {- for (int i = 0; i < clss->members.size(); i++) {+ for (const GDScriptParser::ClassNode::Member &member : clss->members) {const int location = p_recursion_depth == 0 ? classes_processed : (p_recursion_depth | ScriptLanguage::LOCATION_PARENT_MASK);- const GDScriptParser::ClassNode::Member &member = clss->members[i];ScriptLanguage::CodeCompletionOption option;switch (member.type) {case GDScriptParser::ClassNode::Member::VARIABLE:@@ -2000,15 +1998,15 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,const GDScriptParser::DictionaryNode *dn = static_cast<const GDScriptParser::DictionaryNode *>(p_expression);Dictionary d;bool full = true;- for (int i = 0; i < dn->elements.size(); i++) {+ for (const GDScriptParser::DictionaryNode::Pair &element : dn->elements) {GDScriptCompletionIdentifier key;- if (_guess_expression_type(p_context, dn->elements[i].key, key)) {+ if (_guess_expression_type(p_context, element.key, key)) {if (!key.type.is_constant) {full = false;break;}GDScriptCompletionIdentifier value;- if (_guess_expression_type(p_context, dn->elements[i].value, value)) {+ if (_guess_expression_type(p_context, element.value, value)) {if (!value.type.is_constant) {full = false;break;@@ -2038,7 +2036,7 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,Array a;bool full = true;a.resize(an->elements.size());- for (int i = 0; i < an->elements.size(); i++) {+ for (uint32_t i = 0; i < an->elements.size(); i++) {GDScriptCompletionIdentifier value;if (_guess_expression_type(p_context, an->elements[i], value)) {if (value.type.is_constant) {@@ -2163,14 +2161,14 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,}if (dn) {- for (int i = 0; i < dn->elements.size(); i++) {+ for (const GDScriptParser::DictionaryNode::Pair &element : dn->elements) {GDScriptCompletionIdentifier key;- if (!_guess_expression_type(c, dn->elements[i].key, key)) {+ if (!_guess_expression_type(c, element.key, key)) {continue;}if (key.value == String(subscript->attribute->name)) {- r_type.assigned_expression = dn->elements[i].value;- found = _guess_expression_type(c, dn->elements[i].value, r_type);+ r_type.assigned_expression = element.value;+ found = _guess_expression_type(c, element.value, r_type);break;}}@@ -2228,14 +2226,14 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,}if (dn) {- for (int i = 0; i < dn->elements.size(); i++) {+ for (const GDScriptParser::DictionaryNode::Pair &element : dn->elements) {GDScriptCompletionIdentifier key;- if (!_guess_expression_type(c, dn->elements[i].key, key)) {+ if (!_guess_expression_type(c, element.key, key)) {continue;}if (key.value == index.value) {- r_type.assigned_expression = dn->elements[i].value;- found = _guess_expression_type(p_context, dn->elements[i].value, r_type);+ r_type.assigned_expression = element.value;+ found = _guess_expression_type(p_context, element.value, r_type);break;}}@@ -2251,7 +2249,7 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,an = static_cast<const GDScriptParser::ArrayNode *>(base.assigned_expression);}- if (an && idx >= 0 && an->elements.size() > idx) {+ if (an && idx >= 0 && an->elements.size() > (uint32_t)idx) {r_type.assigned_expression = an->elements[idx];found = _guess_expression_type(c, an->elements[idx], r_type);break;@@ -2441,14 +2439,14 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context,}while (suite) {- for (int i = 0; i < suite->statements.size(); i++) {- if (suite->statements[i]->end_line >= p_context.current_line) {+ for (const GDScriptParser::Node *stmt : suite->statements) {+ if (stmt->end_line >= p_context.current_line) {break;}- switch (suite->statements[i]->type) {+ switch (stmt->type) {case GDScriptParser::Node::ASSIGNMENT: {- const GDScriptParser::AssignmentNode *assign = static_cast<const GDScriptParser::AssignmentNode *>(suite->statements[i]);+ const GDScriptParser::AssignmentNode *assign = static_cast<const GDScriptParser::AssignmentNode *>(stmt);if (assign->end_line > last_assign_line && assign->assignee && assign->assigned_value && assign->assignee->type == GDScriptParser::Node::IDENTIFIER) {const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(assign->assignee);if (id->name == p_identifier->name && id->source == p_identifier->source) {@@ -2813,23 +2811,23 @@ static void _find_last_return_in_block(GDScriptParser::CompletionContext &p_contreturn;}- for (int i = 0; i < p_context.current_suite->statements.size(); i++) {- if (p_context.current_suite->statements[i]->start_line < r_last_return_line) {+ for (const GDScriptParser::Node *stmt : p_context.current_suite->statements) {+ if (stmt->start_line < r_last_return_line) {break;}GDScriptParser::CompletionContext c = p_context;- switch (p_context.current_suite->statements[i]->type) {+ switch (stmt->type) {case GDScriptParser::Node::FOR:- c.current_suite = static_cast<const GDScriptParser::ForNode *>(p_context.current_suite->statements[i])->loop;+ c.current_suite = static_cast<const GDScriptParser::ForNode *>(stmt)->loop;_find_last_return_in_block(c, r_last_return_line, r_last_returned_value);break;case GDScriptParser::Node::WHILE:- c.current_suite = static_cast<const GDScriptParser::WhileNode *>(p_context.current_suite->statements[i])->loop;+ c.current_suite = static_cast<const GDScriptParser::WhileNode *>(stmt)->loop;_find_last_return_in_block(c, r_last_return_line, r_last_returned_value);break;case GDScriptParser::Node::IF: {- const GDScriptParser::IfNode *_if = static_cast<const GDScriptParser::IfNode *>(p_context.current_suite->statements[i]);+ const GDScriptParser::IfNode *_if = static_cast<const GDScriptParser::IfNode *>(stmt);c.current_suite = _if->true_block;_find_last_return_in_block(c, r_last_return_line, r_last_returned_value);if (_if->false_block) {@@ -2838,14 +2836,14 @@ static void _find_last_return_in_block(GDScriptParser::CompletionContext &p_cont}} break;case GDScriptParser::Node::MATCH: {- const GDScriptParser::MatchNode *match = static_cast<const GDScriptParser::MatchNode *>(p_context.current_suite->statements[i]);- for (int j = 0; j < match->branches.size(); j++) {- c.current_suite = match->branches[j]->block;+ const GDScriptParser::MatchNode *match = static_cast<const GDScriptParser::MatchNode *>(stmt);+ for (const GDScriptParser::MatchBranchNode *branch : match->branches) {+ c.current_suite = branch->block;_find_last_return_in_block(c, r_last_return_line, r_last_returned_value);}} break;case GDScriptParser::Node::RETURN: {- const GDScriptParser::ReturnNode *ret = static_cast<const GDScriptParser::ReturnNode *>(p_context.current_suite->statements[i]);+ const GDScriptParser::ReturnNode *ret = static_cast<const GDScriptParser::ReturnNode *>(stmt);if (ret->return_value) {if (ret->start_line > r_last_return_line) {r_last_return_line = ret->start_line;@@ -2989,8 +2987,8 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_coStringName current_enum = p_enum_hint;if (p_context.current_class && p_context.current_class->has_member(current_enum) && p_context.current_class->get_member(current_enum).type == GDScriptParser::ClassNode::Member::ENUM) {const GDScriptParser::EnumNode *_enum = p_context.current_class->get_member(current_enum).m_enum;- for (int i = 0; i < _enum->values.size(); i++) {- ScriptLanguage::CodeCompletionOption option(_enum->values[i].identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_ENUM);+ for (const GDScriptParser::EnumNode::Value &value : _enum->values) {+ ScriptLanguage::CodeCompletionOption option(value.identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_ENUM);r_result.insert(option.display, option);}} else {@@ -3020,7 +3018,7 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_co}}-static void _list_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptCompletionIdentifier &p_base, const GDScriptParser::CallNode *p_call, int p_argidx, bool p_static, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, String &r_arghint) {+static void _list_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptCompletionIdentifier &p_base, const GDScriptParser::CallNode *p_call, uint32_t p_argidx, bool p_static, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, String &r_arghint) {Variant base = p_base.value;GDScriptParser::DataType base_type = p_base.type;const StringName &method = p_call->function_name;@@ -3082,7 +3080,7 @@ static void _list_call_arguments(GDScriptParser::CompletionContext &p_context, c}MethodInfo info;- int method_args = 0;+ uint32_t method_args = 0;if (ClassDB::get_method_info(class_name, method, &info)) {method_args = info.arguments.size();@@ -3562,8 +3560,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, cif (!completion_context.current_class) {break;}- for (int i = 0; i < completion_context.current_class->members.size(); i++) {- const GDScriptParser::ClassNode::Member &member = completion_context.current_class->members[i];+ for (const GDScriptParser::ClassNode::Member &member : completion_context.current_class->members) {if (member.type != GDScriptParser::ClassNode::Member::FUNCTION) {continue;}@@ -3662,7 +3659,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c}const GDScriptParser::TypeNode *type = static_cast<const GDScriptParser::TypeNode *>(completion_context.node);- ERR_FAIL_INDEX_V_MSG(completion_context.type_chain_index - 1, type->type_chain.size(), Error::ERR_BUG, "Could not complete type argument with out of bounds type chain index.");+ ERR_FAIL_INDEX_V_MSG(completion_context.type_chain_index - 1, (int)type->type_chain.size(), Error::ERR_BUG, "Could not complete type argument with out of bounds type chain index.");GDScriptCompletionIdentifier base;@@ -3687,7 +3684,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, cGDScriptParser::Node *existing = nullptr;if (completion_context.node && completion_context.node->type == GDScriptParser::Node::CALL && completion_context.current_argument >= 0) {const GDScriptParser::CallNode *call = static_cast<GDScriptParser::CallNode *>(completion_context.node);- existing = call->arguments.size() > completion_context.current_argument ? call->arguments[completion_context.current_argument] : nullptr;+ existing = call->arguments.size() > (uint32_t)completion_context.current_argument ? call->arguments[completion_context.current_argument] : nullptr;} else if (completion_context.node && completion_context.node->type == GDScriptParser::Node::PRELOAD) {const GDScriptParser::PreloadNode *preload = static_cast<GDScriptParser::PreloadNode *>(completion_context.node);existing = preload->path;diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cppindex 59473db96f9..5836323b019 100644--- a/modules/gdscript/gdscript_parser.cpp+++ b/modules/gdscript/gdscript_parser.cpp@@ -1681,7 +1681,7 @@ GDScriptParser::EnumNode *GDScriptParser::parse_enum(bool p_is_static) {#ifdef TOOLS_ENABLED// Enum values documentation.- for (int i = 0; i < enum_node->values.size(); i++) {+ for (uint32_t i = 0; i < enum_node->values.size(); i++) {int enum_value_line = enum_node->values[i].line;int doc_comment_line = enum_value_line - 1;@@ -1697,7 +1697,7 @@ GDScriptParser::EnumNode *GDScriptParser::parse_enum(bool p_is_static) {}if (named) {- enum_node->values.write[i].doc_data = doc_data;+ enum_node->values[i].doc_data = doc_data;} else {current_class->set_enum_value_doc_data(enum_node->values[i].identifier->name, doc_data);}@@ -2568,7 +2568,7 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() {if (guard == nullptr) {push_error(R"(Expected expression for pattern guard after "when".)");} else {- branch->guard_body->statements.append(guard);+ branch->guard_body->statements.push_back(guard);}current_suite = parent_block;complete_extents(branch->guard_body);@@ -3906,7 +3906,7 @@ GDScriptParser::TypeNode *GDScriptParser::parse_type(bool p_allow_void) {} else if (container_type->container_types.size() > 0) {push_error("Nested typed collections are not supported.");} else {- type->container_types.append(container_type);+ type->container_types.push_back(container_type);}first_pass = false;} while (match(GDScriptTokenizer::Token::COMMA));@@ -4218,7 +4218,7 @@ GDScriptParser::ClassDocData GDScriptParser::parse_class_doc_comment(int p_line,link = stripped_line.substr(colon_pos).strip_edges();}- result.tutorials.append(Pair<String, String>(title, link));+ result.tutorials.push_back(Pair<String, String>(title, link));continue;} else if (stripped_line == "@deprecated" || stripped_line.begins_with("@deprecated:")) {result.is_deprecated = true;@@ -4423,7 +4423,7 @@ bool GDScriptParser::validate_annotation_arguments(AnnotationNode *p_annotation)// Some annotations need to be resolved and applied in the parser.if (p_annotation->name == SNAME("@icon") || p_annotation->name == SNAME("@warning_ignore_start") || p_annotation->name == SNAME("@warning_ignore_restore")) {- for (int i = 0; i < p_annotation->arguments.size(); i++) {+ for (uint32_t i = 0; i < p_annotation->arguments.size(); i++) {ExpressionNode *argument = p_annotation->arguments[i];if (argument->type != Node::LITERAL) {@@ -4680,7 +4680,7 @@ bool GDScriptParser::export_annotations(AnnotationNode *p_annotation, Node *p_tavariable->export_info.hint = t_hint;String hint_string;- for (int i = 0; i < p_annotation->resolved_arguments.size(); i++) {+ for (uint32_t i = 0; i < p_annotation->resolved_arguments.size(); i++) {String arg_string = String(p_annotation->resolved_arguments[i]);if (p_annotation->name != SNAME("@export_placeholder")) {@@ -5170,10 +5170,10 @@ bool GDScriptParser::warning_ignore_annotation(AnnotationNode *p_annotation, Nodcase Node::FUNCTION: {FunctionNode *function = static_cast<FunctionNode *>(p_target);end_line = function->start_line;- for (int i = 0; i < function->parameters.size(); i++) {- end_line = MAX(end_line, function->parameters[i]->end_line);- if (function->parameters[i]->initializer != nullptr) {- end_line = MAX(end_line, function->parameters[i]->initializer->end_line);+ for (const ParameterNode *param : function->parameters) {+ end_line = MAX(end_line, param->end_line);+ if (param->initializer != nullptr) {+ end_line = MAX(end_line, param->initializer->end_line);}}} break;@@ -5181,8 +5181,8 @@ bool GDScriptParser::warning_ignore_annotation(AnnotationNode *p_annotation, Nodcase Node::MATCH_BRANCH: {MatchBranchNode *branch = static_cast<MatchBranchNode *>(p_target);end_line = branch->start_line;- for (int i = 0; i < branch->patterns.size(); i++) {- end_line = MAX(end_line, branch->patterns[i]->end_line);+ for (const PatternNode *pattern : branch->patterns) {+ end_line = MAX(end_line, pattern->end_line);}} break;@@ -5259,7 +5259,7 @@ bool GDScriptParser::rpc_annotation(AnnotationNode *p_annotation, Node *p_targetunsigned char permission_args = 0;unsigned char transfer_mode_args = 0;- for (int i = 0; i < p_annotation->resolved_arguments.size(); i++) {+ for (uint32_t i = 0; i < p_annotation->resolved_arguments.size(); i++) {if (i == 3) {rpc_config["channel"] = p_annotation->resolved_arguments[i].operator int();continue;@@ -5660,7 +5660,7 @@ void GDScriptParser::TreePrinter::push_text(const String &p_text) {void GDScriptParser::TreePrinter::print_annotation(const AnnotationNode *p_annotation) {push_text(p_annotation->name);push_text(" (");- for (int i = 0; i < p_annotation->arguments.size(); i++) {+ for (uint32_t i = 0; i < p_annotation->arguments.size(); i++) {if (i > 0) {push_text(" , ");}@@ -5669,9 +5669,9 @@ void GDScriptParser::TreePrinter::print_annotation(const AnnotationNode *p_annotpush_line(")");}-void GDScriptParser::TreePrinter::print_array(ArrayNode *p_array) {+void GDScriptParser::TreePrinter::print_array(const ArrayNode *p_array) {push_text("[ ");- for (int i = 0; i < p_array->elements.size(); i++) {+ for (uint32_t i = 0; i < p_array->elements.size(); i++) {if (i > 0) {push_text(" , ");}@@ -5680,13 +5680,13 @@ void GDScriptParser::TreePrinter::print_array(ArrayNode *p_array) {push_text(" ]");}-void GDScriptParser::TreePrinter::print_assert(AssertNode *p_assert) {+void GDScriptParser::TreePrinter::print_assert(const AssertNode *p_assert) {push_text("Assert ( ");print_expression(p_assert->condition);push_line(" )");}-void GDScriptParser::TreePrinter::print_assignment(AssignmentNode *p_assignment) {+void GDScriptParser::TreePrinter::print_assignment(const AssignmentNode *p_assignment) {switch (p_assignment->assignee->type) {case Node::IDENTIFIER:print_identifier(static_cast<IdentifierNode *>(p_assignment->assignee));@@ -5741,12 +5741,12 @@ void GDScriptParser::TreePrinter::print_assignment(AssignmentNode *p_assignment)push_line();}-void GDScriptParser::TreePrinter::print_await(AwaitNode *p_await) {+void GDScriptParser::TreePrinter::print_await(const AwaitNode *p_await) {push_text("Await ");print_expression(p_await->to_await);}-void GDScriptParser::TreePrinter::print_binary_op(BinaryOpNode *p_binary_op) {+void GDScriptParser::TreePrinter::print_binary_op(const BinaryOpNode *p_binary_op) {// Surround in parenthesis for disambiguation.push_text("(");print_expression(p_binary_op->left_operand);@@ -5817,7 +5817,7 @@ void GDScriptParser::TreePrinter::print_binary_op(BinaryOpNode *p_binary_op) {push_text(")");}-void GDScriptParser::TreePrinter::print_call(CallNode *p_call) {+void GDScriptParser::TreePrinter::print_call(const CallNode *p_call) {if (p_call->is_super) {push_text("super");if (p_call->callee != nullptr) {@@ -5828,7 +5828,7 @@ void GDScriptParser::TreePrinter::print_call(CallNode *p_call) {print_expression(p_call->callee);}push_text("( ");- for (int i = 0; i < p_call->arguments.size(); i++) {+ for (uint32_t i = 0; i < p_call->arguments.size(); i++) {if (i > 0) {push_text(" , ");}@@ -5837,13 +5837,13 @@ void GDScriptParser::TreePrinter::print_call(CallNode *p_call) {push_text(" )");}-void GDScriptParser::TreePrinter::print_cast(CastNode *p_cast) {+void GDScriptParser::TreePrinter::print_cast(const CastNode *p_cast) {print_expression(p_cast->operand);push_text(" AS ");print_type(p_cast->cast_type);}-void GDScriptParser::TreePrinter::print_class(ClassNode *p_class) {+void GDScriptParser::TreePrinter::print_class(const ClassNode *p_class) {for (const AnnotationNode *E : p_class->annotations) {print_annotation(E);}@@ -5875,9 +5875,7 @@ void GDScriptParser::TreePrinter::print_class(ClassNode *p_class) {increase_indent();- for (int i = 0; i < p_class->members.size(); i++) {- const ClassNode::Member &m = p_class->members[i];-+ for (const ClassNode::Member &m : p_class->members) {switch (m.type) {case ClassNode::Member::CLASS:print_class(m.m_class);@@ -5910,7 +5908,7 @@ void GDScriptParser::TreePrinter::print_class(ClassNode *p_class) {decrease_indent();}-void GDScriptParser::TreePrinter::print_constant(ConstantNode *p_constant) {+void GDScriptParser::TreePrinter::print_constant(const ConstantNode *p_constant) {push_text("Constant ");print_identifier(p_constant->identifier);@@ -5927,79 +5925,79 @@ void GDScriptParser::TreePrinter::print_constant(ConstantNode *p_constant) {push_line();}-void GDScriptParser::TreePrinter::print_dictionary(DictionaryNode *p_dictionary) {+void GDScriptParser::TreePrinter::print_dictionary(const DictionaryNode *p_dictionary) {push_line("{");increase_indent();- for (int i = 0; i < p_dictionary->elements.size(); i++) {- print_expression(p_dictionary->elements[i].key);+ for (const DictionaryNode::Pair &element : p_dictionary->elements) {+ print_expression(element.key);if (p_dictionary->style == DictionaryNode::PYTHON_DICT) {push_text(" : ");} else {push_text(" = ");}- print_expression(p_dictionary->elements[i].value);+ print_expression(element.value);push_line(" ,");}decrease_indent();push_text("}");}-void GDScriptParser::TreePrinter::print_expression(ExpressionNode *p_expression) {+void GDScriptParser::TreePrinter::print_expression(const ExpressionNode *p_expression) {if (p_expression == nullptr) {push_text("<invalid expression>");return;}switch (p_expression->type) {case Node::ARRAY:- print_array(static_cast<ArrayNode *>(p_expression));+ print_array(static_cast<const ArrayNode *>(p_expression));break;case Node::ASSIGNMENT:- print_assignment(static_cast<AssignmentNode *>(p_expression));+ print_assignment(static_cast<const AssignmentNode *>(p_expression));break;case Node::AWAIT:- print_await(static_cast<AwaitNode *>(p_expression));+ print_await(static_cast<const AwaitNode *>(p_expression));break;case Node::BINARY_OPERATOR:- print_binary_op(static_cast<BinaryOpNode *>(p_expression));+ print_binary_op(static_cast<const BinaryOpNode *>(p_expression));break;case Node::CALL:- print_call(static_cast<CallNode *>(p_expression));+ print_call(static_cast<const CallNode *>(p_expression));break;case Node::CAST:- print_cast(static_cast<CastNode *>(p_expression));+ print_cast(static_cast<const CastNode *>(p_expression));break;case Node::DICTIONARY:- print_dictionary(static_cast<DictionaryNode *>(p_expression));+ print_dictionary(static_cast<const DictionaryNode *>(p_expression));break;case Node::GET_NODE:- print_get_node(static_cast<GetNodeNode *>(p_expression));+ print_get_node(static_cast<const GetNodeNode *>(p_expression));break;case Node::IDENTIFIER:- print_identifier(static_cast<IdentifierNode *>(p_expression));+ print_identifier(static_cast<const IdentifierNode *>(p_expression));break;case Node::LAMBDA:- print_lambda(static_cast<LambdaNode *>(p_expression));+ print_lambda(static_cast<const LambdaNode *>(p_expression));break;case Node::LITERAL:- print_literal(static_cast<LiteralNode *>(p_expression));+ print_literal(static_cast<const LiteralNode *>(p_expression));break;case Node::PRELOAD:- print_preload(static_cast<PreloadNode *>(p_expression));+ print_preload(static_cast<const PreloadNode *>(p_expression));break;case Node::SELF:- print_self(static_cast<SelfNode *>(p_expression));+ print_self(static_cast<const SelfNode *>(p_expression));break;case Node::SUBSCRIPT:- print_subscript(static_cast<SubscriptNode *>(p_expression));+ print_subscript(static_cast<const SubscriptNode *>(p_expression));break;case Node::TERNARY_OPERATOR:- print_ternary_op(static_cast<TernaryOpNode *>(p_expression));+ print_ternary_op(static_cast<const TernaryOpNode *>(p_expression));break;case Node::TYPE_TEST:- print_type_test(static_cast<TypeTestNode *>(p_expression));+ print_type_test(static_cast<const TypeTestNode *>(p_expression));break;case Node::UNARY_OPERATOR:- print_unary_op(static_cast<UnaryOpNode *>(p_expression));+ print_unary_op(static_cast<const UnaryOpNode *>(p_expression));break;default:push_text(vformat("<unknown expression %d>", p_expression->type));@@ -6007,7 +6005,7 @@ void GDScriptParser::TreePrinter::print_expression(ExpressionNode *p_expression)}}-void GDScriptParser::TreePrinter::print_enum(EnumNode *p_enum) {+void GDScriptParser::TreePrinter::print_enum(const EnumNode *p_enum) {push_text("Enum ");if (p_enum->identifier != nullptr) {print_identifier(p_enum->identifier);@@ -6017,8 +6015,7 @@ void GDScriptParser::TreePrinter::print_enum(EnumNode *p_enum) {push_line(" {");increase_indent();- for (int i = 0; i < p_enum->values.size(); i++) {- const EnumNode::Value &item = p_enum->values[i];+ for (const EnumNode::Value &item : p_enum->values) {print_identifier(item.identifier);push_text(" = ");push_text(itos(item.value));@@ -6028,7 +6025,7 @@ void GDScriptParser::TreePrinter::print_enum(EnumNode *p_enum) {push_line("}");}-void GDScriptParser::TreePrinter::print_for(ForNode *p_for) {+void GDScriptParser::TreePrinter::print_for(const ForNode *p_for) {push_text("For ");print_identifier(p_for->variable);push_text(" IN ");@@ -6042,7 +6039,7 @@ void GDScriptParser::TreePrinter::print_for(ForNode *p_for) {decrease_indent();}-void GDScriptParser::TreePrinter::print_function(FunctionNode *p_function, const String &p_context) {+void GDScriptParser::TreePrinter::print_function(const FunctionNode *p_function, const String &p_context) {for (const AnnotationNode *E : p_function->annotations) {print_annotation(E);}@@ -6057,7 +6054,7 @@ void GDScriptParser::TreePrinter::print_function(FunctionNode *p_function, constpush_text("<anonymous>");}push_text("( ");- for (int i = 0; i < p_function->parameters.size(); i++) {+ for (uint32_t i = 0; i < p_function->parameters.size(); i++) {if (i > 0) {push_text(" , ");}@@ -6069,14 +6066,14 @@ void GDScriptParser::TreePrinter::print_function(FunctionNode *p_function, constdecrease_indent();}-void GDScriptParser::TreePrinter::print_get_node(GetNodeNode *p_get_node) {+void GDScriptParser::TreePrinter::print_get_node(const GetNodeNode *p_get_node) {if (p_get_node->use_dollar) {push_text("$");}push_text(p_get_node->full_path);}-void GDScriptParser::TreePrinter::print_identifier(IdentifierNode *p_identifier) {+void GDScriptParser::TreePrinter::print_identifier(const IdentifierNode *p_identifier) {if (p_identifier != nullptr) {push_text(p_identifier->name);} else {@@ -6084,7 +6081,7 @@ void GDScriptParser::TreePrinter::print_identifier(IdentifierNode *p_identifier)}}-void GDScriptParser::TreePrinter::print_if(IfNode *p_if, bool p_is_elif) {+void GDScriptParser::TreePrinter::print_if(const IfNode *p_if, bool p_is_elif) {if (p_is_elif) {push_text("Elif ");} else {@@ -6106,10 +6103,10 @@ void GDScriptParser::TreePrinter::print_if(IfNode *p_if, bool p_is_elif) {}}-void GDScriptParser::TreePrinter::print_lambda(LambdaNode *p_lambda) {+void GDScriptParser::TreePrinter::print_lambda(const LambdaNode *p_lambda) {print_function(p_lambda->function, "Lambda");push_text("| captures [ ");- for (int i = 0; i < p_lambda->captures.size(); i++) {+ for (uint32_t i = 0; i < p_lambda->captures.size(); i++) {if (i > 0) {push_text(" , ");}@@ -6118,7 +6115,7 @@ void GDScriptParser::TreePrinter::print_lambda(LambdaNode *p_lambda) {push_line(" ]");}-void GDScriptParser::TreePrinter::print_literal(LiteralNode *p_literal) {+void GDScriptParser::TreePrinter::print_literal(const LiteralNode *p_literal) {// Prefix for string types.switch (p_literal->value.get_type()) {case Variant::NODE_PATH:@@ -6146,20 +6143,20 @@ void GDScriptParser::TreePrinter::print_literal(LiteralNode *p_literal) {}}-void GDScriptParser::TreePrinter::print_match(MatchNode *p_match) {+void GDScriptParser::TreePrinter::print_match(const MatchNode *p_match) {push_text("Match ");print_expression(p_match->test);push_line(" :");increase_indent();- for (int i = 0; i < p_match->branches.size(); i++) {- print_match_branch(p_match->branches[i]);+ for (const GDScriptParser::MatchBranchNode *branch : p_match->branches) {+ print_match_branch(branch);}decrease_indent();}-void GDScriptParser::TreePrinter::print_match_branch(MatchBranchNode *p_match_branch) {- for (int i = 0; i < p_match_branch->patterns.size(); i++) {+void GDScriptParser::TreePrinter::print_match_branch(const MatchBranchNode *p_match_branch) {+ for (uint32_t i = 0; i < p_match_branch->patterns.size(); i++) {if (i > 0) {push_text(" , ");}@@ -6173,7 +6170,7 @@ void GDScriptParser::TreePrinter::print_match_branch(MatchBranchNode *p_match_brdecrease_indent();}-void GDScriptParser::TreePrinter::print_match_pattern(PatternNode *p_match_pattern) {+void GDScriptParser::TreePrinter::print_match_pattern(const PatternNode *p_match_pattern) {switch (p_match_pattern->pattern_type) {case PatternNode::PT_LITERAL:print_literal(p_match_pattern->literal);@@ -6193,7 +6190,7 @@ void GDScriptParser::TreePrinter::print_match_pattern(PatternNode *p_match_pattebreak;case PatternNode::PT_ARRAY:push_text("[ ");- for (int i = 0; i < p_match_pattern->array.size(); i++) {+ for (uint32_t i = 0; i < p_match_pattern->array.size(); i++) {if (i > 0) {push_text(" , ");}@@ -6203,7 +6200,7 @@ void GDScriptParser::TreePrinter::print_match_pattern(PatternNode *p_match_pattebreak;case PatternNode::PT_DICTIONARY:push_text("{ ");- for (int i = 0; i < p_match_pattern->dictionary.size(); i++) {+ for (uint32_t i = 0; i < p_match_pattern->dictionary.size(); i++) {if (i > 0) {push_text(" , ");}@@ -6222,7 +6219,7 @@ void GDScriptParser::TreePrinter::print_match_pattern(PatternNode *p_match_patte}}-void GDScriptParser::TreePrinter::print_parameter(ParameterNode *p_parameter) {+void GDScriptParser::TreePrinter::print_parameter(const ParameterNode *p_parameter) {print_identifier(p_parameter->identifier);if (p_parameter->datatype_specifier != nullptr) {push_text(" : ");@@ -6234,13 +6231,13 @@ void GDScriptParser::TreePrinter::print_parameter(ParameterNode *p_parameter) {}}-void GDScriptParser::TreePrinter::print_preload(PreloadNode *p_preload) {+void GDScriptParser::TreePrinter::print_preload(const PreloadNode *p_preload) {push_text(R"(Preload ( ")");push_text(p_preload->resolved_path);push_text(R"(" )");}-void GDScriptParser::TreePrinter::print_return(ReturnNode *p_return) {+void GDScriptParser::TreePrinter::print_return(const ReturnNode *p_return) {push_text("Return");if (p_return->return_value != nullptr) {push_text(" ");@@ -6249,7 +6246,7 @@ void GDScriptParser::TreePrinter::print_return(ReturnNode *p_return) {push_line();}-void GDScriptParser::TreePrinter::print_self(SelfNode *p_self) {+void GDScriptParser::TreePrinter::print_self(const SelfNode *p_self) {push_text("Self(");if (p_self->current_class->identifier != nullptr) {print_identifier(p_self->current_class->identifier);@@ -6259,17 +6256,17 @@ void GDScriptParser::TreePrinter::print_self(SelfNode *p_self) {push_text(")");}-void GDScriptParser::TreePrinter::print_signal(SignalNode *p_signal) {+void GDScriptParser::TreePrinter::print_signal(const SignalNode *p_signal) {push_text("Signal ");print_identifier(p_signal->identifier);push_text("( ");- for (int i = 0; i < p_signal->parameters.size(); i++) {- print_parameter(p_signal->parameters[i]);+ for (const ParameterNode *param : p_signal->parameters) {+ print_parameter(param);}push_line(" )");}-void GDScriptParser::TreePrinter::print_subscript(SubscriptNode *p_subscript) {+void GDScriptParser::TreePrinter::print_subscript(const SubscriptNode *p_subscript) {print_expression(p_subscript->base);if (p_subscript->is_attribute) {push_text(".");@@ -6281,31 +6278,31 @@ void GDScriptParser::TreePrinter::print_subscript(SubscriptNode *p_subscript) {}}-void GDScriptParser::TreePrinter::print_statement(Node *p_statement) {+void GDScriptParser::TreePrinter::print_statement(const Node *p_statement) {switch (p_statement->type) {case Node::ASSERT:- print_assert(static_cast<AssertNode *>(p_statement));+ print_assert(static_cast<const AssertNode *>(p_statement));break;case Node::VARIABLE:- print_variable(static_cast<VariableNode *>(p_statement));+ print_variable(static_cast<const VariableNode *>(p_statement));break;case Node::CONSTANT:- print_constant(static_cast<ConstantNode *>(p_statement));+ print_constant(static_cast<const ConstantNode *>(p_statement));break;case Node::IF:- print_if(static_cast<IfNode *>(p_statement));+ print_if(static_cast<const IfNode *>(p_statement));break;case Node::FOR:- print_for(static_cast<ForNode *>(p_statement));+ print_for(static_cast<const ForNode *>(p_statement));break;case Node::WHILE:- print_while(static_cast<WhileNode *>(p_statement));+ print_while(static_cast<const WhileNode *>(p_statement));break;case Node::MATCH:- print_match(static_cast<MatchNode *>(p_statement));+ print_match(static_cast<const MatchNode *>(p_statement));break;case Node::RETURN:- print_return(static_cast<ReturnNode *>(p_statement));+ print_return(static_cast<const ReturnNode *>(p_statement));break;case Node::BREAK:push_line("Break");@@ -6320,11 +6317,11 @@ void GDScriptParser::TreePrinter::print_statement(Node *p_statement) {push_line("Breakpoint");break;case Node::ASSIGNMENT:- print_assignment(static_cast<AssignmentNode *>(p_statement));+ print_assignment(static_cast<const AssignmentNode *>(p_statement));break;default:if (p_statement->is_expression()) {- print_expression(static_cast<ExpressionNode *>(p_statement));+ print_expression(static_cast<const ExpressionNode *>(p_statement));push_line();} else {push_line(vformat("<unknown statement %d>", p_statement->type));@@ -6333,13 +6330,13 @@ void GDScriptParser::TreePrinter::print_statement(Node *p_statement) {}}-void GDScriptParser::TreePrinter::print_suite(SuiteNode *p_suite) {- for (int i = 0; i < p_suite->statements.size(); i++) {- print_statement(p_suite->statements[i]);+void GDScriptParser::TreePrinter::print_suite(const SuiteNode *p_suite) {+ for (const Node *stmt : p_suite->statements) {+ print_statement(stmt);}}-void GDScriptParser::TreePrinter::print_ternary_op(TernaryOpNode *p_ternary_op) {+void GDScriptParser::TreePrinter::print_ternary_op(const TernaryOpNode *p_ternary_op) {// Surround in parenthesis for disambiguation.push_text("(");print_expression(p_ternary_op->true_expr);@@ -6350,11 +6347,11 @@ void GDScriptParser::TreePrinter::print_ternary_op(TernaryOpNode *p_ternary_op)push_text(")");}-void GDScriptParser::TreePrinter::print_type(TypeNode *p_type) {+void GDScriptParser::TreePrinter::print_type(const TypeNode *p_type) {if (p_type->type_chain.is_empty()) {push_text("Void");} else {- for (int i = 0; i < p_type->type_chain.size(); i++) {+ for (uint32_t i = 0; i < p_type->type_chain.size(); i++) {if (i > 0) {push_text(".");}@@ -6363,13 +6360,13 @@ void GDScriptParser::TreePrinter::print_type(TypeNode *p_type) {}}-void GDScriptParser::TreePrinter::print_type_test(TypeTestNode *p_test) {+void GDScriptParser::TreePrinter::print_type_test(const TypeTestNode *p_test) {print_expression(p_test->operand);push_text(" IS ");print_type(p_test->test_type);}-void GDScriptParser::TreePrinter::print_unary_op(UnaryOpNode *p_unary_op) {+void GDScriptParser::TreePrinter::print_unary_op(const UnaryOpNode *p_unary_op) {// Surround in parenthesis for disambiguation.push_text("(");switch (p_unary_op->operation) {@@ -6391,7 +6388,7 @@ void GDScriptParser::TreePrinter::print_unary_op(UnaryOpNode *p_unary_op) {push_text(")");}-void GDScriptParser::TreePrinter::print_variable(VariableNode *p_variable) {+void GDScriptParser::TreePrinter::print_variable(const VariableNode *p_variable) {for (const AnnotationNode *E : p_variable->annotations) {print_annotation(E);}@@ -6464,7 +6461,7 @@ void GDScriptParser::TreePrinter::print_variable(VariableNode *p_variable) {push_line();}-void GDScriptParser::TreePrinter::print_while(WhileNode *p_while) {+void GDScriptParser::TreePrinter::print_while(const WhileNode *p_while) {push_text("While ");print_expression(p_while->condition);push_line(" :");diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.hindex 60a94b32a7d..849550b5208 100644--- a/modules/gdscript/gdscript_parser.h+++ b/modules/gdscript/gdscript_parser.h@@ -281,7 +281,7 @@ public:struct ClassDocData {String brief;String description;- Vector<Pair<String, String>> tutorials;+ LocalVector<Pair<String, String>> tutorials;bool is_deprecated = false;String deprecated_message;bool is_experimental = false;@@ -372,8 +372,8 @@ public:struct AnnotationNode : public Node {StringName name;- Vector<ExpressionNode *> arguments;- Vector<Variant> resolved_arguments;+ LocalVector<ExpressionNode *> arguments;+ LocalVector<Variant> resolved_arguments;/** Information of the annotation. Might be null for unknown annotations. */AnnotationInfo *info = nullptr;@@ -390,7 +390,7 @@ public:};struct ArrayNode : public ExpressionNode {- Vector<ExpressionNode *> elements;+ LocalVector<ExpressionNode *> elements;ArrayNode() {type = ARRAY;@@ -506,7 +506,7 @@ public:struct CallNode : public ExpressionNode {ExpressionNode *callee = nullptr;- Vector<ExpressionNode *> arguments;+ LocalVector<ExpressionNode *> arguments;StringName function_name;bool is_super = false;bool is_static = false;@@ -552,7 +552,7 @@ public:};IdentifierNode *identifier = nullptr;- Vector<Value> values;+ LocalVector<Value> values;Variant dictionary;#ifdef TOOLS_ENABLEDMemberDocData doc_data;@@ -751,8 +751,8 @@ public:IdentifierNode *identifier = nullptr;String icon_path;String simplified_icon_path;- Vector<Member> members;- HashMap<StringName, int> members_indices;+ LocalVector<Member> members;+ HashMap<StringName, uint32_t> members_indices;ClassNode *outer = nullptr;bool extends_used = false;bool onready_used = false;@@ -777,8 +777,8 @@ public:// EnumValue docs are parsed after itself, so we need a method to add/modify the doc property later.void set_enum_value_doc_data(const StringName &p_name, const MemberDocData &p_doc_data) {- ERR_FAIL_INDEX(members_indices[p_name], members.size());- members.write[members_indices[p_name]].enum_value.doc_data = p_doc_data;+ ERR_FAIL_UNSIGNED_INDEX(members_indices[p_name], members.size());+ members[members_indices[p_name]].enum_value.doc_data = p_doc_data;}#endif // TOOLS_ENABLED@@ -840,7 +840,7 @@ public:ExpressionNode *key = nullptr;ExpressionNode *value = nullptr;};- Vector<Pair> elements;+ LocalVector<Pair> elements;enum Style {LUA_TABLE,@@ -867,8 +867,8 @@ public:struct FunctionNode : public Node {IdentifierNode *identifier = nullptr;- Vector<ParameterNode *> parameters;- HashMap<StringName, int> parameters_indices;+ LocalVector<ParameterNode *> parameters;+ HashMap<StringName, uint32_t> parameters_indices;ParameterNode *rest_parameter = nullptr;TypeNode *return_type = nullptr;@@ -881,7 +881,7 @@ public:Variant rpc_config;MethodInfo info;LambdaNode *source_lambda = nullptr;- Vector<Variant> default_arg_values;+ LocalVector<Variant> default_arg_values;int header_end_line = 0;int header_end_column = 0;@@ -965,8 +965,8 @@ public:FunctionNode *function = nullptr;FunctionNode *parent_function = nullptr;LambdaNode *parent_lambda = nullptr;- Vector<IdentifierNode *> captures;- HashMap<StringName, int> captures_indices;+ LocalVector<IdentifierNode *> captures;+ HashMap<StringName, uint32_t> captures_indices;bool use_self = false;bool has_name() const {@@ -988,7 +988,7 @@ public:struct MatchNode : public Node {ExpressionNode *test = nullptr;- Vector<MatchBranchNode *> branches;+ LocalVector<MatchBranchNode *> branches;MatchNode() {type = MATCH;@@ -996,7 +996,7 @@ public:};struct MatchBranchNode : public Node {- Vector<PatternNode *> patterns;+ LocalVector<PatternNode *> patterns;SuiteNode *block = nullptr;bool has_wildcard = false;SuiteNode *guard_body = nullptr;@@ -1037,14 +1037,14 @@ public:IdentifierNode *bind;ExpressionNode *expression;};- Vector<PatternNode *> array;+ LocalVector<PatternNode *> array;bool rest_used = false; // For array/dict patterns.struct Pair {ExpressionNode *key = nullptr;PatternNode *value_pattern = nullptr;};- Vector<Pair> dictionary;+ LocalVector<Pair> dictionary;HashMap<StringName, IdentifierNode *> binds;@@ -1087,8 +1087,8 @@ public:struct SignalNode : public Node {IdentifierNode *identifier = nullptr;- Vector<ParameterNode *> parameters;- HashMap<StringName, int> parameters_indices;+ LocalVector<ParameterNode *> parameters;+ HashMap<StringName, uint32_t> parameters_indices;MethodInfo method_info;#ifdef TOOLS_ENABLEDMemberDocData doc_data;@@ -1121,7 +1121,7 @@ public:DataType suite_type;SuiteNode *parent_block = nullptr;- Vector<Node *> statements;+ LocalVector<Node *> statements;struct Local {enum Type {UNDEFINED,@@ -1196,8 +1196,8 @@ public:}};Local empty;- Vector<Local> locals;- HashMap<StringName, int> locals_indices;+ LocalVector<Local> locals;+ HashMap<StringName, uint32_t> locals_indices;FunctionNode *parent_function = nullptr;IfNode *parent_if = nullptr;@@ -1236,13 +1236,13 @@ public:};struct TypeNode : public Node {- Vector<IdentifierNode *> type_chain;- Vector<TypeNode *> container_types;+ LocalVector<IdentifierNode *> type_chain;+ LocalVector<TypeNode *> container_types;DataType resolved_type;- TypeNode *get_container_type_or_null(int p_index) const {- return p_index >= 0 && p_index < container_types.size() ? container_types[p_index] : nullptr;+ TypeNode *get_container_type_or_null(uint32_t p_index) const {+ return p_index < container_types.size() ? container_types[p_index] : nullptr;}TypeNode() {@@ -1713,42 +1713,42 @@ public:void push_text(const String &p_text);void print_annotation(const AnnotationNode *p_annotation);- void print_array(ArrayNode *p_array);- void print_assert(AssertNode *p_assert);- void print_assignment(AssignmentNode *p_assignment);- void print_await(AwaitNode *p_await);- void print_binary_op(BinaryOpNode *p_binary_op);- void print_call(CallNode *p_call);- void print_cast(CastNode *p_cast);- void print_class(ClassNode *p_class);- void print_constant(ConstantNode *p_constant);- void print_dictionary(DictionaryNode *p_dictionary);- void print_expression(ExpressionNode *p_expression);- void print_enum(EnumNode *p_enum);- void print_for(ForNode *p_for);- void print_function(FunctionNode *p_function, const String &p_context = "Function");- void print_get_node(GetNodeNode *p_get_node);- void print_if(IfNode *p_if, bool p_is_elif = false);- void print_identifier(IdentifierNode *p_identifier);- void print_lambda(LambdaNode *p_lambda);- void print_literal(LiteralNode *p_literal);- void print_match(MatchNode *p_match);- void print_match_branch(MatchBranchNode *p_match_branch);- void print_match_pattern(PatternNode *p_match_pattern);- void print_parameter(ParameterNode *p_parameter);- void print_preload(PreloadNode *p_preload);- void print_return(ReturnNode *p_return);- void print_self(SelfNode *p_self);- void print_signal(SignalNode *p_signal);- void print_statement(Node *p_statement);- void print_subscript(SubscriptNode *p_subscript);- void print_suite(SuiteNode *p_suite);- void print_ternary_op(TernaryOpNode *p_ternary_op);- void print_type(TypeNode *p_type);- void print_type_test(TypeTestNode *p_type_test);- void print_unary_op(UnaryOpNode *p_unary_op);- void print_variable(VariableNode *p_variable);- void print_while(WhileNode *p_while);+ void print_array(const ArrayNode *p_array);+ void print_assert(const AssertNode *p_assert);+ void print_assignment(const AssignmentNode *p_assignment);+ void print_await(const AwaitNode *p_await);+ void print_binary_op(const BinaryOpNode *p_binary_op);+ void print_call(const CallNode *p_call);+ void print_cast(const CastNode *p_cast);+ void print_class(const ClassNode *p_class);+ void print_constant(const ConstantNode *p_constant);+ void print_dictionary(const DictionaryNode *p_dictionary);+ void print_expression(const ExpressionNode *p_expression);+ void print_enum(const EnumNode *p_enum);+ void print_for(const ForNode *p_for);+ void print_function(const FunctionNode *p_function, const String &p_context = "Function");+ void print_get_node(const GetNodeNode *p_get_node);+ void print_if(const IfNode *p_if, bool p_is_elif = false);+ void print_identifier(const IdentifierNode *p_identifier);+ void print_lambda(const LambdaNode *p_lambda);+ void print_literal(const LiteralNode *p_literal);+ void print_match(const MatchNode *p_match);+ void print_match_branch(const MatchBranchNode *p_match_branch);+ void print_match_pattern(const PatternNode *p_match_pattern);+ void print_parameter(const ParameterNode *p_parameter);+ void print_preload(const PreloadNode *p_preload);+ void print_return(const ReturnNode *p_return);+ void print_self(const SelfNode *p_self);+ void print_signal(const SignalNode *p_signal);+ void print_statement(const Node *p_statement);+ void print_subscript(const SubscriptNode *p_subscript);+ void print_suite(const SuiteNode *p_suite);+ void print_ternary_op(const TernaryOpNode *p_ternary_op);+ void print_type(const TypeNode *p_type);+ void print_type_test(const TypeTestNode *p_type_test);+ void print_unary_op(const UnaryOpNode *p_unary_op);+ void print_variable(const VariableNode *p_variable);+ void print_while(const WhileNode *p_while);public:void print_tree(const GDScriptParser &p_parser);diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cppindex 1c32512e988..31ed4d7a83e 100644--- a/modules/gdscript/language_server/gdscript_extend_parser.cpp+++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp@@ -192,9 +192,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *pr_symbol.documentation = doc;}- for (int i = 0; i < p_class->members.size(); i++) {- const ClassNode::Member &m = p_class->members[i];-+ for (const ClassNode::Member &m : p_class->members) {switch (m.type) {case ClassNode::Member::VARIABLE: {LSP::DocumentSymbol symbol;@@ -293,7 +291,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *psymbol.uri = uri;symbol.script_path = path;symbol.detail = "signal " + String(m.signal->identifier->name) + "(";- for (int j = 0; j < m.signal->parameters.size(); j++) {+ for (uint32_t j = 0; j < m.signal->parameters.size(); j++) {if (j > 0) {symbol.detail += ", ";}@@ -347,7 +345,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *psymbol.script_path = path;symbol.detail = "enum " + String(m.m_enum->identifier->name) + "{";- for (int j = 0; j < m.m_enum->values.size(); j++) {+ for (uint32_t j = 0; j < m.m_enum->values.size(); j++) {if (j > 0) {symbol.detail += ", ";}@@ -417,7 +415,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionNr_symbol.script_path = path;String parameters;- for (int i = 0; i < p_func->parameters.size(); i++) {+ for (uint32_t i = 0; i < p_func->parameters.size(); i++) {const ParameterNode *parameter = p_func->parameters[i];if (i > 0) {parameters += ", ";@@ -491,8 +489,8 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionNcase GDScriptParser::TypeNode::SUITE: {GDScriptParser::SuiteNode *suite_node = (GDScriptParser::SuiteNode *)node;function_nodes.push_back(suite_node);- for (int i = 0; i < suite_node->statements.size(); ++i) {- node_stack.push_back(suite_node->statements[i]);+ for (Node *stmt : suite_node->statements) {+ node_stack.push_back(stmt);}} break;@@ -503,8 +501,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionNfor (List<GDScriptParser::SuiteNode *>::Element *N = function_nodes.front(); N; N = N->next()) {const GDScriptParser::SuiteNode *suite_node = N->get();- for (int i = 0; i < suite_node->locals.size(); i++) {- const SuiteNode::Local &local = suite_node->locals[i];+ for (const SuiteNode::Local &local : suite_node->locals) {LSP::DocumentSymbol symbol;symbol.name = local.name;symbol.kind = local.type == SuiteNode::Local::CONSTANT ? LSP::SymbolKind::Constant : LSP::SymbolKind::Variable;@@ -816,12 +813,12 @@ Dictionary ExtendGDScriptParser::dump_function_api(const GDScriptParser::Functiofunc["return_type"] = p_func->return_type_constraint.to_string();func["rpc_config"] = p_func->rpc_config;Array parameters;- for (int i = 0; i < p_func->parameters.size(); i++) {+ for (ParameterNode *param : p_func->parameters) {Dictionary arg;- arg["name"] = p_func->parameters[i]->identifier->name;- arg["type"] = p_func->parameters[i]->type_constraint.to_string();- if (p_func->parameters[i]->initializer != nullptr) {- arg["default_value"] = p_func->parameters[i]->initializer->reduced_value;+ arg["name"] = param->identifier->name;+ arg["type"] = param->type_constraint.to_string();+ if (param->initializer != nullptr) {+ arg["default_value"] = param->initializer->reduced_value;}parameters.push_back(arg);}@@ -859,8 +856,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNodeArray methods;Array static_functions;- for (int i = 0; i < p_class->members.size(); i++) {- const ClassNode::Member &m = p_class->members[i];+ for (const ClassNode::Member &m : p_class->members) {switch (m.type) {case ClassNode::Member::CLASS:nested_classes.push_back(dump_class_api(m.m_class));@@ -889,8 +885,8 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode} break;case ClassNode::Member::ENUM: {Dictionary enum_dict;- for (int j = 0; j < m.m_enum->values.size(); j++) {- enum_dict[m.m_enum->values[j].identifier->name] = m.m_enum->values[j].value;+ for (const GDScriptParser::EnumNode::Value &element : m.m_enum->values) {+ enum_dict[element.identifier->name] = element.value;}Dictionary api;@@ -921,8 +917,8 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNodeDictionary api;api["name"] = m.signal->identifier->name;Array pars;- for (int j = 0; j < m.signal->parameters.size(); j++) {- pars.append(String(m.signal->parameters[j]->identifier->name));+ for (const ParameterNode *param : m.signal->parameters) {+ pars.append(String(param->identifier->name));}api["arguments"] = pars;if (const LSP::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(m.signal->start_line))) {