xo-interpreter: apply expressions + llvm builtins working!

This commit is contained in:
Roland Conybeare 2025-11-28 19:32:56 -05:00
commit 1d1e72adf3
31 changed files with 531 additions and 50 deletions

View file

@ -56,6 +56,8 @@ namespace xo {
explicit Primitive(std::string_view name,
function_type fn) : PrimitiveBase<Ret (*)(Arg1, Arg2)>{name, fn} {}
/** see also AdoptPrimitiveExpr::adopt() in xo-interpreter/AdoptPrimitiveExpr.hp **/
// inherited from Procedure..
virtual std::size_t n_args() const final override { return 2; }
@ -100,6 +102,7 @@ namespace xo {
make_primitive(gc::IAlloc * mm, std::string_view name, Fn fn) {
return new (MMPtr(mm)) Primitive<Fn>(name, fn);
}
}
}

View file

@ -17,6 +17,9 @@ namespace xo {
**/
class Procedure : public Object {
public:
/** downcast from @p x iff x is actually a Procedure. Otherwise nullptr **/
static gp<Procedure> from(gp<Object> x) { return gp<Procedure>::from(x); }
virtual std::size_t n_args() const = 0;
virtual gp<Object> apply_nocheck(gc::IAlloc * mm, const CVector<gp<Object>> & args) = 0;