mirror of
https://github.com/godotengine/godot
synced 2024-09-05 09:28:51 +00:00
GDScript: Include lambda dependencies
This commit is contained in:
parent
13a0d6e9b2
commit
e4242f9b40
|
@ -1149,7 +1149,7 @@ GDScript *GDScript::get_root_script() {
|
||||||
RBSet<GDScript *> GDScript::get_dependencies() {
|
RBSet<GDScript *> GDScript::get_dependencies() {
|
||||||
RBSet<GDScript *> dependencies;
|
RBSet<GDScript *> dependencies;
|
||||||
|
|
||||||
_get_dependencies(dependencies, this);
|
_collect_dependencies(dependencies, this);
|
||||||
dependencies.erase(this);
|
dependencies.erase(this);
|
||||||
|
|
||||||
return dependencies;
|
return dependencies;
|
||||||
|
@ -1255,52 +1255,55 @@ GDScript *GDScript::_get_gdscript_from_variant(const Variant &p_variant) {
|
||||||
return Object::cast_to<GDScript>(obj);
|
return Object::cast_to<GDScript>(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScript::_get_dependencies(RBSet<GDScript *> &p_dependencies, const GDScript *p_except) {
|
void GDScript::_collect_function_dependencies(GDScriptFunction *p_func, RBSet<GDScript *> &p_dependencies, const GDScript *p_except) {
|
||||||
|
if (p_func == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (GDScriptFunction *lambda : p_func->lambdas) {
|
||||||
|
_collect_function_dependencies(lambda, p_dependencies, p_except);
|
||||||
|
}
|
||||||
|
for (const Variant &V : p_func->constants) {
|
||||||
|
GDScript *scr = _get_gdscript_from_variant(V);
|
||||||
|
if (scr != nullptr && scr != p_except) {
|
||||||
|
scr->_collect_dependencies(p_dependencies, p_except);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GDScript::_collect_dependencies(RBSet<GDScript *> &p_dependencies, const GDScript *p_except) {
|
||||||
if (p_dependencies.has(this)) {
|
if (p_dependencies.has(this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this != p_except) {
|
||||||
p_dependencies.insert(this);
|
p_dependencies.insert(this);
|
||||||
|
}
|
||||||
|
|
||||||
for (const KeyValue<StringName, GDScriptFunction *> &E : member_functions) {
|
for (const KeyValue<StringName, GDScriptFunction *> &E : member_functions) {
|
||||||
if (E.value == nullptr) {
|
_collect_function_dependencies(E.value, p_dependencies, p_except);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const Variant &V : E.value->constants) {
|
|
||||||
GDScript *scr = _get_gdscript_from_variant(V);
|
|
||||||
if (scr != nullptr && scr != p_except) {
|
|
||||||
scr->_get_dependencies(p_dependencies, p_except);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (implicit_initializer) {
|
if (implicit_initializer) {
|
||||||
for (const Variant &V : implicit_initializer->constants) {
|
_collect_function_dependencies(implicit_initializer, p_dependencies, p_except);
|
||||||
GDScript *scr = _get_gdscript_from_variant(V);
|
|
||||||
if (scr != nullptr && scr != p_except) {
|
|
||||||
scr->_get_dependencies(p_dependencies, p_except);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (implicit_ready) {
|
if (implicit_ready) {
|
||||||
for (const Variant &V : implicit_ready->constants) {
|
_collect_function_dependencies(implicit_ready, p_dependencies, p_except);
|
||||||
GDScript *scr = _get_gdscript_from_variant(V);
|
|
||||||
if (scr != nullptr && scr != p_except) {
|
|
||||||
scr->_get_dependencies(p_dependencies, p_except);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (static_initializer) {
|
||||||
|
_collect_function_dependencies(static_initializer, p_dependencies, p_except);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (KeyValue<StringName, Ref<GDScript>> &E : subclasses) {
|
for (KeyValue<StringName, Ref<GDScript>> &E : subclasses) {
|
||||||
if (E.value != p_except) {
|
if (E.value != p_except) {
|
||||||
E.value->_get_dependencies(p_dependencies, p_except);
|
E.value->_collect_dependencies(p_dependencies, p_except);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const KeyValue<StringName, Variant> &E : constants) {
|
for (const KeyValue<StringName, Variant> &E : constants) {
|
||||||
GDScript *scr = _get_gdscript_from_variant(E.value);
|
GDScript *scr = _get_gdscript_from_variant(E.value);
|
||||||
if (scr != nullptr && scr != p_except) {
|
if (scr != nullptr && scr != p_except) {
|
||||||
scr->_get_dependencies(p_dependencies, p_except);
|
scr->_collect_dependencies(p_dependencies, p_except);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,8 @@ class GDScript : public Script {
|
||||||
void _get_script_signal_list(List<MethodInfo> *r_list, bool p_include_base) const;
|
void _get_script_signal_list(List<MethodInfo> *r_list, bool p_include_base) const;
|
||||||
|
|
||||||
GDScript *_get_gdscript_from_variant(const Variant &p_variant);
|
GDScript *_get_gdscript_from_variant(const Variant &p_variant);
|
||||||
void _get_dependencies(RBSet<GDScript *> &p_dependencies, const GDScript *p_except);
|
void _collect_function_dependencies(GDScriptFunction *p_func, RBSet<GDScript *> &p_dependencies, const GDScript *p_except);
|
||||||
|
void _collect_dependencies(RBSet<GDScript *> &p_dependencies, const GDScript *p_except);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||||
|
|
Loading…
Reference in a new issue