From c2522466d2fcb5273004f1989b89186cd68001d7 Mon Sep 17 00:00:00 2001 From: Teddy Date: Wed, 14 Aug 2013 00:08:30 +0800 Subject: added gc setting built-ins --- builtin.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'builtin.cpp') diff --git a/builtin.cpp b/builtin.cpp index b983167..2cd738a 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -1515,6 +1515,22 @@ BUILTIN_PROC_DEF(vector_length) { return new IntNumObj(vect->get_size()); } +BUILTIN_PROC_DEF(gc_status) { + if (args != empty_list) + throw TokenError(name, RUN_ERR_WRONG_NUM_OF_ARGS); + return new IntNumObj(gc.get_remaining()); +} + +BUILTIN_PROC_DEF(set_gc_resolve_threshold) { + ARGS_EXACTLY_ONE; + CHECK_NUMBER(args->car); + CHECK_INT(static_cast(args->car)); + ssize_t s = static_cast(args->car)->get_i(); + if (s < 0) + throw TokenError("a non-negative integer", RUN_ERR_WRONG_TYPE); + gc.set_resolve_threshold(size_t(s)); + return new UnspecObj(); +} BUILTIN_PROC_DEF(display) { ARGS_EXACTLY_ONE; -- cgit v1.2.3