From 17e3178a5bd5da2e731f11eba3cbcca98d179470 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 6 Apr 2018 23:25:23 -0700 Subject: vm: allow vm description to be callable as function. * lib.c (generic_funall): Handle vm-desc objects via vm_execute_toplevel. * vm.h (vm_desc_s, vm_closure_s): Declared. --- lib.c | 4 ++++ vm.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib.c b/lib.c index 980fe768..7219d2d2 100644 --- a/lib.c +++ b/lib.c @@ -6253,6 +6253,10 @@ val generic_funcall(val fun, struct args *args_in) default: callerror(fun, lit("too many arguments")); } + } else if (fun->co.cls == vm_desc_s) { + if (args->fill || args->list) + callerror(fun, lit("too many arguments")); + return vm_execute_toplevel(fun); } else if (fun->co.cls == carray_s) { goto carray; } else if (obj_struct_p(fun)) { diff --git a/vm.h b/vm.h index 1a8a1c8e..da2fab08 100644 --- a/vm.h +++ b/vm.h @@ -25,6 +25,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +extern val vm_desc_s, vm_closure_s; + val vm_make_desc(val nlevels, val nregs, val bytecode, val datavec, val funvec); val vm_execute_toplevel(val desc); -- cgit v1.2.3