Commit | Line | Data |
---|---|---|
02aa5a4c MD |
1 | /* classes: h_files */ |
2 | ||
13dcb666 DH |
3 | #ifndef SCM_STACKS_H |
4 | #define SCM_STACKS_H | |
b29058ff | 5 | |
102dbb6f | 6 | /* Copyright (C) 1995,1996,2000,2001, 2004, 2006, 2008 Free Software Foundation, Inc. |
b29058ff | 7 | * |
73be1d9e MV |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2.1 of the License, or (at your option) any later version. | |
b29058ff | 12 | * |
73be1d9e | 13 | * This library is distributed in the hope that it will be useful, |
02aa5a4c | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
b29058ff | 17 | * |
73be1d9e MV |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software | |
92205699 | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
73be1d9e | 21 | */ |
d3a6bc94 | 22 | |
02aa5a4c MD |
23 | \f |
24 | ||
25 | #include "libguile/__scm.h" | |
26 | ||
27 | /* {Frames and stacks} | |
28 | */ | |
29 | ||
92c2555f | 30 | typedef struct scm_t_info_frame { |
7febb4a2 | 31 | /* SCM flags; */ |
92c2555f | 32 | scm_t_bits flags; |
02aa5a4c MD |
33 | SCM source; |
34 | SCM proc; | |
35 | SCM args; | |
92c2555f MV |
36 | } scm_t_info_frame; |
37 | #define SCM_FRAME_N_SLOTS (sizeof (scm_t_info_frame) / sizeof (SCM)) | |
02aa5a4c | 38 | |
92c2555f | 39 | #define SCM_STACK(obj) ((scm_t_stack *) SCM_STRUCT_DATA (obj)) |
3119346c | 40 | #define SCM_STACK_LAYOUT "pwuourpW" |
92c2555f | 41 | typedef struct scm_t_stack { |
b902ec85 | 42 | SCM id; /* Stack id */ |
92c2555f | 43 | scm_t_info_frame *frames; /* Info frames */ |
c014a02e ML |
44 | unsigned long length; /* Stack length */ |
45 | unsigned long tail_length; | |
92c2555f MV |
46 | scm_t_info_frame tail[1]; |
47 | } scm_t_stack; | |
1be6b49c | 48 | |
762e289a | 49 | SCM_API SCM scm_stack_type; |
b902ec85 | 50 | |
bc36d050 | 51 | #define SCM_STACKP(obj) (SCM_STRUCTP (obj) && scm_is_eq (SCM_STRUCT_VTABLE (obj), scm_stack_type)) |
c692c370 | 52 | #define SCM_STACK_LENGTH(stack) (SCM_STACK (stack) -> length) |
02aa5a4c | 53 | |
13dcb666 | 54 | #define SCM_FRAMEP(obj) \ |
d2e53ed6 | 55 | (scm_is_pair (obj) && SCM_STACKP (SCM_CAR (obj)) \ |
e11e83f3 MV |
56 | && scm_is_unsigned_integer (SCM_CDR (obj), \ |
57 | 0, SCM_STACK_LENGTH (SCM_CAR (obj))-1)) | |
b902ec85 MD |
58 | |
59 | #define SCM_FRAME_REF(frame, slot) \ | |
e11e83f3 | 60 | (SCM_STACK (SCM_CAR (frame)) -> frames[scm_to_size_t (SCM_CDR (frame))].slot) |
b902ec85 MD |
61 | |
62 | #define SCM_FRAME_NUMBER(frame) \ | |
63 | (SCM_BACKWARDS_P \ | |
e11e83f3 | 64 | ? scm_to_size_t (SCM_CDR (frame)) \ |
b902ec85 | 65 | : (SCM_STACK_LENGTH (SCM_CAR (frame)) \ |
e11e83f3 | 66 | - scm_to_size_t (SCM_CDR (frame)) \ |
b902ec85 MD |
67 | - 1)) \ |
68 | ||
69 | #define SCM_FRAME_FLAGS(frame) SCM_FRAME_REF (frame, flags) | |
70 | #define SCM_FRAME_SOURCE(frame) SCM_FRAME_REF (frame, source) | |
71 | #define SCM_FRAME_PROC(frame) SCM_FRAME_REF (frame, proc) | |
72 | #define SCM_FRAME_ARGS(frame) SCM_FRAME_REF (frame, args) | |
02aa5a4c MD |
73 | #define SCM_FRAME_PREV(frame) scm_frame_previous (frame) |
74 | #define SCM_FRAME_NEXT(frame) scm_frame_next (frame) | |
75 | ||
76 | #define SCM_FRAMEF_VOID (1L << 2) | |
77 | #define SCM_FRAMEF_REAL (1L << 3) | |
78 | #define SCM_FRAMEF_PROC (1L << 4) | |
79 | #define SCM_FRAMEF_EVAL_ARGS (1L << 5) | |
80 | #define SCM_FRAMEF_OVERFLOW (1L << 6) | |
81 | ||
451e591c DH |
82 | #define SCM_FRAME_VOID_P(f) (SCM_FRAME_FLAGS (f) & SCM_FRAMEF_VOID) |
83 | #define SCM_FRAME_REAL_P(f) (SCM_FRAME_FLAGS (f) & SCM_FRAMEF_REAL) | |
84 | #define SCM_FRAME_PROC_P(f) (SCM_FRAME_FLAGS (f) & SCM_FRAMEF_PROC) | |
85 | #define SCM_FRAME_EVAL_ARGS_P(f) (SCM_FRAME_FLAGS (f) & SCM_FRAMEF_EVAL_ARGS) | |
86 | #define SCM_FRAME_OVERFLOW_P(f) (SCM_FRAME_FLAGS (f) & SCM_FRAMEF_OVERFLOW) | |
02aa5a4c MD |
87 | |
88 | \f | |
89 | ||
33b001fd MV |
90 | SCM_API SCM scm_stack_p (SCM obj); |
91 | SCM_API SCM scm_make_stack (SCM obj, SCM args); | |
92 | SCM_API SCM scm_stack_id (SCM stack); | |
93 | SCM_API SCM scm_stack_ref (SCM stack, SCM i); | |
94 | SCM_API SCM scm_stack_length (SCM stack); | |
95 | ||
96 | SCM_API SCM scm_frame_p (SCM obj); | |
97 | SCM_API SCM scm_last_stack_frame (SCM obj); | |
98 | SCM_API SCM scm_frame_number (SCM frame); | |
99 | SCM_API SCM scm_frame_source (SCM frame); | |
100 | SCM_API SCM scm_frame_procedure (SCM frame); | |
101 | SCM_API SCM scm_frame_arguments (SCM frame); | |
102 | SCM_API SCM scm_frame_previous (SCM frame); | |
103 | SCM_API SCM scm_frame_next (SCM frame); | |
104 | SCM_API SCM scm_frame_real_p (SCM frame); | |
105 | SCM_API SCM scm_frame_procedure_p (SCM frame); | |
106 | SCM_API SCM scm_frame_evaluating_args_p (SCM frame); | |
107 | SCM_API SCM scm_frame_overflow_p (SCM frame); | |
108 | ||
102dbb6f | 109 | SCM_INTERNAL void scm_init_stacks (void); |
02aa5a4c | 110 | |
b29058ff | 111 | #endif /* SCM_STACKS_H */ |
89e00824 ML |
112 | |
113 | /* | |
114 | Local Variables: | |
115 | c-file-style: "gnu" | |
116 | End: | |
117 | */ |