From 27d6571f6c147c6d76421ba817114756cd2511ec Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 6 Jun 2004 22:58:58 +0000 Subject: correct error tracking and reporting. --- mixlib/mix_vm.h | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'mixlib/mix_vm.h') diff --git a/mixlib/mix_vm.h b/mixlib/mix_vm.h index b7412bf..005bfc2 100644 --- a/mixlib/mix_vm.h +++ b/mixlib/mix_vm.h @@ -1,22 +1,22 @@ /* ---------------------- mix_vm.h : * Types and functions implementing the MIX virtual machine * ------------------------------------------------------------------ - * Copyright (C) 2000, 2001 Free Software Foundation, Inc. - * + * Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * + * */ @@ -55,7 +55,6 @@ mix_vm_connect_device (mix_vm_t *vm, mix_device_t *device); extern mix_device_t * mix_vm_get_device (const mix_vm_t *vm, mix_device_type_t dev); - /* install a device factory for automatic connection */ typedef mix_device_t * (* mix_device_factory_t) (mix_device_type_t device); extern void @@ -82,19 +81,18 @@ mix_vm_get_rJ(const mix_vm_t *vm); extern mix_short_t mix_vm_get_rI(const mix_vm_t *vm, guint idx); -extern void +extern void mix_vm_set_rA(mix_vm_t *vm, mix_word_t value); extern void mix_vm_set_rX(mix_vm_t *vm, mix_word_t value); -extern void +extern void mix_vm_set_rJ(mix_vm_t *vm, mix_short_t value); -extern void +extern void mix_vm_set_rI(mix_vm_t *vm, guint idx, mix_short_t value); - /* Access to the comparison flag and overflow toggle */ extern mix_cmpflag_t mix_vm_get_cmpflag(const mix_vm_t *vm); @@ -125,7 +123,7 @@ mix_vm_set_addr_contents(mix_vm_t *vm, mix_address_t addr, mix_word_t value); extern gboolean /* TRUE if success */ mix_vm_exec_ins(mix_vm_t *vm, const mix_ins_t *ins); -/* Load a code file into memory (-name- does not need the default extension) +/* Load a code file into memory (-name- does not need the default extension) * resetting the vm's state */ extern gboolean @@ -140,7 +138,7 @@ extern const mix_symbol_table_t * mix_vm_get_symbol_table (const mix_vm_t *vm); /* Get current program counter */ -extern mix_address_t +extern mix_address_t mix_vm_get_prog_count (const mix_vm_t *vm); /* Get the source line number for a given address */ @@ -163,6 +161,28 @@ typedef enum { MIX_VM_EMPTY /* no program loaded */ } mix_vm_status_t; +/* execution errors */ +typedef enum { + MIX_VM_ERROR_NONE, /* no error */ + MIX_VM_ERROR_BAD_ACCESS, /* bad memory address */ + MIX_VM_ERROR_BAD_DEVICE_NO, /* bad device number */ + MIX_VM_ERROR_BAD_FSPEC, /* invalid fspec */ + MIX_VM_ERROR_BAD_M, /* invalid M-value */ + MIX_VM_ERROR_DEV_CTL, /* error accessing device for ioctl */ + MIX_VM_ERROR_DEV_READ, /* error accessing device for reading */ + MIX_VM_ERROR_DEV_WRITE, /* error accessing device for writing */ + MIX_VM_ERROR_UNEXPECTED /* unexpected error */ +} mix_vm_error_t; + +extern mix_vm_error_t +mix_vm_get_last_error (const mix_vm_t *vm); + +extern const gchar * +mix_vm_get_last_error_string (const mix_vm_t *vm); + +extern const gchar * +mix_vm_get_error_string (mix_vm_error_t code); + /* run until next breakpoint or end of execution */ extern mix_vm_status_t mix_vm_run (mix_vm_t *vm); @@ -190,6 +210,7 @@ enum { MIX_VM_BP_OK = 0 /* success */ }; + extern gint /* if >0 the line no. of the break point */ mix_vm_set_breakpoint (mix_vm_t *vm, guint lineno); -- cgit v1.2.3