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
|
|
|
#include "Function.hpp"
|
|
|
|
#include "Value.hpp"
|
|
|
|
|
|
|
|
namespace jk
|
|
|
|
{
|
|
|
|
/*explicit*/ Function::Function(foreign_t foreign)
|
|
|
|
: m_foreign { foreign }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-09-10 07:59:51 +00:00
|
|
|
/*explicit*/ Function::Function(std::shared_ptr<Program> program)
|
|
|
|
: m_program { program }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-09-09 22:03:28 +00:00
|
|
|
/*virtual*/ Function::~Function()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
value_t Function::call(std::vector<value_t> const& args)
|
|
|
|
{
|
2023-09-10 07:59:51 +00:00
|
|
|
if (m_foreign)
|
|
|
|
{
|
|
|
|
return m_foreign(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Value::make_nil();
|
2023-09-09 22:03:28 +00:00
|
|
|
}
|
|
|
|
}
|