summaryrefslogtreecommitdiffhomepage
path: root/mixutils/mixvm_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixutils/mixvm_loop.c')
-rw-r--r--mixutils/mixvm_loop.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/mixutils/mixvm_loop.c b/mixutils/mixvm_loop.c
index 023d82d..f88acfb 100644
--- a/mixutils/mixvm_loop.c
+++ b/mixutils/mixvm_loop.c
@@ -27,6 +27,11 @@
#include <mixlib/mix_vm.h>
#include <mixlib/mix_device.h>
#include <mixlib/mix_vm_dump.h>
+
+#ifdef MAKE_GUILE
+#include <mixguile/mixguile.h>
+#endif
+
#include "mixvm_command.h"
#ifdef HAVE_LIBHISTORY
@@ -80,7 +85,7 @@ rl_gets ()
/* The main command loop of the virtual machine */
static mix_config_t *config_ = NULL;
-static void
+static mix_vm_cmd_dispatcher_t *
init_mixvm_ (const gchar *file, gboolean use_emacs)
{
static const gchar *HISTORY_FILE = "mixvm.history";
@@ -93,18 +98,30 @@ init_mixvm_ (const gchar *file, gboolean use_emacs)
if (mix_config_get_history_size (config_) == 0)
mix_config_set_history_size (config_, HISTORY_SIZE);
- mixvm_cmd_init (config_, (char *)file, use_emacs);
+ return mixvm_cmd_init (config_, (char *)file, use_emacs);
}
-void
-mix_vmloop (const gchar *file, gboolean use_emacs)
+
+static void
+loop_ (int argc, char *argv[])
{
- init_mixvm_ (file, use_emacs);
while ( mixvm_cmd_exec (rl_gets ()) )
;
mix_config_delete (config_);
}
+void
+mix_vmloop (int argc, char *argv[], const gchar *file, gboolean use_emacs)
+{
+#ifdef MAKE_GUILE
+ mix_vm_cmd_dispatcher_t *dis = init_mixvm_ (file, use_emacs);
+ mixguile_init (argc, argv, loop_, dis);
+#else
+ (void) init_mixvm_ (file, use_emacs);
+ loop_ (argc, argv);
+#endif
+}
+
/* run a program and exit */
void
mix_vmrun (const gchar *code_file, gboolean dump)