diff options
Diffstat (limited to 'mixlib')
-rw-r--r-- | mixlib/mix_vm.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/mixlib/mix_vm.c b/mixlib/mix_vm.c index 9816cb5..f41c60a 100644 --- a/mixlib/mix_vm.c +++ b/mixlib/mix_vm.c @@ -22,8 +22,10 @@ #include "mix.h" #include "xmix_vm.h" +#define vm_reset_(vm) vm_reset_reload_ (vm, FALSE); + static void -vm_reset_ (mix_vm_t *vm) +vm_reset_reload_ (mix_vm_t *vm, gboolean is_reload) { guint k; set_rA_ (vm, MIX_WORD_ZERO); @@ -63,7 +65,7 @@ vm_reset_ (mix_vm_t *vm) mix_device_delete (vm->devices[k]); vm->devices[k] = NULL; } - bp_clear_all_ (vm); + if (!is_reload) bp_clear_all_ (vm); } @@ -77,6 +79,7 @@ mix_vm_new (void) vm->line_table = NULL; vm->address_table = NULL; vm->symbol_table = NULL; + vm->src_file = NULL; for (i = 0; i < BD_NO_; ++i) vm->devices[i] = NULL; @@ -297,13 +300,26 @@ gboolean mix_vm_load_file (mix_vm_t *vm, const gchar *name) { mix_code_file_t *file; + mix_src_file_t *sfile = NULL; mix_ins_desc_t ins; const gchar *sp; + gboolean reload = FALSE; g_return_val_if_fail (vm != NULL, FALSE); file = mix_code_file_new_read (name); if (file == NULL) return FALSE; - vm_reset_ (vm); + sp = mix_code_file_get_source_path (file); + + if (sp != NULL) + { + sfile = mix_src_file_new_for_read (sp); + reload = (vm->src_file + && !strcmp (mix_src_file_get_path (vm->src_file), + mix_src_file_get_path (sfile))); + } + + vm_reset_reload_ (vm, reload); + if ( mix_code_file_is_debug (file) ) { vm->symbol_table = mix_code_file_get_symbol_table (file); @@ -311,9 +327,7 @@ mix_vm_load_file (mix_vm_t *vm, const gchar *name) vm->address_table = g_tree_new (cmp_uint_); } - sp = mix_code_file_get_source_path (file); - if (sp != NULL) - vm->src_file = mix_src_file_new_for_read (sp); + vm->src_file = sfile; while ( mix_code_file_get_ins (file, &ins) ) { |