From 65b3bb556df56c0098f1717e8b77af20759b8096 Mon Sep 17 00:00:00 2001 From: jnthn Date: Sun, 19 Apr 2009 10:47:14 +0200 Subject: [PATCH] Implement --> for specifying return type. --- src/parser/actions.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/parser/actions.pm b/src/parser/actions.pm index 88dc51c1a5b..a6c0a9e9798 100644 --- a/src/parser/actions.pm +++ b/src/parser/actions.pm @@ -1229,6 +1229,17 @@ method signature($/, $key) { $i++; } + ## handle return type written with --> T + if $ { + $loadinit.push(PAST::Op.new( + :pasttype('call'), + :name('!sub_trait_verb'), + PAST::Var.new( :name('block'), :scope('register') ), + 'trait_verb:returns', + $( $[0] ) + )); + } + ## restore block stack and return signature ast our $?BLOCK_OPEN; $?BLOCK_OPEN := $block; @@ -3219,13 +3230,13 @@ sub set_block_type($block, $type) { $type ); $block := $set_type; - $block.loadinit().push($set_type); # The following is to make sure the Parrot-level sub has a backlink # to the Rakudo-level object, since it's all that we can find from # interpinfo. - $block.loadinit().push(PAST::Op.new( + $block.loadinit().unshift(PAST::Op.new( :inline(" $P0 = getattribute block, ['Sub'], 'proxy'", " setprop $P0, '$!real_self', block") ) ); + $block.loadinit().unshift($set_type); } }