Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add support for loading foreign libraries.
It's not right yet.  Needs both spec and implementation fixes.
  • Loading branch information
tene committed May 18, 2009
1 parent 1639d85 commit 6b43f5d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
34 changes: 32 additions & 2 deletions src/builtins/eval.pir
Expand Up @@ -143,6 +143,38 @@ itself can be found in src/builtins/control.pir.
.param pmc args :slurpy
.param pmc options :slurpy :named

.local pmc ver, compiler_obj
.local string lang
compiler_obj = compreg 'perl6'

# This HLL stuff *should* be integrated with the rest... I spent an hour on it and failed.
ver = options['ver']
if null ver goto no_hll
$P0 = ver['lang']
if null $P0 goto no_hll
lang = $P0
.local pmc compiler, request, library, imports, callerns
$P0 = getinterp
callerns = $P0['namespace';1]
'load-language'(lang)
compiler = compreg lang
request = new 'Hash'
$P0 = compiler_obj.'parse_name'(module)
request['name'] = $P0
library = compiler.'fetch-library'(request)
imports = library['symbols']
imports = imports['DEFAULT']
.local pmc ns_iter, item
ns_iter = new 'Iterator', imports
import_loop:
unless ns_iter goto import_loop_end
$S0 = shift ns_iter
$P0 = imports[$S0]
callerns[$S0] = $P0
goto import_loop
import_loop_end:
.return (library)
no_hll:
# Require module.
.local pmc retval
retval = 'require'(module, 'module'=>1)
Expand All @@ -157,8 +189,6 @@ itself can be found in src/builtins/control.pir.

# See if we've had a namespace name passed in.
.local pmc import_ns
.local pmc compiler_obj
compiler_obj = compreg 'perl6'
$P0 = options['import_to']
if null $P0 goto use_caller_ns
$S0 = $P0
Expand Down
7 changes: 6 additions & 1 deletion src/parrot/misc.pir
Expand Up @@ -44,4 +44,9 @@ Note that we currently do this by adding the method to Parrot's
.end
.namespace []
# work around a parrot bug.
.sub 'load-language'
.param string lang
load_language lang
.end

0 comments on commit 6b43f5d

Please sign in to comment.