support function literal, set builtins to global context. great!
This commit is contained in:
19
src/Value/function.cpp
Normal file
19
src/Value/function.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <value.hpp>
|
||||
#include <Value/function.hpp>
|
||||
|
||||
namespace Fig
|
||||
{
|
||||
FunctionStruct::FunctionStruct(std::function<Value(const std::vector<Value> &)> fn,
|
||||
int argc) :
|
||||
id(nextId()),
|
||||
isBuiltin(true),
|
||||
builtin(std::move(fn)),
|
||||
builtinParamCount(argc) {}
|
||||
|
||||
Function::Function(std::function<Value(const std::vector<Value> &)> fn,
|
||||
int argc) :
|
||||
__ValueWrapper(ValueType::Function)
|
||||
{
|
||||
data = std::make_unique<FunctionStruct>(std::move(fn), argc);
|
||||
}
|
||||
}; // namespace Fig
|
||||
Reference in New Issue
Block a user