3
$Id: step.c,v 9.34 1999/01/02 06:11:34 cph Exp $
5
Copyright (c) 1987-1999 Massachusetts Institute of Technology
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or (at
10
your option) any later version.
12
This program is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
/* Support for the stepper */
27
/**********************************/
28
/* Support of stepping primitives */
29
/**********************************/
31
/* UGLY ... this knows (a) that it is called with the primitive frame
32
already popped off the stack; and (b) the order in which Save_Cont
33
stores things on the stack.
37
DEFUN (Install_Traps, (Hunk3), SCHEME_OBJECT Hunk3)
39
SCHEME_OBJECT Eval_Hook, Apply_Hook, Return_Hook;
42
Eval_Hook = MEMORY_REF (Hunk3, HUNK_CXR0);
43
Apply_Hook = MEMORY_REF (Hunk3, HUNK_CXR1);
44
Return_Hook = MEMORY_REF (Hunk3, HUNK_CXR2);
45
Set_Fixed_Obj_Slot(Stepper_State, Hunk3);
46
Trapping = ((Eval_Hook != SHARP_F) |
47
(Apply_Hook != SHARP_F) |
48
(Return_Hook != SHARP_F));
52
/* (PRIMITIVE-EVAL-STEP EXPRESSION ENV HUNK3)
53
Evaluates EXPRESSION in ENV and intalls the eval-trap,
54
apply-trap, and return-trap from HUNK3. If any
55
trap is #F, it is a null trap that does a normal EVAL,
59
DEFINE_PRIMITIVE ("PRIMITIVE-EVAL-STEP", Prim_eval_step, 3, 3, 0)
62
CHECK_ARG (3, HUNK3_P);
64
SCHEME_OBJECT expression = (ARG_REF (1));
65
SCHEME_OBJECT environment = (ARG_REF (2));
66
SCHEME_OBJECT hooks = (ARG_REF (3));
67
PRIMITIVE_CANONICALIZE_CONTEXT ();
68
POP_PRIMITIVE_FRAME (3);
69
Install_Traps (hooks);
70
Store_Expression (expression);
71
Store_Env (environment);
73
PRIMITIVE_ABORT (PRIM_NO_TRAP_EVAL);
75
PRIMITIVE_RETURN (UNSPECIFIC);
78
/* (PRIMITIVE-APPLY-STEP OPERATOR OPERANDS HUNK3)
79
Applies OPERATOR to OPERANDS and intalls the eval-trap,
80
apply-trap, and return-trap from HUNK3. If any
81
trap is #F, it is a null trap that does a normal EVAL,
84
Mostly a copy of Prim_Apply, since this, too, must count the space
85
required before actually building a frame */
87
DEFINE_PRIMITIVE ("PRIMITIVE-APPLY-STEP", Prim_apply_step, 3, 3, 0)
90
PRIMITIVE_CANONICALIZE_CONTEXT ();
91
CHECK_ARG (3, HUNK3_P);
93
SCHEME_OBJECT hooks = (ARG_REF (3));
94
fast long number_of_args = 0;
96
SCHEME_OBJECT procedure = (ARG_REF (1));
97
SCHEME_OBJECT argument_list = (ARG_REF (2));
99
fast SCHEME_OBJECT scan_list;
100
TOUCH_IN_PRIMITIVE (argument_list, scan_list);
101
while (PAIR_P (scan_list))
104
TOUCH_IN_PRIMITIVE ((PAIR_CDR (scan_list)), scan_list);
106
if (scan_list != EMPTY_LIST)
107
error_wrong_type_arg (2);
109
POP_PRIMITIVE_FRAME (3);
110
Install_Traps (hooks);
112
fast SCHEME_OBJECT * scan_stack = (STACK_LOC (- number_of_args));
113
fast SCHEME_OBJECT scan_list;
115
Will_Push (number_of_args + STACK_ENV_EXTRA_SLOTS + 1);
116
Stack_Pointer = scan_stack;
117
TOUCH_IN_PRIMITIVE (argument_list, scan_list);
118
for (i = number_of_args; (i > 0); i -= 1)
120
(*scan_stack++) = (PAIR_CAR (scan_list));
121
TOUCH_IN_PRIMITIVE ((PAIR_CDR (scan_list)), scan_list);
123
STACK_PUSH (procedure);
124
STACK_PUSH (STACK_FRAME_HEADER + number_of_args);
129
PRIMITIVE_ABORT (PRIM_NO_TRAP_APPLY);
131
PRIMITIVE_RETURN (UNSPECIFIC);
134
/* (PRIMITIVE-RETURN-STEP VALUE HUNK3)
135
Returns VALUE and intalls the eval-trap, apply-trap, and
136
return-trap from HUNK3. If any trap is #F, it is a null trap
137
that does a normal EVAL, APPLY or return.
140
DEFINE_PRIMITIVE ("PRIMITIVE-RETURN-STEP", Prim_return_step, 2, 2, 0)
142
PRIMITIVE_HEADER (2);
143
PRIMITIVE_CANONICALIZE_CONTEXT ();
144
CHECK_ARG (2, HUNK3_P);
146
SCHEME_OBJECT value = (ARG_REF (1));
147
SCHEME_OBJECT hooks = (ARG_REF (2));
149
POP_PRIMITIVE_FRAME (2);
150
Install_Traps (hooks);
152
PRIMITIVE_ABORT (PRIM_NO_TRAP_POP_RETURN);
153
PRIMITIVE_RETURN (UNSPECIFIC);