1 /* Copyright (C) 2001 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <libguile/programs.h>
24 #define SCM_VM_BOOT_HOOK 0
25 #define SCM_VM_HALT_HOOK 1
26 #define SCM_VM_NEXT_HOOK 2
27 #define SCM_VM_BREAK_HOOK 3
28 #define SCM_VM_ENTER_HOOK 4
29 #define SCM_VM_APPLY_HOOK 5
30 #define SCM_VM_EXIT_HOOK 6
31 #define SCM_VM_RETURN_HOOK 7
32 #define SCM_VM_NUM_HOOKS 8
36 typedef SCM (*scm_t_vm_engine
) (struct scm_vm
*vp
, SCM program
, SCM
*argv
, int nargs
);
38 #define SCM_VM_REGULAR_ENGINE 0
39 #define SCM_VM_DEBUG_ENGINE 1
40 #define SCM_VM_NUM_ENGINES 2
43 scm_byte_t
*ip
; /* instruction pointer */
44 SCM
*sp
; /* stack pointer */
45 SCM
*fp
; /* frame pointer */
46 size_t stack_size
; /* stack size */
47 SCM
*stack_base
; /* stack base address */
48 SCM
*stack_limit
; /* stack limit address */
49 int engine
; /* which vm engine we're using */
50 SCM hooks
[SCM_VM_NUM_HOOKS
]; /* hooks */
51 SCM options
; /* options */
52 unsigned long time
; /* time spent */
53 unsigned long clock
; /* bogos clock */
54 SCM trace_frame
; /* a frame being traced */
57 SCM_API SCM scm_the_vm_fluid
;
59 #define SCM_VM_P(x) SCM_SMOB_PREDICATE (scm_tc16_vm, x)
60 #define SCM_VM_DATA(vm) ((struct scm_vm *) SCM_SMOB_DATA (vm))
61 #define SCM_VALIDATE_VM(pos,x) SCM_MAKE_VALIDATE (pos, x, VM_P)
63 SCM_API SCM
scm_the_vm ();
64 SCM_API SCM
scm_make_vm (void);
65 SCM_API SCM
scm_vm_apply (SCM vm
, SCM program
, SCM args
);
66 SCM_API SCM
scm_c_vm_run (SCM vm
, SCM program
, SCM
*argv
, int nargs
);
67 SCM_API SCM
scm_vm_option_ref (SCM vm
, SCM key
);
68 SCM_API SCM
scm_vm_option_set_x (SCM vm
, SCM key
, SCM val
);
70 SCM_API SCM
scm_vm_version (void);
71 SCM_API SCM
scm_the_vm (void);
72 SCM_API SCM
scm_vm_p (SCM obj
);
73 SCM_API SCM
scm_vm_ip (SCM vm
);
74 SCM_API SCM
scm_vm_sp (SCM vm
);
75 SCM_API SCM
scm_vm_fp (SCM vm
);
76 SCM_API SCM
scm_vm_boot_hook (SCM vm
);
77 SCM_API SCM
scm_vm_halt_hook (SCM vm
);
78 SCM_API SCM
scm_vm_next_hook (SCM vm
);
79 SCM_API SCM
scm_vm_break_hook (SCM vm
);
80 SCM_API SCM
scm_vm_enter_hook (SCM vm
);
81 SCM_API SCM
scm_vm_apply_hook (SCM vm
);
82 SCM_API SCM
scm_vm_exit_hook (SCM vm
);
83 SCM_API SCM
scm_vm_return_hook (SCM vm
);
84 SCM_API SCM
scm_vm_option (SCM vm
, SCM key
);
85 SCM_API SCM
scm_set_vm_option_x (SCM vm
, SCM key
, SCM val
);
86 SCM_API SCM
scm_vm_stats (SCM vm
);
87 SCM_API SCM
scm_vm_trace_frame (SCM vm
);
93 scm_t_ptrdiff stack_size
;
98 SCM_API scm_t_bits scm_tc16_vm_cont
;
99 #define SCM_VM_CONT_P(OBJ) SCM_SMOB_PREDICATE (scm_tc16_vm_cont, OBJ)
100 #define SCM_VM_CONT_DATA(CONT) ((struct scm_vm_cont *) SCM_CELL_WORD_1 (CONT))
102 SCM_API SCM
scm_vm_capture_continuations (void);
103 SCM_API
void scm_vm_reinstate_continuations (SCM conts
);
105 SCM_API SCM
scm_load_compiled_with_vm (SCM file
);
107 SCM_INTERNAL
void scm_init_vm (void);
109 #endif /* _SCM_VM_H_ */