mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-03 09:29:38 +01:00
Also backported the previous change for cscript.
This commit is contained in:
parent
929ad6b766
commit
6b6536ffe8
@ -57,6 +57,21 @@ T *CScriptParser::alloc_node() {
|
||||
return t;
|
||||
}
|
||||
|
||||
static String _lookup_autoload_path_for_identifier(const String &p_identifier) {
|
||||
String autoload_path;
|
||||
String autoload_setting_path = "autoload/" + p_identifier;
|
||||
if (ProjectSettings::get_singleton()->has_setting(autoload_setting_path)) {
|
||||
autoload_path = ProjectSettings::get_singleton()->get(autoload_setting_path);
|
||||
if (autoload_path.begins_with("*")) {
|
||||
autoload_path = autoload_path.right(1);
|
||||
}
|
||||
if (!autoload_path.begins_with("res://")) {
|
||||
autoload_path = "res://" + autoload_path;
|
||||
}
|
||||
}
|
||||
return autoload_path;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
static String _find_function_name(const CScriptParser::OperatorNode *p_call);
|
||||
#endif // DEBUG_ENABLED
|
||||
@ -5332,23 +5347,9 @@ void CScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive)
|
||||
}
|
||||
p = nullptr;
|
||||
} else {
|
||||
List<PropertyInfo> props;
|
||||
ProjectSettings::get_singleton()->get_property_list(&props);
|
||||
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
|
||||
String s = E->get().name;
|
||||
if (!s.begins_with("autoload/")) {
|
||||
continue;
|
||||
}
|
||||
String name = s.get_slice("/", 1);
|
||||
if (name == base) {
|
||||
String singleton_path = ProjectSettings::get_singleton()->get(s);
|
||||
if (singleton_path.begins_with("*")) {
|
||||
singleton_path = singleton_path.right(1);
|
||||
}
|
||||
if (!singleton_path.begins_with("res://")) {
|
||||
singleton_path = "res://" + singleton_path;
|
||||
}
|
||||
base_script = ResourceLoader::load(singleton_path);
|
||||
String autoload_path = _lookup_autoload_path_for_identifier(base);
|
||||
if (!autoload_path.empty()) {
|
||||
base_script = ResourceLoader::load(autoload_path);
|
||||
if (!base_script.is_valid()) {
|
||||
_set_error("Class '" + base + "' could not be fully loaded (script error or cyclic inheritance).", p_class->line);
|
||||
return;
|
||||
@ -5356,7 +5357,6 @@ void CScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive)
|
||||
p = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (p) {
|
||||
bool found = false;
|
||||
@ -5704,28 +5704,10 @@ CScriptParser::DataType CScriptParser::_resolve_type(const DataType &p_source, i
|
||||
name_part++;
|
||||
continue;
|
||||
}
|
||||
List<PropertyInfo> props;
|
||||
ProjectSettings::get_singleton()->get_property_list(&props);
|
||||
String singleton_path;
|
||||
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
|
||||
String s = E->get().name;
|
||||
if (!s.begins_with("autoload/")) {
|
||||
continue;
|
||||
}
|
||||
String name = s.get_slice("/", 1);
|
||||
if (name == id) {
|
||||
singleton_path = ProjectSettings::get_singleton()->get(s);
|
||||
if (singleton_path.begins_with("*")) {
|
||||
singleton_path = singleton_path.right(1);
|
||||
}
|
||||
if (!singleton_path.begins_with("res://")) {
|
||||
singleton_path = "res://" + singleton_path;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!singleton_path.empty()) {
|
||||
Ref<Script> script = ResourceLoader::load(singleton_path);
|
||||
String autoload_path = _lookup_autoload_path_for_identifier(id);
|
||||
if (!autoload_path.empty()) {
|
||||
Ref<Script> script = ResourceLoader::load(autoload_path);
|
||||
|
||||
Ref<CScript> gds = script;
|
||||
if (gds.is_valid()) {
|
||||
if (!gds->is_valid()) {
|
||||
@ -7654,24 +7636,9 @@ CScriptParser::DataType CScriptParser::_reduce_identifier_type(const DataType *p
|
||||
}
|
||||
|
||||
// Non-tool singletons aren't loaded, check project settings
|
||||
List<PropertyInfo> props;
|
||||
ProjectSettings::get_singleton()->get_property_list(&props);
|
||||
|
||||
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
|
||||
String s = E->get().name;
|
||||
if (!s.begins_with("autoload/")) {
|
||||
continue;
|
||||
}
|
||||
String name = s.get_slice("/", 1);
|
||||
if (name == p_identifier) {
|
||||
String script = ProjectSettings::get_singleton()->get(s);
|
||||
if (script.begins_with("*")) {
|
||||
script = script.right(1);
|
||||
}
|
||||
if (!script.begins_with("res://")) {
|
||||
script = "res://" + script;
|
||||
}
|
||||
Ref<Script> singleton = ResourceLoader::load(script);
|
||||
String autoload_path = _lookup_autoload_path_for_identifier(p_identifier);
|
||||
if (!autoload_path.empty()) {
|
||||
Ref<Script> singleton = ResourceLoader::load(autoload_path);
|
||||
if (singleton.is_valid()) {
|
||||
DataType result;
|
||||
result.has_type = true;
|
||||
@ -7690,7 +7657,6 @@ CScriptParser::DataType CScriptParser::_reduce_identifier_type(const DataType *p
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This means looking in the current class, which type is always known
|
||||
_set_error("The identifier \"" + p_identifier.operator String() + "\" isn't declared in the current scope.", p_line);
|
||||
|
Loading…
Reference in New Issue
Block a user