mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-17 06:42:18 -08:00
Introduce ECL_STACK_INDEX macro
This commit is contained in:
parent
80127a2f01
commit
8fe85d2e7c
8 changed files with 12 additions and 20 deletions
|
|
@ -59,9 +59,9 @@
|
|||
|
||||
/********************* PRIVATE ********************/
|
||||
|
||||
#define asm_begin() ecl_stack_index(ecl_process_env())
|
||||
#define asm_begin() current_pc()
|
||||
#define asm_clear(h) ecl_stack_set_index(ecl_process_env(), h)
|
||||
#define current_pc() ecl_stack_index(ecl_process_env())
|
||||
#define current_pc() ECL_STACK_INDEX(ecl_process_env())
|
||||
#define set_pc(n) ecl_stack_set_index(ecl_process_env(), n)
|
||||
#define asm_op(o) ecl_stack_push(ecl_process_env(), (cl_object)((cl_fixnum)(o)))
|
||||
#define asm_ref(n) (cl_fixnum)(ecl_process_env()->stack[n])
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ FEstack_advance(void)
|
|||
FEerror("Internal error: stack advance beyond current point.",0);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ecl_stack_grow(cl_env_ptr env)
|
||||
{
|
||||
ecl_stack_set_size(env, env->stack_size + env->stack_size / 2);
|
||||
|
|
@ -86,13 +86,6 @@ ecl_stack_pop(cl_env_ptr env) {
|
|||
return *(--env->stack_top);
|
||||
}
|
||||
|
||||
#undef ecl_stack_index
|
||||
|
||||
cl_index
|
||||
ecl_stack_index(cl_env_ptr env) {
|
||||
return env->stack_top - env->stack;
|
||||
}
|
||||
|
||||
void
|
||||
ecl_stack_set_index(cl_env_ptr env, cl_index index) {
|
||||
cl_object *new_top = env->stack + index;
|
||||
|
|
|
|||
|
|
@ -976,7 +976,7 @@ static cl_object
|
|||
sharp_asterisk_reader(cl_object in, cl_object c, cl_object d)
|
||||
{
|
||||
cl_env_ptr env = ecl_process_env();
|
||||
cl_index sp = ecl_stack_index(env);
|
||||
cl_index sp = ECL_STACK_INDEX(env);
|
||||
cl_object last, elt, x;
|
||||
cl_index dim, dimcount, i;
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
|
|
@ -1001,7 +1001,7 @@ sharp_asterisk_reader(cl_object in, cl_object c, cl_object d)
|
|||
FEreader_error("Character ~:C is not allowed after #*",
|
||||
in, 1, CODE_CHAR(x));
|
||||
}
|
||||
ecl_stack_push(env, MAKE_FIXNUM(x == '1'));
|
||||
ECL_STACK_PUSH(env, MAKE_FIXNUM(x == '1'));
|
||||
}
|
||||
if (Null(d)) {
|
||||
dim = dimcount;
|
||||
|
|
@ -1011,7 +1011,7 @@ sharp_asterisk_reader(cl_object in, cl_object c, cl_object d)
|
|||
FEreader_error("Too many elements in #*....", in, 0);
|
||||
if (dim && (dimcount == 0))
|
||||
FEreader_error("Cannot fill the bit-vector #*.", in, 0);
|
||||
else last = env->stack_top[-1];
|
||||
else last = ECL_STACK_REF(env,-1);
|
||||
}
|
||||
x = ecl_alloc_simple_vector(dim, aet_bit);
|
||||
for (i = 0; i < dim; i++) {
|
||||
|
|
@ -1021,7 +1021,7 @@ sharp_asterisk_reader(cl_object in, cl_object c, cl_object d)
|
|||
else
|
||||
x->vector.self.bit[i/CHAR_BIT] |= 0200 >> i%CHAR_BIT;
|
||||
}
|
||||
ecl_stack_pop_n(env, dimcount);
|
||||
ECL_STACK_POP_N_UNSAFE(env, dimcount);
|
||||
@(return x)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ _ecl_frs_push(register cl_env_ptr env, register cl_object val)
|
|||
output->frs_bds_top_index = env->bds_top - env->bds_org;
|
||||
output->frs_val = val;
|
||||
output->frs_ihs = env->ihs_top;
|
||||
output->frs_sp = ecl_stack_index(env);
|
||||
output->frs_sp = ECL_STACK_INDEX(env);
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -953,14 +953,14 @@ nstring_case(cl_narg narg, cl_object fun, ecl_casefun casefun, cl_va_list ARGS)
|
|||
for (i = 0, l = 0; i < narg; i++) {
|
||||
cl_object s = si_coerce_to_base_string(cl_va_arg(args));
|
||||
if (s->base_string.fillp) {
|
||||
ecl_stack_push(the_env, s);
|
||||
ECL_STACK_PUSH(the_env, s);
|
||||
l += s->base_string.fillp;
|
||||
}
|
||||
}
|
||||
/* Do actual copying by recovering those strings */
|
||||
output = cl_alloc_simple_base_string(l);
|
||||
while (l) {
|
||||
cl_object s = ecl_stack_pop(the_env);
|
||||
cl_object s = ECL_STACK_POP_UNSAFE(the_env);
|
||||
size_t bytes = s->base_string.fillp;
|
||||
l -= bytes;
|
||||
memcpy(output->base_string.self + l, s->base_string.self, bytes);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
(*unwind-exit* `((STACK ,sp) ,@*unwind-exit*)))
|
||||
(wt-nl "{")
|
||||
(wt-nl "volatile bool unwinding = FALSE;")
|
||||
(wt-nl "cl_index " sp "=ecl_stack_index(cl_env_copy)," nargs ";")
|
||||
(wt-nl "cl_index " sp "=ECL_STACK_INDEX(cl_env_copy)," nargs ";")
|
||||
(wt-nl "ecl_frame_ptr next_fr;")
|
||||
;; Here we compile the form which is protected. When this form
|
||||
;; is aborted, it continues at the ecl_frs_pop() with unwinding=TRUE.
|
||||
|
|
|
|||
|
|
@ -475,9 +475,9 @@ extern ECL_API void ecl_stack_frame_close(cl_object f);
|
|||
|
||||
extern ECL_API void FEstack_underflow(void);
|
||||
extern ECL_API void FEstack_advance(void);
|
||||
extern ECL_API void ecl_stack_grow(cl_env_ptr env);
|
||||
extern ECL_API void ecl_stack_push(cl_env_ptr env, cl_object o);
|
||||
extern ECL_API cl_object ecl_stack_pop(cl_env_ptr env);
|
||||
extern ECL_API cl_index ecl_stack_index(cl_env_ptr env);
|
||||
extern ECL_API void ecl_stack_set_size(cl_env_ptr env, cl_index new_size);
|
||||
extern ECL_API void ecl_stack_set_index(cl_env_ptr env, cl_index sp);
|
||||
extern ECL_API void ecl_stack_pop_n(cl_env_ptr env, cl_index n);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ typedef struct cl_compiler_env *cl_compiler_env_ptr;
|
|||
/* interpreter.d */
|
||||
|
||||
#define ecl_stack_ref(env,n) (env)->stack[n]
|
||||
#define ecl_stack_index(env) ((env)->stack_top-(env)->stack)
|
||||
|
||||
#define ECL_BUILD_STACK_FRAME(env,name,frame) \
|
||||
struct ecl_stack_frame frame;\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue