xo-interpreter2 stack: move fn_n_args() to ObjectPrimitives
This commit is contained in:
parent
32b26d1163
commit
42b5cc7aea
3 changed files with 29 additions and 0 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Primitive_gco_0.hpp"
|
#include "Primitive_gco_0.hpp"
|
||||||
|
#include "Primitive_gco_1_gco.hpp"
|
||||||
#include "Primitive_gco_2_gco_gco.hpp"
|
#include "Primitive_gco_2_gco_gco.hpp"
|
||||||
#include "Primitive_gco_3_dict_string_gco.hpp"
|
#include "Primitive_gco_3_dict_string_gco.hpp"
|
||||||
|
|
||||||
|
|
@ -35,6 +36,9 @@ namespace xo {
|
||||||
|
|
||||||
/** create primitive that upserts a key,value pair into a dictionary **/
|
/** create primitive that upserts a key,value pair into a dictionary **/
|
||||||
static DPrimitive_gco_3_dict_string_gco * make_dict_upsert_pm(obj<AAllocator> mm);
|
static DPrimitive_gco_3_dict_string_gco * make_dict_upsert_pm(obj<AAllocator> mm);
|
||||||
|
|
||||||
|
/** create primitive: get fixed number of args for function **/
|
||||||
|
static DPrimitive_gco_1_gco * make_fn_n_args_pm(obj<AAllocator> mm);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,30 @@ namespace xo {
|
||||||
return DPrimitive_gco_3_dict_string_gco::_make(mm, "dict_upsert", &xfer_dict_upsert);
|
return DPrimitive_gco_3_dict_string_gco::_make(mm, "dict_upsert", &xfer_dict_upsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----- fn_n_args -----
|
||||||
|
|
||||||
|
obj<AGCObject>
|
||||||
|
xfer_fn_n_args(obj<ARuntimeContext> rcx,
|
||||||
|
obj<AGCObject> fn_gco)
|
||||||
|
{
|
||||||
|
scope log(XO_DEBUG(true));
|
||||||
|
|
||||||
|
log && log(xtag("fn_gco.tseq", fn_gco._typeseq()));
|
||||||
|
log && log(xtag("fn_gco.tname", TypeRegistry::id2name(fn_gco._typeseq())));
|
||||||
|
|
||||||
|
auto fn_proc = FacetRegistry::instance().try_variant<AProcedure,AGCObject>(fn_gco);
|
||||||
|
|
||||||
|
assert(fn_proc);
|
||||||
|
|
||||||
|
return DInteger::box<AGCObject>(rcx.allocator(), fn_proc.n_args());
|
||||||
|
}
|
||||||
|
|
||||||
|
DPrimitive_gco_1_gco *
|
||||||
|
ObjectPrimitives::make_fn_n_args_pm(obj<AAllocator> mm)
|
||||||
|
{
|
||||||
|
return DPrimitive_gco_1_gco::_make(mm, "fn_n_args", &xfer_fn_n_args);
|
||||||
|
}
|
||||||
|
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ namespace xo {
|
||||||
ok = ok & install_aux(sink, ObjectPrimitives::make_cons_pm(mm), flags);
|
ok = ok & install_aux(sink, ObjectPrimitives::make_cons_pm(mm), flags);
|
||||||
ok = ok & install_aux(sink, ObjectPrimitives::make_dict_make_pm(mm), flags);
|
ok = ok & install_aux(sink, ObjectPrimitives::make_dict_make_pm(mm), flags);
|
||||||
ok = ok & install_aux(sink, ObjectPrimitives::make_dict_upsert_pm(mm), flags);
|
ok = ok & install_aux(sink, ObjectPrimitives::make_dict_upsert_pm(mm), flags);
|
||||||
|
ok = ok & install_aux(sink, ObjectPrimitives::make_fn_n_args_pm(mm), flags);
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue