summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gdscript_parser.h')
-rw-r--r--modules/gdscript/gdscript_parser.h46
1 files changed, 28 insertions, 18 deletions
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index 9690784cba..4b46b98baa 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -147,14 +147,17 @@ public:
_FORCE_INLINE_ bool has_no_type() const { return type_source == UNDETECTED; }
_FORCE_INLINE_ bool is_variant() const { return kind == VARIANT || kind == RESOLVING || kind == UNRESOLVED; }
_FORCE_INLINE_ bool is_hard_type() const { return type_source > INFERRED; }
+
String to_string() const;
+ _FORCE_INLINE_ String to_string_strict() const { return is_hard_type() ? to_string() : "Variant"; }
+ PropertyInfo to_property_info(const String &p_name) const;
_FORCE_INLINE_ void set_container_element_type(const DataType &p_type) {
container_element_type = memnew(DataType(p_type));
}
_FORCE_INLINE_ DataType get_container_element_type() const {
- ERR_FAIL_COND_V(container_element_type == nullptr, DataType());
+ ERR_FAIL_NULL_V(container_element_type, DataType());
return *container_element_type;
}
@@ -175,11 +178,11 @@ public:
bool operator==(const DataType &p_other) const {
if (type_source == UNDETECTED || p_other.type_source == UNDETECTED) {
- return true; // Can be consireded equal for parsing purposes.
+ return true; // Can be considered equal for parsing purposes.
}
if (type_source == INFERRED || p_other.type_source == INFERRED) {
- return true; // Can be consireded equal for parsing purposes.
+ return true; // Can be considered equal for parsing purposes.
}
if (kind != p_other.kind) {
@@ -360,7 +363,7 @@ public:
bool is_resolved = false;
bool is_applied = false;
- bool apply(GDScriptParser *p_this, Node *p_target);
+ bool apply(GDScriptParser *p_this, Node *p_target, ClassNode *p_class);
bool applies_to(uint32_t p_target_kinds) const;
AnnotationNode() {
@@ -749,6 +752,10 @@ public:
bool resolved_interface = false;
bool resolved_body = false;
+ StringName get_global_name() const {
+ return (outer == nullptr && identifier != nullptr) ? identifier->name : StringName();
+ }
+
Member get_member(const StringName &p_name) const {
return members[members_indices[p_name]];
}
@@ -831,13 +838,13 @@ public:
HashMap<StringName, int> parameters_indices;
TypeNode *return_type = nullptr;
SuiteNode *body = nullptr;
- bool is_static = false;
+ bool is_static = false; // For lambdas it's determined in the analyzer.
bool is_coroutine = false;
Variant rpc_config;
MethodInfo info;
LambdaNode *source_lambda = nullptr;
-#ifdef TOOLS_ENABLED
Vector<Variant> default_arg_values;
+#ifdef TOOLS_ENABLED
MemberDocData doc_data;
#endif // TOOLS_ENABLED
@@ -942,6 +949,7 @@ public:
Vector<PatternNode *> patterns;
SuiteNode *block = nullptr;
bool has_wildcard = false;
+ SuiteNode *guard_body = nullptr;
MatchBranchNode() {
type = MATCH_BRANCH;
@@ -1026,6 +1034,7 @@ public:
IdentifierNode *identifier = nullptr;
Vector<ParameterNode *> parameters;
HashMap<StringName, int> parameters_indices;
+ MethodInfo method_info;
#ifdef TOOLS_ENABLED
MemberDocData doc_data;
#endif // TOOLS_ENABLED
@@ -1331,7 +1340,7 @@ private:
bool in_lambda = false;
bool lambda_ended = false; // Marker for when a lambda ends, to apply an end of statement if needed.
- typedef bool (GDScriptParser::*AnnotationAction)(const AnnotationNode *p_annotation, Node *p_target);
+ typedef bool (GDScriptParser::*AnnotationAction)(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
struct AnnotationInfo {
enum TargetKind {
NONE = 0,
@@ -1452,16 +1461,16 @@ private:
bool register_annotation(const MethodInfo &p_info, uint32_t p_target_kinds, AnnotationAction p_apply, const Vector<Variant> &p_default_arguments = Vector<Variant>(), bool p_is_vararg = false);
bool validate_annotation_arguments(AnnotationNode *p_annotation);
void clear_unused_annotations();
- bool tool_annotation(const AnnotationNode *p_annotation, Node *p_target);
- bool icon_annotation(const AnnotationNode *p_annotation, Node *p_target);
- bool onready_annotation(const AnnotationNode *p_annotation, Node *p_target);
+ bool tool_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool icon_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool onready_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
template <PropertyHint t_hint, Variant::Type t_type>
- bool export_annotations(const AnnotationNode *p_annotation, Node *p_target);
+ bool export_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
template <PropertyUsageFlags t_usage>
- bool export_group_annotations(const AnnotationNode *p_annotation, Node *p_target);
- bool warning_annotations(const AnnotationNode *p_annotation, Node *p_target);
- bool rpc_annotation(const AnnotationNode *p_annotation, Node *p_target);
- bool static_unload_annotation(const AnnotationNode *p_annotation, Node *p_target);
+ bool export_group_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool warning_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool rpc_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
+ bool static_unload_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class);
// Statements.
Node *parse_statement();
VariableNode *parse_variable(bool p_is_static);
@@ -1510,10 +1519,11 @@ private:
TypeNode *parse_type(bool p_allow_void = false);
#ifdef TOOLS_ENABLED
- int class_doc_line = 0x7FFFFFFF;
+ int max_script_doc_line = INT_MAX;
+ int min_member_doc_line = 1;
bool has_comment(int p_line, bool p_must_be_doc = false);
MemberDocData parse_doc_comment(int p_line, bool p_single_line = false);
- ClassDocData parse_class_doc_comment(int p_line, bool p_inner_class, bool p_single_line = false);
+ ClassDocData parse_class_doc_comment(int p_line, bool p_single_line = false);
#endif // TOOLS_ENABLED
public:
@@ -1522,7 +1532,7 @@ public:
bool is_tool() const { return _is_tool; }
ClassNode *find_class(const String &p_qualified_name) const;
bool has_class(const GDScriptParser::ClassNode *p_class) const;
- static Variant::Type get_builtin_type(const StringName &p_type);
+ static Variant::Type get_builtin_type(const StringName &p_type); // Excluding `Variant::NIL` and `Variant::OBJECT`.
CompletionContext get_completion_context() const { return completion_context; }
CompletionCall get_completion_call() const { return completion_call; }