General Issues

Parrot::Interpreter - cannot use Lua
Parrot::Interpreter - should support multi-level namespaces
Parrot::Interpreter - run Pynie code
Add exported function Parrot_set_HLL()
load_bytecode, loadlib, and HLL
abc should not evaluate to 'last' in the abc language
r37927 segfaults on building lua
export conventions (cross hll)
pdd31-hll interop
hll interop
Assertion Failure with steme and rakudo
Problem with threads and HLLs
.HLL should not case-mangle its arg
Deprecations as data
Something borked with HLL mappings.

Known Workarounds

Call the 'load_language' opcode from the 'parrot' HLL
Use an all-lowercase HLL name

Library Loading

To provide other languages access to libraries written in your language, you must add a 'load_library' method to your compiler object. This method must accept one positional parameter, a list (or ::-delimited string?) representing the name of the library to load, and an arbitrary quantity of other named parameters (:named :slurpy), which it is (currently) free to ignore. This method should return a hash containing the following attributes:

symbols:       # The only required attribute
        # a map of names to symbols
        # a map of names to symbols
    # other named sets of symbols can go here...
    # the only required items are DEFAULT and ALL
# You can include other additional information
filename: "/path/to/filename.ext"
version: "v1.0.1"
author: "adent"

For existing implementations of this, look at runtime/parrot/languages/parrot/parrot.pir in the Parrot repository and perl6.pir in the rakudo repository.

An example implementation of a 'foreign_load' function:

.HLL 'example'

.sub 'foreign_load'
    .param string lang
    .param string module
    .local pmc compiler, name, library, imports, callerns, foreignlibns
    $P0 = getinterp
    callerns = $P0['namespace';1]
    'load-language'(lang)          # This sub just calls the load_language opcode, but from the 'parrot' HLL, to avoid a parrot bug
    compiler = compreg lang
    name = split '::', module
    library = compiler.'load_library'(name)
    imports = library['symbols']
    imports = imports['DEFAULT']
    .local pmc iter, item
    iter = new 'Iterator', imports
    unless iter goto import_loop_end
    $S0 = shift iter
    $P0 = imports[$S0]
    callerns[$S0] = $P0
    goto import_loop
    foreignlibns = library['namespace']
    if null foreignlibns goto no_foreign_ns
    $S0 = pop name
    set_hll_global name, $S0, foreignlibns
    .return (library)

.HLL 'parrot'

# Workaround for a Parrot bug
.sub 'load-language'
    .param pmc name
    load_language name

# Switch back
.HLL 'example'