src/sub.c - Subroutines
Subroutines,
continuations,
co-routines and other fun stuff...
void mark_context
- Marks the context
*ctx
.
Parrot_sub *new_sub
- Returns a new
Parrot_sub
.
Parrot_sub *new_closure
- Returns a new
Parrot_sub
with its own sctatchpad.
- XXX: Need to document semantics in detail.
Parrot_cont *new_continuation
- Returns a new
Parrot_cont
to the context of to
with its own copy of the current interpreter context.
If to
is NULL
,
then the to_ctx
is set to the current context.
Parrot_cont *new_ret_continuation
- Returns a new
Parrot_cont
pointing to the current context.
Parrot_coro *new_coroutine
- Returns a new
Parrot_coro
.
- XXX: Need to document semantics in detail.
PMC *new_ret_continuation_pmc
- Returns a new
RetContinuation
PMC.
Uses one from the cache,
if possible; otherwise,
creates a new one.
void invalidate_retc_context
- Make true Continuations from all RetContinuations up the call chain.
STRING *Parrot_full_sub_name
- Return namespace,
name,
and location of subroutine.
int Parrot_Context_get_info
- Takes pointers to a context and its information table.
Populates the table and returns 0 or 1.
XXX needs explanation Used by Parrot_Context_infostr.
STRING *Parrot_Context_infostr
- Formats context information for display.
Takes a context pointer and returns a pointer to the text.
Used in debug.c and warnings.c
PMC *Parrot_find_pad
- Locate the LexPad containing the given name.
Return NULL on failure.
PMC *parrot_new_closure
- Used where?
XXX
- Creates a new closure,
saving the context information.
Takes a pointer to a subroutine.
- Returns a pointer to the closure,
(or throws exceptions if invalid).
void Parrot_continuation_check
- Verifies that the provided continuation is sane.
- */
- void Parrot_continuation_check(PARROT_INTERP,
ARGIN(PMC *pmc),
ARGIN(Parrot_cont *cc)) { parrot_context_t *to_ctx = cc->to_ctx; parrot_context_t *from_ctx = CONTEXT(interp);
- #if CTX_LEAK_DEBUG if (Interp_debug_TEST(interp,
PARROT_CTX_DESTROY_DEBUG_FLAG)) fprintf(stderr,
"[invoke cont %p,
to_ctx %p,
from_ctx %p (refs %d)]\n",
(void *)pmc,
(void *)to_ctx,
(void *)from_ctx,
(int)from_ctx->ref_count); #endif if (!to_ctx) Parrot_ex_throw_from_c_args(interp,
NULL,
EXCEPTION_INVALID_OPERATION,
"Continuation invoked after deactivation."); }
- /*
void Parrot_continuation_rewind_environment
- Restores the appropriate context for the continuation.
- */
- void Parrot_continuation_rewind_environment(PARROT_INTERP,
ARGIN(PMC *pmc),
ARGIN(Parrot_cont *cc)) { parrot_context_t *to_ctx = cc->to_ctx;
/* debug print before context is switched */
if (Interp_trace_TEST(interp, PARROT_TRACE_SUB_CALL_FLAG)) {
PMC *sub = to_ctx->current_sub;
PIO_eprintf(interp, "# Back in sub '%Ss', env %p\n",
Parrot_full_sub_name(interp, sub),
interp->dynamic_env);
}
/* set context */
CONTEXT(interp) = to_ctx;
interp->ctx.bp = to_ctx->bp;
interp->ctx.bp_ps = to_ctx->bp_ps;
}
- /*
include/parrot/sub.h.
Initial version by Melvin on 2002/06/6.