2019-06-27 14:48:19 +00:00
|
|
|
|
|
|
|
#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<ScriptType> _secondParameter;
|
|
|
|
const shared_ptr<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);
|
|
|
|
}
|
|
|
|
|
2019-07-04 17:08:13 +00:00
|
|
|
inline const shared_ptr<ScriptType> GetSecondParameterType() const{
|
2019-06-27 14:48:19 +00:00
|
|
|
return _secondParameter;
|
|
|
|
}
|
|
|
|
|
2019-07-04 17:08:13 +00:00
|
|
|
inline const shared_ptr<ScriptType> GetReturnType() const{
|
2019-06-27 14:48:19 +00:00
|
|
|
return _returnType;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif //PORYGONLANG_USERDATAOPERATION_HPP
|