summaryrefslogtreecommitdiff
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.h43
1 files changed, 20 insertions, 23 deletions
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index e0c8042162..0903f62061 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/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 {
@@ -732,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
@@ -902,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;
}
@@ -1157,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;
@@ -1184,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