Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add foreign-load function to load libraries from a foreign language.

Fix module definition.
  • Loading branch information...
commit 107cc3f08b74f08e7a1aa0c584dcf47a75135707 1 parent 08f0f9f
Stephen Weeks tene authored
Showing with 36 additions and 2 deletions.
  1. +1 −1  cardinal.pir
  2. +34 −0 src/builtins/eval.pir
  3. +1 −1  src/parser/actions.pm
2  cardinal.pir
View
@@ -32,7 +32,7 @@ object.
.local pmc parrotns, cardinalns, exports
parrotns = get_root_namespace ['parrot']
cardinalns = get_hll_namespace
- exports = split ' ', 'PAST PCT PGE P6metaclass'
+ exports = split ' ', 'PAST PCT PGE'
parrotns.'export_to'(cardinalns, exports)
.end
34 src/builtins/eval.pir
View
@@ -121,10 +121,44 @@ such as C<eval>, C<require>, and C<use>.
$P0 = 'require'(file, 'file'=>1)
.end
+.sub 'foreign_load'
+ .param string lang
+ .param string module
+ .local pmc compiler, request, library, imports, callerns
+ $P0 = getinterp
+ callerns = $P0['namespace';1]
+ 'load-language'(lang)
+ compiler = compreg lang
+ request = new 'Hash'
+ $P0 = split '/', module
+ request['name'] = $P0
+ library = compiler.'fetch-library'(request)
+ imports = library['symbols']
+ imports = imports['DEFAULT']
+ .local pmc iter, item
+ iter = new 'Iterator', imports
+ import_loop:
+ unless iter goto import_loop_end
+ $S0 = shift iter
+ $P0 = imports[$S0]
+ callerns[$S0] = $P0
+ goto import_loop
+ import_loop_end:
+ .return (library)
+.end
+
=back
=cut
+
+.HLL 'parrot' # work around a stupid parrot bug... argh!!!!!
+
+.sub 'load-language'
+ .param string lang
+ load_language lang
+.end
+.HLL 'cardinal'
# Local Variables:
# mode: pir
# fill-column: 100
2  src/parser/actions.pm
View
@@ -455,7 +455,7 @@ method module($/) {
my $name := $( $<module_identifier> );
$past.namespace( $name.name() );
$past.blocktype('declaration');
- $past.pirflags(':load :init');
+ #$past.pirflags(':load :init');
make $past;
}
Please sign in to comment.
Something went wrong with that request. Please try again.