@@ -57,6 +57,7 @@ class QAST::Compiler is HLL::Compiler {
57
57
has % ! lexical_regs ; # Mapping of lexical names to registers
58
58
has % ! reg_types ; # Mapping of all registers to types
59
59
has int $ ! param_idx ; # Current lexical parameter index
60
+ has @ ! loadlibs ; # Libraries to load for the target POST::Block.
60
61
61
62
method new ($ qast , $ outer ) {
62
63
my $ obj := nqp ::create(self );
@@ -125,6 +126,15 @@ class QAST::Compiler is HLL::Compiler {
125
126
method lexical_type ($ name ) { % ! lexical_types {$ name } }
126
127
method lexical_type_long ($ name ) { % longnames {% ! lexical_types {$ name }} }
127
128
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
+ }
128
138
}
129
139
130
140
our $ serno ;
@@ -299,6 +309,10 @@ class QAST::Compiler is HLL::Compiler {
299
309
else {
300
310
$ sub . pirflags(' :anon' );
301
311
}
312
+
313
+ # Set loadlibs if applicable.
314
+ my @ loadlibs := $ block . loadlibs();
315
+ $ sub . loadlibs(@ loadlibs ) if @ loadlibs ;
302
316
}
303
317
304
318
# If we are at the top level, we'll immediately return.
@@ -381,8 +395,11 @@ class QAST::Compiler is HLL::Compiler {
381
395
}
382
396
return $ ops ;
383
397
}
398
+ elsif $ node . supports(' loadlibs' ) {
399
+ $ * BLOCK . add_loadlibs($ node . alternative(' loadlibs' ));
400
+ }
384
401
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 '" );
386
403
}
387
404
}
388
405
0 commit comments