Skip to content

Commit e5cccaa

Browse files
committed
Provide a way to handle loadlibs.
1 parent 59ea95f commit e5cccaa

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/QAST/Compiler.nqp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class QAST::Compiler is HLL::Compiler {
5757
has %!lexical_regs; # Mapping of lexical names to registers
5858
has %!reg_types; # Mapping of all registers to types
5959
has int $!param_idx; # Current lexical parameter index
60+
has @!loadlibs; # Libraries to load for the target POST::Block.
6061

6162
method new($qast, $outer) {
6263
my $obj := nqp::create(self);
@@ -125,6 +126,15 @@ class QAST::Compiler is HLL::Compiler {
125126
method lexical_type($name) { %!lexical_types{$name} }
126127
method lexical_type_long($name) { %longnames{%!lexical_types{$name}} }
127128
method reg_type($name) { %!reg_types{$name} }
129+
130+
method add_loadlibs(@libs) {
131+
for @libs {
132+
@!loadlibs[+@!loadlibs] := $_;
133+
}
134+
}
135+
method loadlibs() {
136+
@!loadlibs
137+
}
128138
}
129139

130140
our $serno;
@@ -299,6 +309,10 @@ class QAST::Compiler is HLL::Compiler {
299309
else {
300310
$sub.pirflags(':anon');
301311
}
312+
313+
# Set loadlibs if applicable.
314+
my @loadlibs := $block.loadlibs();
315+
$sub.loadlibs(@loadlibs) if @loadlibs;
302316
}
303317

304318
# If we are at the top level, we'll immediately return.
@@ -381,8 +395,11 @@ class QAST::Compiler is HLL::Compiler {
381395
}
382396
return $ops;
383397
}
398+
elsif $node.supports('loadlibs') {
399+
$*BLOCK.add_loadlibs($node.alternative('loadlibs'));
400+
}
384401
else {
385-
nqp::die("To compile on the Parrot backend, QAST::VM must have an alternative 'paoort', 'pirop' or 'pir'");
402+
nqp::die("To compile on the Parrot backend, QAST::VM must have an alternative 'parrot', 'pirop', 'pir' or 'loadlibs'");
386403
}
387404
}
388405

0 commit comments

Comments
 (0)