|
@@ -2037,7 +2037,8 @@ bool GDScriptParser::_reduce_export_var_type(Variant &p_value, int p_line) {
|
|
if (p_value.get_type() == Variant::ARRAY) {
|
|
if (p_value.get_type() == Variant::ARRAY) {
|
|
Array arr = p_value;
|
|
Array arr = p_value;
|
|
for (int i = 0; i < arr.size(); i++) {
|
|
for (int i = 0; i < arr.size(); i++) {
|
|
- if (!_reduce_export_var_type(arr[i], p_line)) return false;
|
|
|
|
|
|
+ if (!_reduce_export_var_type(arr[i], p_line))
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -2046,7 +2047,8 @@ bool GDScriptParser::_reduce_export_var_type(Variant &p_value, int p_line) {
|
|
Dictionary dict = p_value;
|
|
Dictionary dict = p_value;
|
|
for (int i = 0; i < dict.size(); i++) {
|
|
for (int i = 0; i < dict.size(); i++) {
|
|
Variant value = dict.get_value_at_index(i);
|
|
Variant value = dict.get_value_at_index(i);
|
|
- if (!_reduce_export_var_type(value, p_line)) return false;
|
|
|
|
|
|
+ if (!_reduce_export_var_type(value, p_line))
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -3374,7 +3376,8 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
|
|
|
|
|
|
_parse_pattern_block(compiled_branches, match_node->branches, p_static);
|
|
_parse_pattern_block(compiled_branches, match_node->branches, p_static);
|
|
|
|
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
|
|
|
|
ControlFlowNode *match_cf_node = alloc_node<ControlFlowNode>();
|
|
ControlFlowNode *match_cf_node = alloc_node<ControlFlowNode>();
|
|
match_cf_node->cf_type = ControlFlowNode::CF_MATCH;
|
|
match_cf_node->cf_type = ControlFlowNode::CF_MATCH;
|
|
@@ -4999,7 +5002,8 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!_reduce_export_var_type(cn->value, member.line)) return;
|
|
|
|
|
|
+ if (!_reduce_export_var_type(cn->value, member.line))
|
|
|
|
+ return;
|
|
|
|
|
|
member._export.type = cn->value.get_type();
|
|
member._export.type = cn->value.get_type();
|
|
member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
|
|
member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
|
|
@@ -5528,8 +5532,10 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (base_class) break;
|
|
|
|
- if (found) continue;
|
|
|
|
|
|
+ if (base_class)
|
|
|
|
+ break;
|
|
|
|
+ if (found)
|
|
|
|
+ continue;
|
|
|
|
|
|
if (p->constant_expressions.has(base)) {
|
|
if (p->constant_expressions.has(base)) {
|
|
if (p->constant_expressions[base].expression->type != Node::TYPE_CONSTANT) {
|
|
if (p->constant_expressions[base].expression->type != Node::TYPE_CONSTANT) {
|
|
@@ -5631,10 +5637,12 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive
|
|
}
|
|
}
|
|
|
|
|
|
String GDScriptParser::DataType::to_string() const {
|
|
String GDScriptParser::DataType::to_string() const {
|
|
- if (!has_type) return "var";
|
|
|
|
|
|
+ if (!has_type)
|
|
|
|
+ return "var";
|
|
switch (kind) {
|
|
switch (kind) {
|
|
case BUILTIN: {
|
|
case BUILTIN: {
|
|
- if (builtin_type == Variant::NIL) return "null";
|
|
|
|
|
|
+ if (builtin_type == Variant::NIL)
|
|
|
|
+ return "null";
|
|
return Variant::get_type_name(builtin_type);
|
|
return Variant::get_type_name(builtin_type);
|
|
} break;
|
|
} break;
|
|
case NATIVE: {
|
|
case NATIVE: {
|
|
@@ -5798,8 +5806,10 @@ bool GDScriptParser::_parse_type(DataType &r_type, bool p_can_be_void) {
|
|
}
|
|
}
|
|
|
|
|
|
GDScriptParser::DataType GDScriptParser::_resolve_type(const DataType &p_source, int p_line) {
|
|
GDScriptParser::DataType GDScriptParser::_resolve_type(const DataType &p_source, int p_line) {
|
|
- if (!p_source.has_type) return p_source;
|
|
|
|
- if (p_source.kind != DataType::UNRESOLVED) return p_source;
|
|
|
|
|
|
+ if (!p_source.has_type)
|
|
|
|
+ return p_source;
|
|
|
|
+ if (p_source.kind != DataType::UNRESOLVED)
|
|
|
|
+ return p_source;
|
|
|
|
|
|
Vector<String> full_name = p_source.native_type.operator String().split(".", false);
|
|
Vector<String> full_name = p_source.native_type.operator String().split(".", false);
|
|
int name_part = 0;
|
|
int name_part = 0;
|
|
@@ -7031,7 +7041,8 @@ bool GDScriptParser::_get_function_signature(DataType &p_base_type, const String
|
|
native = "_" + native.operator String();
|
|
native = "_" + native.operator String();
|
|
}
|
|
}
|
|
if (!ClassDB::class_exists(native)) {
|
|
if (!ClassDB::class_exists(native)) {
|
|
- if (!check_types) return false;
|
|
|
|
|
|
+ if (!check_types)
|
|
|
|
+ return false;
|
|
ERR_FAIL_V_MSG(false, "Parser bug: Class '" + String(native) + "' not found.");
|
|
ERR_FAIL_V_MSG(false, "Parser bug: Class '" + String(native) + "' not found.");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -7126,7 +7137,8 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
|
|
par_types.write[i - 1] = _reduce_node_type(p_call->arguments[i]);
|
|
par_types.write[i - 1] = _reduce_node_type(p_call->arguments[i]);
|
|
}
|
|
}
|
|
|
|
|
|
- if (error_set) return DataType();
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return DataType();
|
|
|
|
|
|
// Special case: check copy constructor. Those are defined implicitly in Variant.
|
|
// Special case: check copy constructor. Those are defined implicitly in Variant.
|
|
if (par_types.size() == 1) {
|
|
if (par_types.size() == 1) {
|
|
@@ -7194,7 +7206,8 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat
|
|
err += "' matches the signature '";
|
|
err += "' matches the signature '";
|
|
err += Variant::get_type_name(tn->vtype) + "(";
|
|
err += Variant::get_type_name(tn->vtype) + "(";
|
|
for (int i = 0; i < par_types.size(); i++) {
|
|
for (int i = 0; i < par_types.size(); i++) {
|
|
- if (i > 0) err += ", ";
|
|
|
|
|
|
+ if (i > 0)
|
|
|
|
+ err += ", ";
|
|
err += par_types[i].to_string();
|
|
err += par_types[i].to_string();
|
|
}
|
|
}
|
|
err += ")'.";
|
|
err += ")'.";
|
|
@@ -7563,7 +7576,8 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN
|
|
native = "_" + native.operator String();
|
|
native = "_" + native.operator String();
|
|
}
|
|
}
|
|
if (!ClassDB::class_exists(native)) {
|
|
if (!ClassDB::class_exists(native)) {
|
|
- if (!check_types) return false;
|
|
|
|
|
|
+ if (!check_types)
|
|
|
|
+ return false;
|
|
ERR_FAIL_V_MSG(false, "Parser bug: Class \"" + String(native) + "\" not found.");
|
|
ERR_FAIL_V_MSG(false, "Parser bug: Class \"" + String(native) + "\" not found.");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -7861,12 +7875,14 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
|
|
// Function declarations
|
|
// Function declarations
|
|
for (int i = 0; i < p_class->static_functions.size(); i++) {
|
|
for (int i = 0; i < p_class->static_functions.size(); i++) {
|
|
_check_function_types(p_class->static_functions[i]);
|
|
_check_function_types(p_class->static_functions[i]);
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
for (int i = 0; i < p_class->functions.size(); i++) {
|
|
for (int i = 0; i < p_class->functions.size(); i++) {
|
|
_check_function_types(p_class->functions[i]);
|
|
_check_function_types(p_class->functions[i]);
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
// Class variables
|
|
// Class variables
|
|
@@ -7946,7 +7962,8 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
|
|
}
|
|
}
|
|
|
|
|
|
// Setter and getter
|
|
// Setter and getter
|
|
- if (v.setter == StringName() && v.getter == StringName()) continue;
|
|
|
|
|
|
+ if (v.setter == StringName() && v.getter == StringName())
|
|
|
|
+ continue;
|
|
|
|
|
|
bool found_getter = false;
|
|
bool found_getter = false;
|
|
bool found_setter = false;
|
|
bool found_setter = false;
|
|
@@ -7989,10 +8006,12 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (found_getter && found_setter) break;
|
|
|
|
|
|
+ if (found_getter && found_setter)
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
- if ((found_getter || v.getter == StringName()) && (found_setter || v.setter == StringName())) continue;
|
|
|
|
|
|
+ if ((found_getter || v.getter == StringName()) && (found_setter || v.setter == StringName()))
|
|
|
|
+ continue;
|
|
|
|
|
|
// Check for static functions
|
|
// Check for static functions
|
|
for (int j = 0; j < p_class->static_functions.size(); j++) {
|
|
for (int j = 0; j < p_class->static_functions.size(); j++) {
|
|
@@ -8064,7 +8083,8 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
|
|
for (int i = 0; i < p_class->subclasses.size(); i++) {
|
|
for (int i = 0; i < p_class->subclasses.size(); i++) {
|
|
current_class = p_class->subclasses[i];
|
|
current_class = p_class->subclasses[i];
|
|
_check_class_level_types(current_class);
|
|
_check_class_level_types(current_class);
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
current_class = p_class;
|
|
current_class = p_class;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -8201,7 +8221,8 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
|
|
_check_block_types(current_block);
|
|
_check_block_types(current_block);
|
|
current_block = NULL;
|
|
current_block = NULL;
|
|
current_function = NULL;
|
|
current_function = NULL;
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
for (int i = 0; i < p_class->functions.size(); i++) {
|
|
for (int i = 0; i < p_class->functions.size(); i++) {
|
|
@@ -8211,7 +8232,8 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
|
|
_check_block_types(current_block);
|
|
_check_block_types(current_block);
|
|
current_block = NULL;
|
|
current_block = NULL;
|
|
current_function = NULL;
|
|
current_function = NULL;
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
@@ -8232,7 +8254,8 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) {
|
|
for (int i = 0; i < p_class->subclasses.size(); i++) {
|
|
for (int i = 0; i < p_class->subclasses.size(); i++) {
|
|
current_class = p_class->subclasses[i];
|
|
current_class = p_class->subclasses[i];
|
|
_check_class_blocks_types(current_class);
|
|
_check_class_blocks_types(current_class);
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
current_class = p_class;
|
|
current_class = p_class;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -8502,7 +8525,8 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
|
|
_add_warning(GDScriptWarning::RETURN_VALUE_DISCARDED, op->line, func_name);
|
|
_add_warning(GDScriptWarning::RETURN_VALUE_DISCARDED, op->line, func_name);
|
|
}
|
|
}
|
|
#endif // DEBUG_ENABLED
|
|
#endif // DEBUG_ENABLED
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
} break;
|
|
} break;
|
|
case OperatorNode::OP_YIELD: {
|
|
case OperatorNode::OP_YIELD: {
|
|
_mark_line_as_safe(op->line);
|
|
_mark_line_as_safe(op->line);
|
|
@@ -8537,7 +8561,8 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (!function_type.has_type) break;
|
|
|
|
|
|
+ if (!function_type.has_type)
|
|
|
|
+ break;
|
|
|
|
|
|
if (function_type.kind == DataType::BUILTIN && function_type.builtin_type == Variant::NIL) {
|
|
if (function_type.kind == DataType::BUILTIN && function_type.builtin_type == Variant::NIL) {
|
|
// Return void, should not have arguments
|
|
// Return void, should not have arguments
|
|
@@ -8597,7 +8622,8 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
|
|
current_block = p_block->sub_blocks[i];
|
|
current_block = p_block->sub_blocks[i];
|
|
_check_block_types(current_block);
|
|
_check_block_types(current_block);
|
|
current_block = p_block;
|
|
current_block = p_block;
|
|
- if (error_set) return;
|
|
|
|
|
|
+ if (error_set)
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
@@ -8740,7 +8766,8 @@ Error GDScriptParser::_parse(const String &p_base_path) {
|
|
current_function = NULL;
|
|
current_function = NULL;
|
|
current_block = NULL;
|
|
current_block = NULL;
|
|
|
|
|
|
- if (for_completion) check_types = false;
|
|
|
|
|
|
+ if (for_completion)
|
|
|
|
+ check_types = false;
|
|
|
|
|
|
// Resolve all class-level stuff before getting into function blocks
|
|
// Resolve all class-level stuff before getting into function blocks
|
|
_check_class_level_types(main_class);
|
|
_check_class_level_types(main_class);
|