diff options
author | George Marques <george@gmarqu.es> | 2020-06-11 21:49:58 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2020-07-20 11:38:40 -0300 |
commit | dadfcd8aba8df696f7c608866a34b4e5ee55a0bf (patch) | |
tree | 3a56d430105efb8df17dcbabe807d302d9687462 /modules/gdscript/gdscript_parser.h | |
parent | 95c0909290508620bd330c2b4f7120c92cd73f0c (diff) | |
download | redot-engine-dadfcd8aba8df696f7c608866a34b4e5ee55a0bf.tar.gz |
Added support for enums to be used as types in GDScript
Diffstat (limited to 'modules/gdscript/gdscript_parser.h')
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 4e9f750a2d..9deb4e6558 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -100,6 +100,8 @@ public: NATIVE, SCRIPT, CLASS, // GDScript. + ENUM, // Full enumeration. + ENUM_VALUE, // Value from enumeration. VARIANT, // Can be any type. UNRESOLVED, // TODO: Enum @@ -120,10 +122,12 @@ public: Variant::Type builtin_type = Variant::NIL; StringName native_type; + StringName enum_type; // Enum name or the value name in an enum. Ref<Script> script_type; ClassNode *class_type = nullptr; MethodInfo method_info; // For callable/signals. + HashMap<StringName, int> enum_values; // For enums. _FORCE_INLINE_ bool is_set() const { return kind != UNRESOLVED; } _FORCE_INLINE_ bool has_no_type() const { return type_source == UNDETECTED; } @@ -150,7 +154,10 @@ public: case BUILTIN: return builtin_type == p_other.builtin_type; case NATIVE: + case ENUM: return native_type == p_other.native_type; + case ENUM_VALUE: + return native_type == p_other.native_type && enum_type == p_other.enum_type; case SCRIPT: return script_type == p_other.script_type; case CLASS: @@ -480,6 +487,8 @@ public: return function->get_datatype(); case VARIABLE: return variable->get_datatype(); + case ENUM: + return m_enum->get_datatype(); case ENUM_VALUE: { // Always integer. DataType type; @@ -496,9 +505,6 @@ public: // TODO: Add parameter info. return type; } - case ENUM: - // TODO: Use special datatype kinds for this. - return DataType(); case UNDEFINED: return DataType(); } |