@@ -76,28 +76,36 @@ class NQP::Actions is HLL::Actions {
76
76
# register the mainline as a module (so trying to use ourself in the
77
77
# program will not explode). If we have a MAIN sub, call it at end of
78
78
# mainline.
79
- # XXX Needs QAST update.
80
- # $unit.unshift(PAST::Var.new( :scope('parameter'), :name('@ARGS'), :slurpy(1),
81
- # :directaccess(1) ));
82
- # my $main_tasks := QAST::Stmts.new(
83
- # PAST::Op.new( :pirop('load_bytecode vs'), 'ModuleLoader.pbc' ),
84
- # QAST::Op.new(
85
- # :op('callmethod'), :name('set_mainline_module'),
86
- # PAST::Var.new( :name('ModuleLoader'), :namespace([]), :scope('package') ),
87
- # PAST::Var.new( :scope('keyed'), PAST::Op.new( :pirop('getinterp P') ), 'context' )
88
- # )
89
- # );
90
- # if $*MAIN_SUB {
91
- # $main_tasks.push(QAST::Op.new(
92
- # :op('call'), QAST::BVal.new( :value($*MAIN_SUB) ),
93
- # QAST::Var.new( :scope('lexical'), :name('@ARGS'), :flat(1) )
94
- # ));
95
- # }
96
- # $mainline.push(QAST::Op.new(
97
- # :op('if'),
98
- # QAST::Var.new( :scope('lexical'), :name('@ARGS') ),
99
- # $main_tasks
100
- # ));
79
+ $ unit . unshift (QAST ::Var. new ( : scope(' lexical' ), : name(' @ARGS' ), : decl(' param' ), : slurpy(1 ) ));
80
+ my $ main_tasks := QAST ::Stmts. new (
81
+ QAST ::VM. new (
82
+ : pirop(' load_bytecode vs' ),
83
+ QAST ::SVal. new ( : value(' ModuleLoader.pbc' ) )
84
+ ),
85
+ QAST ::Op. new (
86
+ : op(' callmethod' ), : name(' set_mainline_module' ),
87
+ QAST ::VM. new (
88
+ pirop => ' get_hll_global Ps' ,
89
+ QAST ::SVal. new ( : value(' ModuleLoader' ) )
90
+ ),
91
+ QAST ::Op. new (
92
+ : op(' atkey' ),
93
+ QAST ::VM. new ( : pirop(' getinterp P' ) ),
94
+ QAST ::SVal. new ( : value(' context' ) )
95
+ )
96
+ )
97
+ );
98
+ if $ * MAIN_SUB {
99
+ $ main_tasks . push (QAST ::Op. new (
100
+ : op(' call' ), QAST ::BVal. new ( : value($ * MAIN_SUB ) ),
101
+ QAST ::Var. new ( : scope(' lexical' ), : name(' @ARGS' ), : flat(1 ) )
102
+ ));
103
+ }
104
+ $ mainline . push (QAST ::Op. new (
105
+ : op(' if' ),
106
+ QAST ::Var. new ( : scope(' lexical' ), : name(' @ARGS' ) ),
107
+ $ main_tasks
108
+ ));
101
109
102
110
# Push mainline statements into UNIT.
103
111
$ unit . push ($ mainline );
0 commit comments