1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 23:50:19 +02:00

scm_c_make_frame takes struct scm_frame as arg

* libguile/frames.h:
* libguile/frames.c (scm_c_make_frame): Adapt to take a const struct
  scm_frame as the argument.  Adapt callers.

* libguile/continuations.c:
* libguile/stacks.c: Adapt callers.
This commit is contained in:
Andy Wingo 2014-04-14 15:14:26 +02:00
parent 44d9705464
commit 8de051da47
4 changed files with 25 additions and 23 deletions

View file

@ -179,11 +179,15 @@ scm_i_continuation_to_frame (SCM continuation)
if (scm_is_true (cont->vm_cont)) if (scm_is_true (cont->vm_cont))
{ {
struct scm_frame frame;
struct scm_vm_cont *data = SCM_VM_CONT_DATA (cont->vm_cont); struct scm_vm_cont *data = SCM_VM_CONT_DATA (cont->vm_cont);
return scm_c_make_frame (SCM_VM_FRAME_KIND_CONT, data,
(data->fp + data->reloc) - data->stack_base, frame.stack_holder = data;
(data->sp + data->reloc) - data->stack_base, frame.fp_offset = (data->fp + data->reloc) - data->stack_base;
data->ra); frame.sp_offset = (data->sp + data->reloc) - data->stack_base;
frame.ip = data->ra;
return scm_c_make_frame (SCM_VM_FRAME_KIND_CONT, &frame);
} }
else else
return SCM_BOOL_F; return SCM_BOOL_F;

View file

@ -35,17 +35,15 @@ verify (offsetof (struct scm_vm_frame, dynamic_link) == 0);
SCM SCM
scm_c_make_frame (enum scm_vm_frame_kind frame_kind, void *stack_holder, scm_c_make_frame (enum scm_vm_frame_kind kind, const struct scm_frame *frame)
scm_t_ptrdiff fp_offset, scm_t_ptrdiff sp_offset,
scm_t_uint32 *ip)
{ {
struct scm_frame *p = scm_gc_malloc (sizeof (struct scm_frame), struct scm_frame *p = scm_gc_malloc (sizeof (struct scm_frame),
"vmframe"); "vmframe");
p->stack_holder = stack_holder; p->stack_holder = frame->stack_holder;
p->fp_offset = fp_offset; p->fp_offset = frame->fp_offset;
p->sp_offset = sp_offset; p->sp_offset = frame->sp_offset;
p->ip = ip; p->ip = frame->ip;
return scm_cell (scm_tc7_frame | (frame_kind << 8), (scm_t_bits)p); return scm_cell (scm_tc7_frame | (kind << 8), (scm_t_bits)p);
} }
void void
@ -337,8 +335,7 @@ SCM_DEFINE (scm_frame_previous, "frame-previous", 1, 0, 0,
if (!scm_c_frame_previous (SCM_VM_FRAME_KIND (frame), &tmp)) if (!scm_c_frame_previous (SCM_VM_FRAME_KIND (frame), &tmp))
return SCM_BOOL_F; return SCM_BOOL_F;
return scm_c_make_frame (kind, tmp.stack_holder, tmp.fp_offset, return scm_c_make_frame (kind, &tmp);
tmp.sp_offset, tmp.ip);
} }
#undef FUNC_NAME #undef FUNC_NAME

View file

@ -167,9 +167,8 @@ enum scm_vm_frame_kind
SCM_INTERNAL SCM* scm_i_frame_stack_base (SCM frame); SCM_INTERNAL SCM* scm_i_frame_stack_base (SCM frame);
SCM_INTERNAL scm_t_ptrdiff scm_i_frame_offset (SCM frame); SCM_INTERNAL scm_t_ptrdiff scm_i_frame_offset (SCM frame);
SCM_INTERNAL SCM scm_c_make_frame (enum scm_vm_frame_kind vm_frame_kind, SCM_INTERNAL SCM scm_c_make_frame (enum scm_vm_frame_kind kind,
void *stack_holder, scm_t_ptrdiff fp_offset, const struct scm_frame *frame);
scm_t_ptrdiff sp_offset, scm_t_uint32 *ip);
SCM_INTERNAL int scm_c_frame_previous (enum scm_vm_frame_kind kind, SCM_INTERNAL int scm_c_frame_previous (enum scm_vm_frame_kind kind,
struct scm_frame *frame); struct scm_frame *frame);

View file

@ -1,5 +1,5 @@
/* A stack holds a frame chain /* A stack holds a frame chain
* Copyright (C) 1996,1997,2000,2001, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation * Copyright (C) 1996,1997,2000,2001, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -254,14 +254,16 @@ SCM_DEFINE (scm_make_stack, "make-stack", 1, 0, 1,
{ {
SCM cont; SCM cont;
struct scm_vm_cont *c; struct scm_vm_cont *c;
struct scm_frame tmp;
cont = scm_i_capture_current_stack (); cont = scm_i_capture_current_stack ();
c = SCM_VM_CONT_DATA (cont);
frame = scm_c_make_frame (SCM_VM_FRAME_KIND_CONT, c, c = SCM_VM_CONT_DATA (cont);
(c->fp + c->reloc) - c->stack_base, tmp.stack_holder = c;
(c->sp + c->reloc) - c->stack_base, tmp.fp_offset = (c->fp + c->reloc) - c->stack_base;
c->ra); tmp.sp_offset = (c->sp + c->reloc) - c->stack_base;
tmp.ip = c->ra;
frame = scm_c_make_frame (SCM_VM_FRAME_KIND_CONT, &tmp);
} }
else if (SCM_VM_FRAME_P (obj)) else if (SCM_VM_FRAME_P (obj))
frame = obj; frame = obj;