xo-interpreter: apply expressions + llvm builtins working!
This commit is contained in:
parent
7ca1366bec
commit
1d1e72adf3
31 changed files with 531 additions and 50 deletions
|
|
@ -4,14 +4,16 @@
|
|||
**/
|
||||
|
||||
#include "BuiltinPrimitives.hpp"
|
||||
#include "ObjectConversion.hpp"
|
||||
#include "Integer.hpp"
|
||||
#include "Primitive.hpp"
|
||||
#include "xo/expression/PrimitiveExpr.hpp"
|
||||
#include "xo/object/ObjectConversion.hpp"
|
||||
#include "xo/reflect/Reflect.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
using xo::reflect::Reflect;
|
||||
using xo::reflect::TaggedPtr;
|
||||
using xo::reflect::TypeDescr;
|
||||
|
||||
namespace scm {
|
||||
|
|
@ -21,6 +23,12 @@ namespace xo {
|
|||
return x + y;
|
||||
}
|
||||
|
||||
void
|
||||
BuiltinPrimitives::install_interpreter_conversions(ObjectConverter * /*target*/)
|
||||
{
|
||||
/* abandoning this path */
|
||||
}
|
||||
|
||||
void
|
||||
BuiltinPrimitives::install(gc::IAlloc * mm, gp<GlobalEnv> env)
|
||||
{
|
||||
|
|
@ -29,12 +37,26 @@ namespace xo {
|
|||
// add(x,y)
|
||||
{
|
||||
gp<Object> rhs = xo::obj::make_primitive(mm, "add", add64);
|
||||
TypeDescr td = Reflect::require<decltype(add64)>();
|
||||
|
||||
TypeDescr td = Reflect::require_function<decltype(&add64)>();
|
||||
|
||||
rp<Variable> lhs = Variable::make("add", td);
|
||||
gp<Object> * addr = env->establish_var(lhs.borrow());
|
||||
|
||||
*addr = rhs;
|
||||
}
|
||||
|
||||
// add2_i64
|
||||
{
|
||||
auto pm_expr = PrimitiveExpr_i64::make_add2_i64();
|
||||
|
||||
gp<Object> rhs = xo::obj::make_primitive(mm, pm_expr->name(), pm_expr->value());
|
||||
|
||||
rp<Variable> lhs = Variable::make(pm_expr->name(), pm_expr->value_td());
|
||||
gp<Object> * addr = env->establish_var(lhs.borrow());
|
||||
|
||||
*addr = rhs;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue