Skip to content

Commit 50bd8cc

Browse files
committed
Eliminate many uses of viviself.
1 parent 0758db1 commit 50bd8cc

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

src/NQPQ/Actions.pm

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,10 @@ class NQP::Actions is HLL::Actions {
10011001
if $<invocant> {
10021002
my $inv := $<invocant>[0].ast;
10031003
$BLOCKINIT.push($inv);
1004-
$BLOCKINIT.push(QAST::Var.new(
1005-
:name('self'), :scope('lexical'), :decl('var'),
1006-
:viviself(PAST::Var.new( :scope('lexical'), :name($inv.name) ))
1004+
$BLOCKINIT.push(QAST::Op.new(
1005+
:op('bind'),
1006+
QAST::Var.new( :name('self'), :scope('lexical'), :decl('var') ),
1007+
QAST::Var.new( :scope('lexical'), :name($inv.name) )
10071008
));
10081009
$BLOCK<signature_has_invocant> := 1
10091010
}
@@ -1016,7 +1017,7 @@ class NQP::Actions is HLL::Actions {
10161017
if $<named_param> {
10171018
$past := $<named_param>.ast;
10181019
if $quant ne '!' {
1019-
$past.viviself( vivitype($<named_param><param_var><sigil>) );
1020+
$past.default( default_for($<named_param><param_var><sigil>) );
10201021
}
10211022
}
10221023
else {
@@ -1026,7 +1027,7 @@ class NQP::Actions is HLL::Actions {
10261027
$past.named( $<param_var><sigil> eq '%' );
10271028
}
10281029
elsif $quant eq '?' {
1029-
$past.viviself( vivitype($<param_var><sigil>) );
1030+
$past.default( default_for($<param_var><sigil>) );
10301031
}
10311032
}
10321033
if $<default_value> {
@@ -1036,14 +1037,13 @@ class NQP::Actions is HLL::Actions {
10361037
if $quant eq '!' {
10371038
$/.CURSOR.panic("Can't put default on required parameter");
10381039
}
1039-
$past.viviself( $<default_value>[0]<EXPR>.ast );
1040+
$past.default( $<default_value>[0]<EXPR>.ast );
10401041
}
1041-
unless $past.viviself { $*W.cur_lexpad().arity( +$*W.cur_lexpad().arity + 1 ); }
1042+
unless $past.default { $*W.cur_lexpad().arity( +$*W.cur_lexpad().arity + 1 ); }
10421043

1043-
# Note: this is hijacking multitype a bit here comapred to what it was
1044-
# originally used for (a textual name). But it's ignored
1044+
# Set the type of the parameter.
10451045
if $<typename> {
1046-
$past.multitype($<typename>[0].ast);
1046+
$past.returns($<typename>[0].ast.value);
10471047
}
10481048

10491049
# Set definedness flag (XXX want a better way to do this).
@@ -1143,9 +1143,10 @@ class NQP::Actions is HLL::Actions {
11431143
else {
11441144
my $block := $*W.pop_lexpad();
11451145
$block[0].unshift(QAST::Var.new(:name<self>, :scope<lexical>, :decl<param>));
1146-
$block[0].push(
1147-
QAST::Var.new(:name<self>, :scope<local>, :decl<var>,
1148-
:viviself(PAST::Var.new( :name<self>, :scope('lexical_6model') ))));
1146+
$block[0].push(QAST::Op.new(
1147+
:op('bind'),
1148+
QAST::Var.new(:name<self>, :scope<local>, :decl<var> ),
1149+
QAST::Var.new( :name<self>, :scope('lexical') )));
11491150
$block[0].push(QAST::Var.new(:name<>, :scope<lexical>, :decl<var>));
11501151
$block[0].push(QAST::Var.new(:name<$/>, :scope<lexical>, :decl<var>));
11511152
$block.symbol('', :scope<lexical>);
@@ -1330,21 +1331,15 @@ class NQP::Actions is HLL::Actions {
13301331
method semilist($/) { make $<statement>.ast }
13311332

13321333
method postcircumfix:sym<[ ]>($/) {
1333-
make PAST::Var.new( $<EXPR>.ast , :scope('keyed_int'),
1334-
:viviself('Undef'),
1335-
:vivibase(vivitype('@')) );
1334+
make QAST::Op.new( :op('atpos'), $<EXPR>.ast );
13361335
}
13371336

13381337
method postcircumfix:sym<{ }>($/) {
1339-
make PAST::Var.new( $<EXPR>.ast , :scope('keyed'),
1340-
:viviself('Undef'),
1341-
:vivibase(vivitype('%')) );
1338+
make QAST::Op.new( :op('atkey'), $<EXPR>.ast );
13421339
}
13431340

13441341
method postcircumfix:sym<ang>($/) {
1345-
make PAST::Var.new( $<quote_EXPR>.ast, :scope('keyed'),
1346-
:viviself('Undef'),
1347-
:vivibase(vivitype('%')) );
1342+
make QAST::Op.new( :op('atkey'), $<EXPR>.ast );
13481343
}
13491344

13501345
method postcircumfix:sym<( )>($/) {
@@ -1424,9 +1419,10 @@ class NQP::Actions is HLL::Actions {
14241419
method quote:sym</ />($/) {
14251420
my $block := $*W.pop_lexpad();
14261421
$block[0].push(PAST::Var.new(:name<self>, :scope<parameter>));
1427-
$block[0].push(
1428-
PAST::Var.new(:name<self>, :scope<register>, :isdecl(1),
1429-
:viviself(PAST::Var.new( :name<self>, :scope('lexical_6model') ))));
1422+
$block[0].push(QAST::Op.new(
1423+
:op('bind'),
1424+
QAST::Var.new(:name<self>, :scope<register>, :isdecl(1) ),
1425+
QAST::Var.new( :name<self>, :scope('lexical') )));
14301426
$block[0].push(PAST::Var.new(:name<>, :scope<lexical>, :isdecl(1)));
14311427
$block[0].push(PAST::Var.new(:name<$/>, :scope<lexical>, :isdecl(1)));
14321428
$block.symbol('', :scope<lexical>);

0 commit comments

Comments
 (0)