summaryrefslogtreecommitdiffhomepage
path: root/mixutils
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2001-07-19 00:24:23 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2001-07-19 00:24:23 +0000
commit9d46df7ae76533833c26df9f0b0bf24e086c25b2 (patch)
tree83c0375e6d4345a16035f7f756a156142e7e6e64 /mixutils
parentb18af386c53f81e31f98a1c1b699666ec69a7aa4 (diff)
downloadmdk-9d46df7ae76533833c26df9f0b0bf24e086c25b2.tar.gz
mdk-9d46df7ae76533833c26df9f0b0bf24e086c25b2.tar.bz2
cond bp support
Diffstat (limited to 'mixutils')
-rw-r--r--mixutils/mixvm_loop.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/mixutils/mixvm_loop.c b/mixutils/mixvm_loop.c
index f9672e8..023d82d 100644
--- a/mixutils/mixvm_loop.c
+++ b/mixutils/mixvm_loop.c
@@ -78,42 +78,41 @@ rl_gets ()
/* The main command loop of the virtual machine */
-void
-mix_vmloop (const gchar *file, gboolean use_emacs)
+static mix_config_t *config_ = NULL;
+
+static void
+init_mixvm_ (const gchar *file, gboolean use_emacs)
{
static const gchar *HISTORY_FILE = "mixvm.history";
static gint HISTORY_SIZE = 100;
- mix_config_t *config = mix_config_new (NULL, CONFIG_FILE_);
+ config_ = mix_config_new (NULL, CONFIG_FILE_);
- mix_config_set_autosave (config, TRUE);
- if (!mix_config_get_history_file (config))
- mix_config_set_history_file (config, HISTORY_FILE);
- if (mix_config_get_history_size (config) == 0)
- mix_config_set_history_size (config, HISTORY_SIZE);
+ mix_config_set_autosave (config_, TRUE);
+ if (!mix_config_get_history_file (config_))
+ mix_config_set_history_file (config_, HISTORY_FILE);
+ if (mix_config_get_history_size (config_) == 0)
+ mix_config_set_history_size (config_, HISTORY_SIZE);
- mixvm_cmd_init (config, (char *)file, use_emacs);
+ mixvm_cmd_init (config_, (char *)file, use_emacs);
+}
+
+void
+mix_vmloop (const gchar *file, gboolean use_emacs)
+{
+ init_mixvm_ (file, use_emacs);
while ( mixvm_cmd_exec (rl_gets ()) )
;
- if (config) mix_config_delete (config);
+ mix_config_delete (config_);
}
/* run a program and exit */
void
mix_vmrun (const gchar *code_file, gboolean dump)
{
- mix_vm_t *vm = mix_vm_new ();
- if (!mix_vm_load_file (vm, code_file)) {
- fprintf (stderr, _("Error loading %s file\n"), code_file);
- return;
- }
- mix_vm_run (vm);
- printf (_("** Execution time: %ld\n"), mix_vm_get_uptime (vm));
- if (dump) {
- mix_dump_context_t *dc = mix_dump_context_new (MIX_DUMP_DEF_CHANNEL,
- 0, 0,
- MIX_DUMP_ALL_NOMEM);
- mix_vm_dump (vm, dc);
- mix_dump_context_delete (dc);
- }
- mix_vm_delete (vm);
+ gboolean result;
+
+ init_mixvm_ (code_file, FALSE);
+ result = mixvm_cmd_exec (g_strdup ("run"));
+ if (result && dump) mixvm_cmd_exec (g_strdup ("pall"));
+ mix_config_delete (config_);
}