diff options
author | George Marques <george@gmarqu.es> | 2024-04-18 11:48:07 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2024-04-18 11:54:37 -0300 |
commit | dc73440f899e6f32de748787e946ad762771fda0 (patch) | |
tree | d1b72549e507b6161963422f4c3fd8211dffdded /modules/gdscript/gdscript_parser.h | |
parent | 2efbc6bfb3b4f49a6bc75b3d367cfe81eeddbf3a (diff) | |
download | redot-engine-dc73440f899e6f32de748787e946ad762771fda0.tar.gz |
GDScript: Implement get_dependencies()
The parser and analyzer now track the dependencies of the script and
return the list when the resource loader ask for them.
What is considered a dependency:
- Any `preload()` call.
- The base script this one extends.
- Any identifier, including types, that refers to global scripts.
- Any autoload singleton reference.
Diffstat (limited to 'modules/gdscript/gdscript_parser.h')
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index d047fa8e46..40fcc13fa2 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1427,6 +1427,8 @@ private: void reset_extents(Node *p_node, GDScriptTokenizer::Token p_token); void reset_extents(Node *p_node, Node *p_from); + HashSet<String> dependencies; + template <typename T> T *alloc_node() { T *node = memnew(T); @@ -1568,9 +1570,11 @@ public: bool annotation_exists(const String &p_annotation_name) const; const List<ParserError> &get_errors() const { return errors; } - const List<String> get_dependencies() const { - // TODO: Keep track of deps. - return List<String>(); + const HashSet<String> &get_dependencies() const { + return dependencies; + } + void add_dependency(const String &p_dependency) { + dependencies.insert(p_dependency); } #ifdef DEBUG_ENABLED const List<GDScriptWarning> &get_warnings() const { return warnings; } |