diff options
Diffstat (limited to 'modules/gdscript/gdscript_parser.h')
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 0ba0d5b6da..8f0265510f 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -91,6 +91,7 @@ public: struct SuiteNode; struct TernaryOpNode; struct TypeNode; + struct TypeTestNode; struct UnaryOpNode; struct VariableNode; struct WhileNode; @@ -124,6 +125,7 @@ public: bool is_constant = false; bool is_read_only = false; bool is_meta_type = false; + bool is_pseudo_type = false; // For global names that can't be used standalone. bool is_coroutine = false; // For function calls. Variant::Type builtin_type = Variant::NIL; @@ -210,6 +212,7 @@ public: is_read_only = p_other.is_read_only; is_constant = p_other.is_constant; is_meta_type = p_other.is_meta_type; + is_pseudo_type = p_other.is_pseudo_type; is_coroutine = p_other.is_coroutine; builtin_type = p_other.builtin_type; native_type = p_other.native_type; @@ -288,6 +291,7 @@ public: SUITE, TERNARY_OPERATOR, TYPE, + TYPE_TEST, UNARY_OPERATOR, VARIABLE, WHILE, @@ -426,7 +430,6 @@ public: OP_BIT_XOR, OP_LOGIC_AND, OP_LOGIC_OR, - OP_TYPE_TEST, OP_CONTENT_TEST, OP_COMP_EQUAL, OP_COMP_NOT_EQUAL, @@ -706,8 +709,10 @@ public: ClassNode *outer = nullptr; bool extends_used = false; bool onready_used = false; + bool has_static_data = false; + bool annotated_static_unload = false; String extends_path; - Vector<StringName> extends; // List for indexing: extends A.B.C + Vector<IdentifierNode *> extends; // List for indexing: extends A.B.C DataType base_type; String fqcn; // Fully-qualified class name. Identifies uniquely any class in the project. #ifdef TOOLS_ENABLED @@ -844,6 +849,7 @@ public: LOCAL_BIND, // Pattern bind. MEMBER_SIGNAL, MEMBER_VARIABLE, + STATIC_VARIABLE, MEMBER_CONSTANT, INHERITED_VARIABLE, }; @@ -1150,6 +1156,16 @@ public: } }; + struct TypeTestNode : public ExpressionNode { + ExpressionNode *operand = nullptr; + TypeNode *test_type = nullptr; + DataType test_datatype; + + TypeTestNode() { + type = TYPE_TEST; + } + }; + struct UnaryOpNode : public ExpressionNode { enum OpType { OP_POSITIVE, @@ -1189,6 +1205,7 @@ public: bool onready = false; PropertyInfo export_info; int assignments = 0; + bool is_static = false; #ifdef TOOLS_ENABLED String doc_description; #endif // TOOLS_ENABLED @@ -1392,16 +1409,16 @@ private: // Main blocks. void parse_program(); - ClassNode *parse_class(); + ClassNode *parse_class(bool p_is_static); void parse_class_name(); void parse_extends(); void parse_class_body(bool p_is_multiline); template <class T> - void parse_class_member(T *(GDScriptParser::*p_parse_function)(), AnnotationInfo::TargetKind p_target, const String &p_member_kind); - SignalNode *parse_signal(); - EnumNode *parse_enum(); + void parse_class_member(T *(GDScriptParser::*p_parse_function)(bool), AnnotationInfo::TargetKind p_target, const String &p_member_kind, bool p_is_static = false); + SignalNode *parse_signal(bool p_is_static); + EnumNode *parse_enum(bool p_is_static); ParameterNode *parse_parameter(); - FunctionNode *parse_function(); + FunctionNode *parse_function(bool p_is_static); void parse_function_signature(FunctionNode *p_function, SuiteNode *p_body, const String &p_type); SuiteNode *parse_suite(const String &p_context, SuiteNode *p_suite = nullptr, bool p_for_lambda = false); // Annotations @@ -1418,14 +1435,15 @@ private: 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); // Statements. Node *parse_statement(); - VariableNode *parse_variable(); - VariableNode *parse_variable(bool p_allow_property); + VariableNode *parse_variable(bool p_is_static); + VariableNode *parse_variable(bool p_is_static, bool p_allow_property); VariableNode *parse_property(VariableNode *p_variable, bool p_need_indent); void parse_property_getter(VariableNode *p_variable); void parse_property_setter(VariableNode *p_variable); - ConstantNode *parse_constant(); + ConstantNode *parse_constant(bool p_is_static); AssertNode *parse_assert(); BreakNode *parse_break(); ContinueNode *parse_continue(); @@ -1460,13 +1478,14 @@ private: ExpressionNode *parse_attribute(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_subscript(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_lambda(ExpressionNode *p_previous_operand, bool p_can_assign); + ExpressionNode *parse_type_test(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_yield(ExpressionNode *p_previous_operand, bool p_can_assign); ExpressionNode *parse_invalid_token(ExpressionNode *p_previous_operand, bool p_can_assign); TypeNode *parse_type(bool p_allow_void = false); #ifdef TOOLS_ENABLED // Doc comments. int class_doc_line = 0x7FFFFFFF; - bool has_comment(int p_line); + bool has_comment(int p_line, bool p_must_be_doc = false); String get_doc_comment(int p_line, bool p_single_line = false); void get_class_doc_comment(int p_line, String &p_brief, String &p_desc, Vector<Pair<String, String>> &p_tutorials, bool p_inner_class); #endif // TOOLS_ENABLED @@ -1541,8 +1560,9 @@ public: void print_statement(Node *p_statement); void print_subscript(SubscriptNode *p_subscript); void print_suite(SuiteNode *p_suite); - void print_type(TypeNode *p_type); void print_ternary_op(TernaryOpNode *p_ternary_op); + void print_type(TypeNode *p_type); + void print_type_test(TypeTestNode *p_type_test); void print_unary_op(UnaryOpNode *p_unary_op); void print_variable(VariableNode *p_variable); void print_while(WhileNode *p_while); |