This repository has been archived on 2023-09-10. You can view files and clone it, but cannot push or open issues/pull-requests.
2023-09-09 22:03:28 +00:00
|
|
|
#ifndef jk_FUNCTION_HPP
|
|
|
|
#define jk_FUNCTION_HPP
|
|
|
|
|
|
|
|
#include "commons.hpp"
|
2023-09-10 07:59:51 +00:00
|
|
|
#include "Program.hpp"
|
2023-09-09 22:03:28 +00:00
|
|
|
|
|
|
|
namespace jk
|
|
|
|
{
|
|
|
|
class Value;
|
|
|
|
|
|
|
|
using value_t = std::shared_ptr<Value>;
|
|
|
|
using foreign_t = std::function<value_t(std::vector<value_t>)>;
|
|
|
|
|
|
|
|
class Function
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit Function(foreign_t foreign);
|
2023-09-10 07:59:51 +00:00
|
|
|
explicit Function(std::shared_ptr<Program> program);
|
|
|
|
|
2023-09-09 22:03:28 +00:00
|
|
|
virtual ~Function();
|
|
|
|
|
2023-09-10 07:59:51 +00:00
|
|
|
std::shared_ptr<Program> program() const { return m_program; }
|
|
|
|
|
2023-09-09 22:03:28 +00:00
|
|
|
value_t call(std::vector<value_t> const& args);
|
|
|
|
|
|
|
|
private:
|
|
|
|
foreign_t m_foreign;
|
2023-09-10 07:59:51 +00:00
|
|
|
std::shared_ptr<Program> m_program;
|
2023-09-09 22:03:28 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|