Selaa lähdekoodia

[GDScript] Add static HashMap cleanup.

bruvzg 5 vuotta sitten
vanhempi
commit
ee973f5b90

+ 4 - 0
modules/gdscript/gdscript_analyzer.cpp

@@ -71,6 +71,10 @@ static StringName get_real_class_name(const StringName &p_source) {
 	return p_source;
 }
 
+void GDScriptAnalyzer::cleanup() {
+	underscore_map.clear();
+}
+
 static GDScriptParser::DataType make_callable_type(const MethodInfo &p_info) {
 	GDScriptParser::DataType type;
 	type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;

+ 2 - 0
modules/gdscript/gdscript_analyzer.h

@@ -113,6 +113,8 @@ public:
 	Error analyze();
 
 	GDScriptAnalyzer(GDScriptParser *p_parser);
+
+	static void cleanup();
 };
 
 #endif // GDSCRIPT_ANALYZER_H

+ 4 - 0
modules/gdscript/gdscript_parser.cpp

@@ -94,6 +94,10 @@ Variant::Type GDScriptParser::get_builtin_type(const StringName &p_type) {
 	return Variant::VARIANT_MAX;
 }
 
+void GDScriptParser::cleanup() {
+	builtin_types.clear();
+}
+
 GDScriptFunctions::Function GDScriptParser::get_builtin_function(const StringName &p_name) {
 	for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
 		if (p_name == GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i))) {

+ 1 - 0
modules/gdscript/gdscript_parser.h

@@ -1335,6 +1335,7 @@ public:
 		void print_tree(const GDScriptParser &p_parser);
 	};
 #endif // DEBUG_ENABLED
+	static void cleanup();
 };
 
 #endif // GDSCRIPT_PARSER_H

+ 4 - 0
modules/gdscript/register_types.cpp

@@ -35,6 +35,7 @@
 #include "core/os/dir_access.h"
 #include "core/os/file_access.h"
 #include "gdscript.h"
+#include "gdscript_analyzer.h"
 #include "gdscript_cache.h"
 #include "gdscript_tokenizer.h"
 
@@ -148,4 +149,7 @@ void unregister_gdscript_types() {
 	EditorTranslationParser::get_singleton()->remove_parser(gdscript_translation_parser_plugin, EditorTranslationParser::STANDARD);
 	gdscript_translation_parser_plugin.unref();
 #endif // TOOLS_ENABLED
+
+	GDScriptParser::cleanup();
+	GDScriptAnalyzer::cleanup();
 }