support function literal, set builtins to global context. great!

This commit is contained in:
2025-12-20 20:27:36 +08:00
parent b9a98150ae
commit e7ca714a89
19 changed files with 362 additions and 502 deletions

19
src/Value/function.cpp Normal file
View 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