
#ifndef PORYGONLANG_USERDATAOPERATION_HPP
#define PORYGONLANG_USERDATAOPERATION_HPP
#include <utility>
#include "../Binder/BoundOperators.hpp"
#include "../Evaluator/EvalValues/EvalValue.hpp"

namespace Porygon::UserData {
    class UserDataBinaryOperation {
        void* _parent;
        Evaluation::EvalValue *(*_func)(void *obj, Evaluation::EvalValue *b);
        const shared_ptr<const ScriptType> _secondParameter;
        const shared_ptr<const ScriptType> _returnType;
    public:
        UserDataBinaryOperation(void *parent,
                                Evaluation::EvalValue *(*func)(void *, Evaluation::EvalValue *),
                                shared_ptr<ScriptType> secondParameter,
                                shared_ptr<ScriptType>  returnType)
                : _parent(parent),  _func(func), _secondParameter(std::move(secondParameter)),
                  _returnType(std::move(returnType)) {}

        Evaluation::EvalValue* Invoke(Evaluation::EvalValue * b) const{
            return _func(_parent, b);
        }

        [[nodiscard]]
        inline shared_ptr<const ScriptType> GetSecondParameterType() const{
            return _secondParameter;
        }

        [[nodiscard]]
        inline shared_ptr<const ScriptType> GetReturnType() const{
            return _returnType;
        }
    };
}


#endif //PORYGONLANG_USERDATAOPERATION_HPP
