/* Continuation.pmc
 *  Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
 *  CVS Info
 *     $Id: continuation.pmc,v 1.16 2003/08/28 08:11:05 leo Exp $
 *  Overview:
 *     These are the vtable functions for the Continuation base class
 *  Data Structure and Algorithms:
 *  History:
 *     Initial revision by sean 2002/08/04
 *  Notes:
 *  References:
 */

#include "parrot/parrot.h"
#include "parrot/method_util.h"

pmclass Continuation extends Closure {

    void init () {
        PMC_sub(SELF) = new_continuation(INTERP);
	SELF->cache.struct_val = NULL;
	PObj_custom_mark_destroy_SETALL(SELF);
    }


    void mark () {
        struct Parrot_Sub * cc
            = (struct Parrot_Sub*)PMC_sub(SELF);
	mark_stack(INTERP, cc->ctx.user_stack);
	mark_stack(INTERP, cc->ctx.control_stack);
	SUPER();	/* mark pad_stack, warns in closure */
    }

    void clone(PMC *ret) {
	struct Parrot_Sub * sub;
	SUPER(ret);
	sub = PMC_sub(ret);
	stack_mark_cow(sub->ctx.user_stack);
	stack_mark_cow(sub->ctx.control_stack);
    }

    void* invoke (void* next) {
	struct Parrot_Sub * cc = (struct Parrot_Sub*)PMC_sub(SELF);
	restore_context(interpreter, &cc->ctx);
	return SUPER(next);
    }
}
