This repository has been archived on 2023-09-10. You can view files and clone it, but cannot push or open issues/pull-requests.
joko/lib/Function.hpp

33 lines
605 B
C++
Raw Normal View History

2023-09-09 22:03:28 +00:00
#ifndef jk_FUNCTION_HPP
#define jk_FUNCTION_HPP
#include "commons.hpp"
#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);
explicit Function(std::shared_ptr<Program> program);
2023-09-09 22:03:28 +00:00
virtual ~Function();
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;
std::shared_ptr<Program> m_program;
2023-09-09 22:03:28 +00:00
};
}
#endif