diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 8807a72c..6bcbe8bf 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -15,6 +15,7 @@ #include "VsmRcx.hpp" #include "Closure.hpp" #include +#include #include #include #include @@ -914,7 +915,7 @@ namespace xo { static DPrimitive_gco_0 s_cwd_pm("_cwd", &xfer_cwd); - // ----- primitive: fn_nth() ----- + // ----- primitive: nth() ----- // TODO: seq_gc -> obj // n_gco -> obj @@ -934,6 +935,24 @@ namespace xo { static DPrimitive_gco_2_gco_gco s_nth_pm("_nth", &xfer_nth); + // ----- primitive: cons() ----- + + obj + xfer_cons(obj rcx, + obj car, + obj cdr) + { + (void)rcx; + + auto cdr_list = obj::from(cdr); + + return DList::cons(rcx.allocator(), + car, + cdr_list.data()); + } + + static DPrimitive_gco_2_gco_gco s_cons_pm("_cons", &xfer_cons); + // ----- primitive: fn_n_args() ----- obj @@ -1038,6 +1057,18 @@ namespace xo { obj(&s_nth_pm)); } + /* cons */ + { + const DUniqueString * name + = reader_.intern_string("cons"); + + global_env_->_upsert_value + (mm_.to_op(), + name, + Reflect::require(), + obj(&s_cons_pm)); + } + /* fn_n_args */ { const DUniqueString * name diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 21b5faa3..9fb85ffc 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -31,7 +31,7 @@ namespace xo { using xo::scm::DFloat; using xo::scm::DBoolean; using xo::scm::DInteger; - using xo::scm::DRuntimeError; +// using xo::scm::DRuntimeError; using xo::mm::AGCObject; using xo::mm::MemorySizeInfo; using xo::mm::AAllocator;