1 #pragma once 2 3 #include "Value.h" 4 5 namespace actions { 6 namespace expression { 7 8 class TypeDefinition { 9 public: 10 TypeDefinition(SCP_string name, SCP_vector<actions::expression::ValueType> allowedImplicitConversion); 11 12 const SCP_string& getName() const; 13 14 const SCP_vector<actions::expression::ValueType>& getAllowedImplicitConversions() const; 15 16 static const TypeDefinition& forValueType(ValueType type); 17 18 // This type is supposed to be global so it may not be copied 19 TypeDefinition(const TypeDefinition&) = delete; 20 TypeDefinition& operator=(const TypeDefinition&) = delete; 21 22 TypeDefinition(TypeDefinition&&) = delete; 23 TypeDefinition& operator=(TypeDefinition&&) = delete; 24 25 private: 26 SCP_string m_name; 27 28 // The types this type is allowed to implicitly convert to 29 SCP_vector<ValueType> m_allowedImplicitConversions; 30 31 static TypeDefinition s_integer; 32 static TypeDefinition s_float; 33 static TypeDefinition s_vector; 34 static TypeDefinition s_identifier; 35 }; 36 37 bool checkTypeWithImplicitConversion(ValueType currentType, ValueType expectedType); 38 39 } // namespace expression 40 } // namespace actions 41