#include #include #include #ifndef PORYGONLANG_SCRIPTTYPE_HPP #define PORYGONLANG_SCRIPTTYPE_HPP #include #include #include #include "Binder/BoundVariables/BoundVariableKey.hpp" using namespace std; enum class TypeClass{ Error, Nil, Number, Bool, String, Function, UserData, Table, }; class ScriptType{ TypeClass _class; public: explicit ScriptType(TypeClass c){ _class = c; } virtual ~ScriptType() = default; const TypeClass GetClass(){ return _class; } virtual bool operator ==(const ScriptType& b){ return _class == b._class; }; virtual bool operator ==(ScriptType* b){ return _class == b->_class; }; virtual bool operator !=(const ScriptType& b){ return ! (operator==(b)); } virtual bool operator !=(ScriptType* b){ return ! (operator==(b)); } }; class NumericScriptType : public ScriptType{ // Are we aware of whether this is a float or not? bool _awareOfFloat; // Is this value a float? bool _isFloat; public: explicit NumericScriptType(bool floatAware, bool isFloat) : ScriptType(TypeClass::Number){ _awareOfFloat = floatAware; _isFloat = isFloat; } bool IsAwareOfFloat(){ return _awareOfFloat; } bool IsFloat(){ return _isFloat; } }; class FunctionScriptType : public ScriptType{ shared_ptr _returnType; shared_ptr>> _parameterTypes; shared_ptr>> _parameterKeys; public: FunctionScriptType(std::shared_ptr returnType, shared_ptr>> parameterTypes, shared_ptr>> parameterKeys) : ScriptType(TypeClass::Function){ _returnType = std::move(returnType); _parameterTypes = std::move(parameterTypes); _parameterKeys = std::move(parameterKeys); } shared_ptr GetReturnType(){ return _returnType; } shared_ptr>> GetParameterTypes(){ return _parameterTypes; } shared_ptr>> GetParameterKeys(){ return _parameterKeys; } }; #endif //PORYGONLANG_SCRIPTTYPE_HPP