NAME ^

src/embed.c - The Parrot embedding interface

DESCRIPTION ^

This file implements the Parrot embedding interface.

Functions ^

Parrot_Interp Parrot_new(Parrot_Interp parent)

Returns a new Parrot interpreter.

The first created interpreter (parent is NULL) is the last one to get destroyed.

void Parrot_init(Interp *interpreter)

Initializes the new interpreter. This function only has effect the first time it is called. Use this function when you intend to enter the run loop, which automatically sets the top of stack pointer.

void Parrot_init_stacktop(Interp *interpreter, void *stack_top)

Like above. Additionally sets the stack top, so that Parrot objects created in inner stack frames will be visible during DODs stack walking code. stack_top should be the address of an automatic variable in the caller's stack frame. All unanchored Parrot objects (PMCs) must live in inner stack frames so that they are not destroyed during DOD runs.

Use this function when you call into Parrot before entering a run loop.

void Parrot_set_flag(Interp *interpreter, Parrot_Interp_flag flag)

Sets a flag in the interpreter specified by flag, any of PARROT_BOUNDS_FLAG, or PARROT_PROFILE_FLAG to enable profiling, and bounds checking respectively or PARROT_THR_TYPE_1, PARROT_THR_TYPE_2, or PARROT_THR_TYPE_3 to disable thread communication and variable sharing, disable variable sharing but enable thread communication, or to enable variable sharing.

void Parrot_set_debug(Interp *interpreter, UINTVAL flag)

Set a debug flag: PARROT_DEBUG_FLAG.

void Parrot_set_trace(Interp *interpreter, UINTVAL flag)

Set a trace flag: PARROT_TRACE_FLAG

void Parrot_clear_flag(Interp *, Parrot_Interp_flag flag)

void Parrot_clear_debug(Interp *, UINTVAL flag)

void Parrot_clear_trace(Interp *, UINTVAL flag)

Clears a flag in the interpreter.

Parrot_Int Parrot_test_flag(Interp*, Parrot_Interp_flag flag)

UINTVAL Parrot_test_debug(Interp*, UINTVAL flag)

UINTVAL Parrot_test_trace(Interp*, UINTVAL flag)

Test the interpreter flags specified in flag.

void Parrot_set_run_core(Interp *interpreter, Parrot_Run_core_t core)

Sets the specified run core.

void Parrot_setwarnings(Interp *interpreter, Parrot_warnclass wc)

Activates the given warnings.

struct PackFile *Parrot_readbc(Interp *interpreter, const char *filename)

Read in a bytecode, unpack it into a PackFile structure, and do fixups.

void Parrot_loadbc(Interp *interpreter, struct PackFile *pf)

Loads the PackFile returned by Parrot_readbc().

static PMC *setup_argv(Interp *interpreter, int argc, char ** argv)

Creates and returns ARGS array PMC.

static int prof_sort_f(const void *a, const void *b)

Sort function for profile data. Sorts by time.

static const char *op_name(Parrot_Interp interpreter, int k)

Returns the name of the opcode.

static FLOATVAL calibrate(Parrot_Interp interpreter)

With this calibration, reported times of parrot -p almost match those measured with time parrot -b.

static void print_profile(int status, void *p)

Prints out a profile listing.

static void print_debug(int status, void *p)

Prints GC info.

void Parrot_runcode(Interp *interpreter, int argc, char *argv[])

Sets up ARGV and runs the ops.

static char *argv_join(char **argv)

XXX Doesn't handle arguments with spaces.

void Parrot_debug(Interp *interpreter, int argc, char **argv)

Runs the interpreter's bytecode in debugging mode.

void Parrot_disassemble(Interp *interpreter)

Disassembles and prints out the interpreter's bytecode.

This is used by the Parrot disassembler.

void Parrot_run_native(Parrot_Interp interpreter, native_func_t func)

Run the C function func through the program [enternative, end]. This ensures that the function is run with the same setup as in other run loops.

This function is used in some of the source tests in t/src which use the interpreter outside a runloop.

SEE ALSO ^

include/parrot/embed.h and docs/embed.pod.

HISTORY ^

Initial version by Brent Dax on 2002.1.28.


parrot