#ifdef BUILDING_LIBGUILE
#define FOR_EACH_VM_BUILTIN(M) \
- M(apply, APPLY) \
- M(values, VALUES) \
- M(abort_to_prompt, ABORT_TO_PROMPT) \
- M(call_with_values, CALL_WITH_VALUES) \
- M(call_with_current_continuation, CALL_WITH_CURRENT_CONTINUATION)
+ M(apply, APPLY, 2, 0, 1) \
+ M(values, VALUES, 0, 0, 1) \
+ M(abort_to_prompt, ABORT_TO_PROMPT, 1, 0, 1) \
+ M(call_with_values, CALL_WITH_VALUES, 2, 0, 0) \
+ M(call_with_current_continuation, CALL_WITH_CURRENT_CONTINUATION, 1, 0, 0)
/* These enumerated values are embedded in RTL code, and as such are
part of Guile's ABI. */
enum scm_vm_builtins
{
-#define ENUM(builtin, BUILTIN) SCM_VM_BUILTIN_##BUILTIN,
+#define ENUM(builtin, BUILTIN, req, opt, rest) SCM_VM_BUILTIN_##BUILTIN,
FOR_EACH_VM_BUILTIN(ENUM)
#undef ENUM
SCM_VM_BUILTIN_COUNT
SCM_INTERNAL SCM scm_vm_builtin_name_to_index (SCM name);
SCM_INTERNAL SCM scm_vm_builtin_index_to_name (SCM idx);
+SCM_INTERNAL void scm_init_vm_builtin_properties (void);
#endif /* BUILDING_LIBGUILE */
{
switch (idx)
{
-#define INDEX_TO_NAME(builtin, BUILTIN) \
+#define INDEX_TO_NAME(builtin, BUILTIN, req, opt, rest) \
case SCM_VM_BUILTIN_##BUILTIN: return vm_builtin_##builtin;
FOR_EACH_VM_BUILTIN(INDEX_TO_NAME)
#undef INDEX_TO_NAME
}
}
+SCM scm_sym_apply;
static SCM scm_sym_values;
static SCM scm_sym_abort_to_prompt;
static SCM scm_sym_call_with_values;
{
SCM_VALIDATE_SYMBOL (1, name);
-#define NAME_TO_INDEX(builtin, BUILTIN) \
+#define NAME_TO_INDEX(builtin, BUILTIN, req, opt, rest) \
if (scm_is_eq (name, scm_sym_##builtin)) \
return scm_from_uint (SCM_VM_BUILTIN_##BUILTIN);
FOR_EACH_VM_BUILTIN(NAME_TO_INDEX)
switch (idx)
{
-#define INDEX_TO_NAME(builtin, BUILTIN) \
+#define INDEX_TO_NAME(builtin, BUILTIN, req, opt, rest) \
case SCM_VM_BUILTIN_##BUILTIN: return scm_sym_##builtin;
FOR_EACH_VM_BUILTIN(INDEX_TO_NAME)
#undef INDEX_TO_NAME
static void
scm_init_vm_builtins (void)
{
- scm_sym_values = scm_from_utf8_symbol ("values");
- scm_sym_abort_to_prompt = scm_from_utf8_symbol ("abort-to-prompt");
- scm_sym_call_with_values = scm_from_utf8_symbol ("call-with-values");
- scm_sym_call_with_current_continuation =
- scm_from_utf8_symbol ("call-with-current-continuation");
-
scm_c_define_gsubr ("builtin-name->index", 1, 0, 0,
scm_vm_builtin_name_to_index);
scm_c_define_gsubr ("builtin-index->name", 1, 0, 0,
return ret;
}
+void
+scm_init_vm_builtin_properties (void)
+{
+ /* FIXME: Seems hacky to do this here, but oh well :/ */
+ scm_sym_apply = scm_from_utf8_symbol ("apply");
+ scm_sym_values = scm_from_utf8_symbol ("values");
+ scm_sym_abort_to_prompt = scm_from_utf8_symbol ("abort-to-prompt");
+ scm_sym_call_with_values = scm_from_utf8_symbol ("call-with-values");
+ scm_sym_call_with_current_continuation =
+ scm_from_utf8_symbol ("call-with-current-continuation");
+
+#define INIT_BUILTIN(builtin, BUILTIN, req, opt, rest) \
+ scm_set_procedure_property_x (vm_builtin_##builtin, scm_sym_name, \
+ scm_sym_##builtin); \
+ scm_set_procedure_minimum_arity_x (vm_builtin_##builtin, \
+ SCM_I_MAKINUM (req), \
+ SCM_I_MAKINUM (opt), \
+ scm_from_bool (rest));
+ FOR_EACH_VM_BUILTIN (INIT_BUILTIN);
+#undef INIT_BUILTIN
+}
+
void
scm_bootstrap_vm (void)
{
SCM_SET_CELL_WORD_0 (rtl_boot_continuation,
(SCM_CELL_WORD_0 (rtl_boot_continuation)
| SCM_F_PROGRAM_IS_BOOT));
- vm_builtin_apply = scm_i_make_rtl_program (vm_builtin_apply_code);
- vm_builtin_values = scm_i_make_rtl_program (vm_builtin_values_code);
- vm_builtin_abort_to_prompt =
- scm_i_make_rtl_program (vm_builtin_abort_to_prompt_code);
- vm_builtin_call_with_values =
- scm_i_make_rtl_program (vm_builtin_call_with_values_code);
- vm_builtin_call_with_current_continuation =
- scm_i_make_rtl_program (vm_builtin_call_with_current_continuation_code);
+
+#define DEFINE_BUILTIN(builtin, BUILTIN, req, opt, rest) \
+ vm_builtin_##builtin = scm_i_make_rtl_program (vm_builtin_##builtin##_code);
+ FOR_EACH_VM_BUILTIN (DEFINE_BUILTIN);
+#undef DEFINE_BUILTIN
#ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
vm_stack_gc_kind =