NAME ^

src/embed.c - The Parrot embedding interface

DESCRIPTION ^

This file implements the Parrot embedding interface.

Functions ^

Parrot_Interp Parrot_new

Returns a new Parrot interpreter.

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

void Parrot_init_stacktop

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.

void Parrot_set_flag

Sets on any of the following flags, specified by flag, in the interpreter:

Flag Effect PARROT_BOUNDS_FLAG enable bounds checking PARROT_PROFILE_FLAG enable profiling, PARROT_THR_TYPE_1 disable variable sharing and thread communication PARROT_THR_TYPE_2 disable variable sharing but enable thread communication PARROT_THR_TYPE_3 enable variable sharing.

void Parrot_set_debug

Set a debug flag: PARROT_DEBUG_FLAG.

void Parrot_set_executable_name

Sets the name of the executable launching Parrot (see pbc_to_exe and the parrot binary).

void Parrot_set_trace

Set a trace flag: PARROT_TRACE_FLAG

void Parrot_clear_flag

Clears a flag in the interpreter.

void Parrot_clear_debug

Clears a flag in the interpreter.

void Parrot_clear_trace

Clears a flag in the interpreter.

Parrot_Int Parrot_test_flag

Test the interpreter flags specified in flag.

UINTVAL Parrot_test_debug

Test the interpreter flags specified in flag.

UINTVAL Parrot_test_trace

Test the interpreter flags specified in flag.

void Parrot_set_run_core

Sets the specified run core.

void Parrot_setwarnings

Activates the given warnings.

PackFile *Parrot_readbc

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

void Parrot_loadbc

Loads the PackFile returned by Parrot_readbc().

static PMC *setup_argv

Creates and returns ARGS array PMC.

static int prof_sort_f

Sort function for profile data. Sorts by time.

static const char *op_name

Returns the name of the opcode.

static FLOATVAL calibrate

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

static void print_profile

Prints out a profile listing.

static void print_debug

Prints GC info.

static PMC *set_current_sub

Search the fixup table for a PMC matching the argument. On a match, set up the appropriate context.

If no match, set up a dummy PMC entry. In either case, return a pointer to the PMC.

void Parrot_runcode

Sets up ARGV and runs the ops.

opcode_t *Parrot_debug

Runs the interpreter's bytecode in debugging mode.

void Parrot_disassemble

Disassembles and prints out the interpreter's bytecode.

This is used by the Parrot disassembler.

void Parrot_run_native

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