NAME ^

src/embed.c - The Parrot embedding interface

DESCRIPTION ^

This file implements the Parrot embedding interface.

Functions ^

PARROT_API 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.

PARROT_API void Parrot_init_stacktop(PARROT_INTERP, void *stack_top)

Initializes the new interpreter when it hasn't been initialized before.

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.

PARROT_API void Parrot_set_flag(PARROT_INTERP, INTVAL 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.

PARROT_API void Parrot_set_debug(PARROT_INTERP, UINTVAL flag)

Set a debug flag: PARROT_DEBUG_FLAG.

PARROT_API void Parrot_set_trace(PARROT_INTERP, UINTVAL flag)

Set a trace flag: PARROT_TRACE_FLAG

PARROT_API void Parrot_clear_flag(PARROT_INTERP, INTVAL flag)

Clears a flag in the interpreter.

PARROT_API void Parrot_clear_debug(PARROT_INTERP, UINTVAL flag)

Clears a flag in the interpreter.

PARROT_API void Parrot_clear_trace(PARROT_INTERP, UINTVAL flag)

Clears a flag in the interpreter.

PARROT_API Parrot_Int Parrot_test_flag(PARROT_INTERP, INTVAL flag)

Test the interpreter flags specified in flag.

PARROT_API UINTVAL Parrot_test_debug(PARROT_INTERP, UINTVAL flag)

Test the interpreter flags specified in flag.

PARROT_API UINTVAL Parrot_test_trace(PARROT_INTERP, UINTVAL flag)

Test the interpreter flags specified in flag.

PARROT_API void Parrot_set_run_core(PARROT_INTERP, Parrot_Run_core_t core)

Sets the specified run core.

PARROT_API void Parrot_setwarnings(PARROT_INTERP, Parrot_warnclass wc)

Activates the given warnings.

PARROT_API PARROT_CAN_RETURN_NULL PackFile *Parrot_readbc(PARROT_INTERP, ARGIN_NULLOK(const char *fullname))

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

PARROT_API void Parrot_loadbc(PARROT_INTERP, NOTNULL(PackFile *pf))

Loads the PackFile returned by Parrot_readbc().

PARROT_CANNOT_RETURN_NULL static PMC *setup_argv(PARROT_INTERP, int argc, NOTNULL(char ** argv))

Creates and returns ARGS array PMC.

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

Sort function for profile data. Sorts by time.

PARROT_CANNOT_RETURN_NULL static const char *op_name(PARROT_INTERP, int k)

Returns the name of the opcode.

static FLOATVAL calibrate(PARROT_INTERP)

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

static void print_profile(PARROT_INTERP, SHIM(int status), SHIM(void *p))

Prints out a profile listing.

static void print_debug(PARROT_INTERP, SHIM(int status), SHIM(void *p))

Prints GC info.

PARROT_CANNOT_RETURN_NULL static PMC *set_current_sub(PARROT_INTERP)

RT#48260: Not yet documented!!!

PARROT_API void Parrot_runcode(PARROT_INTERP, int argc, char *argv[])

Sets up ARGV and runs the ops.

PARROT_API PARROT_CAN_RETURN_NULL opcode_t *Parrot_debug(NOTNULL(Parrot_Interp debugger), opcode_t *pc)

Runs the interpreter's bytecode in debugging mode.

PARROT_API void Parrot_disassemble(PARROT_INTERP)

Disassembles and prints out the interpreter's bytecode.

This is used by the Parrot disassembler.

PARROT_API void Parrot_run_native(PARROT_INTERP, 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