#ifndef PORYGONLANG_SCRIPTFUNCTIONEVALVALUE_HPP #define PORYGONLANG_SCRIPTFUNCTIONEVALVALUE_HPP #include #include #include #include "../../ScriptType.hpp" #include "EvalValue.hpp" #include "../../Binder/BoundStatements/BoundStatement.hpp" #include "../EvaluationScope/EvaluationScope.hpp" #include "../../FunctionScriptType.hpp" using namespace std; namespace Porygon::Evaluation { class GenericFunctionOption{ public: virtual ~GenericFunctionOption() = default; }; class EvaluationScriptFunctionOption : public GenericFunctionOption{ const std::shared_ptr _innerBlock; const std::shared_ptr _scope; public: EvaluationScriptFunctionOption(shared_ptr innerBlock, shared_ptr scope) : _innerBlock(std::move(innerBlock)), _scope(std::move(scope)) { } ~EvaluationScriptFunctionOption() final = default; inline std::shared_ptr GetInnerBlock() const { return _innerBlock; } inline const std::shared_ptr &GetScope() const { return _scope; } }; class GenericFunctionEvalValue : public EvalValue{ protected: const shared_ptr _type; const size_t _hash; shared_ptr>> _options; GenericFunctionEvalValue(shared_ptr type, size_t hash, shared_ptr>> options) :_type(std::move(type)), _hash(hash), _options(std::move(options)) {} public: GenericFunctionEvalValue(shared_ptr type, size_t hash) : _type(move(type)), _hash(hash), _options(make_shared>>()){ } GenericFunctionEvalValue(const GenericFunctionEvalValue& _) = delete; GenericFunctionEvalValue() = delete; GenericFunctionEvalValue& operator =(GenericFunctionEvalValue v) = delete; [[nodiscard]] EvalValue* Clone() const final { return new GenericFunctionEvalValue(_type, _hash, _options); } inline void RegisterOption(GenericFunctionOption* option) const{ _options->push_back(shared_ptr(option)); } [[nodiscard]] inline std::shared_ptr GetType() const { return _type; } inline TypeClass GetTypeClass() const final { return TypeClass::Function; } bool operator==(const EvalValue *b) const final { if (b->GetTypeClass() != TypeClass::Function) return false; return this->_hash == ((GenericFunctionEvalValue *) b)->_hash; }; inline std::size_t GetHashCode() const final { return _hash; } [[nodiscard]] inline shared_ptr GetOption(const size_t id) const{ return this->_options->at(id); } }; } #endif //PORYGONLANG_SCRIPTFUNCTIONEVALVALUE_HPP