diff options
Diffstat (limited to 'modules/gdscript/gdscript_parser.h')
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 540ef1c561..0903f62061 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1,32 +1,32 @@ -/*************************************************************************/ -/* gdscript_parser.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ +/**************************************************************************/ +/* gdscript_parser.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ #ifndef GDSCRIPT_PARSER_H #define GDSCRIPT_PARSER_H @@ -57,6 +57,7 @@ public: struct AnnotationNode; struct ArrayNode; struct AssertNode; + struct AssignableNode; struct AssignmentNode; struct AwaitNode; struct BinaryOpNode; @@ -184,8 +185,8 @@ public: case BUILTIN: return builtin_type == p_other.builtin_type; case NATIVE: - case ENUM: - return native_type == p_other.native_type && enum_type == p_other.enum_type; + case ENUM: // Enums use native_type to identify the enum and its base class. + return native_type == p_other.native_type; case SCRIPT: return script_type == p_other.script_type; case CLASS: @@ -354,6 +355,20 @@ public: } }; + struct AssignableNode : public Node { + IdentifierNode *identifier = nullptr; + ExpressionNode *initializer = nullptr; + TypeNode *datatype_specifier = nullptr; + bool infer_datatype = false; + bool use_conversion_assign = false; + int usages = 0; + + virtual ~AssignableNode() {} + + protected: + AssignableNode() {} + }; + struct AssignmentNode : public ExpressionNode { // Assignment is not really an expression but it's easier to parse as if it were. enum Operation { @@ -483,6 +498,7 @@ public: IdentifierNode *identifier = nullptr; Vector<Value> values; + Variant dictionary; #ifdef TOOLS_ENABLED String doc_description; #endif // TOOLS_ENABLED @@ -731,12 +747,7 @@ public: } }; - struct ConstantNode : public Node { - IdentifierNode *identifier = nullptr; - ExpressionNode *initializer = nullptr; - TypeNode *datatype_specifier = nullptr; - bool infer_datatype = false; - int usages = 0; + struct ConstantNode : public AssignableNode { #ifdef TOOLS_ENABLED String doc_description; #endif // TOOLS_ENABLED @@ -901,13 +912,7 @@ public: } }; - struct ParameterNode : public Node { - IdentifierNode *identifier = nullptr; - ExpressionNode *default_value = nullptr; - TypeNode *datatype_specifier = nullptr; - bool infer_datatype = false; - int usages = 0; - + struct ParameterNode : public AssignableNode { ParameterNode() { type = PARAMETER; } @@ -1156,18 +1161,13 @@ public: } }; - struct VariableNode : public Node { + struct VariableNode : public AssignableNode { enum PropertyStyle { PROP_NONE, PROP_INLINE, PROP_SETGET, }; - IdentifierNode *identifier = nullptr; - ExpressionNode *initializer = nullptr; - TypeNode *datatype_specifier = nullptr; - bool infer_datatype = false; - PropertyStyle property = PROP_NONE; union { FunctionNode *setter = nullptr; @@ -1183,8 +1183,6 @@ public: bool onready = false; PropertyInfo export_info; int assignments = 0; - int usages = 0; - bool use_conversion_assign = false; #ifdef TOOLS_ENABLED String doc_description; #endif // TOOLS_ENABLED |