Skip to content

Commit

Permalink
Change lazy signature setup so that it uses block references instead
Browse files Browse the repository at this point in the history
of name lookups in the package.
  • Loading branch information
pmichaud committed Feb 22, 2010
1 parent dcc84e6 commit a3a650e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
11 changes: 4 additions & 7 deletions src/Perl6/Actions.pm
Expand Up @@ -1978,13 +1978,10 @@ sub add_signature($block, $sig_obj, $lazy) {

# If lazy, make and push signature setup block.
if $lazy {
my $sig_setup_block_name := $block.unique('!sig_setup_' ~ pir::time__N() ~ '_');
$block[0].push(PAST::Block.new(
:name($sig_setup_block_name),
:blocktype('declaration'),
$sig_obj.ast(1)
));
$sig_setup_block_name
my $sig_setup_block :=
PAST::Block.new( :blocktype<declaration>, $sig_obj.ast(1) );
$block[0].push($sig_setup_block);
PAST::Val.new(:value($sig_setup_block));
}
else {
$block.loadinit.push($sig_obj.ast(1));
Expand Down
18 changes: 8 additions & 10 deletions src/builtins/Code.pir
Expand Up @@ -17,7 +17,7 @@ for executable objects.
.local pmc p6meta, codeproto
p6meta = get_hll_global ['Mu'], '$!P6META'
$P0 = get_hll_global 'Callable'
codeproto = p6meta.'new_class'('Code', 'parent'=>'Any', 'attr'=>'$!do $!multi $!signature $!lazy_sig_init_name', 'does_role'=>$P0)
codeproto = p6meta.'new_class'('Code', 'parent'=>'Any', 'attr'=>'$!do $!multi $!signature $!lazy_sig_init', 'does_role'=>$P0)
$P1 = new ['Role']
$P1.'name'('invokable')
p6meta.'compose_role'(codeproto, $P1)
Expand All @@ -31,7 +31,7 @@ for executable objects.
.sub 'new' :method
.param pmc do
.param pmc multi
.param pmc lazy_sig_init_name
.param pmc lazy_sig_init
$P0 = getprop '$!p6type', do
if null $P0 goto need_create
.return ($P0)
Expand All @@ -42,7 +42,7 @@ for executable objects.
transform_to_p6opaque $P0
setattribute $P0, '$!do', do
setattribute $P0, '$!multi', multi
setattribute $P0, '$!lazy_sig_init_name', lazy_sig_init_name
setattribute $P0, '$!lazy_sig_init', lazy_sig_init
if multi != 2 goto proto_done
$P1 = box 1
setprop $P0, 'proto', $P1
Expand All @@ -60,7 +60,7 @@ for executable objects.
$P0 = getattribute self, '$!do'
$P0 = clone $P0
$P1 = getattribute self, '$!multi'
$P2 = getattribute self, '$!lazy_sig_init_name'
$P2 = getattribute self, '$!lazy_sig_init'
$P3 = self.'new'($P0, $P1, $P2)
.return ($P3)
.end
Expand Down Expand Up @@ -154,7 +154,7 @@ Gets the signature for the block, or returns Failure if it lacks one.
=cut

.sub 'signature' :method
.local pmc do, ll_sig, lazy_name
.local pmc do, ll_sig, lazy_sig

# Do we have a cached result?
$P0 = getattribute self, '$!signature'
Expand All @@ -168,11 +168,9 @@ Gets the signature for the block, or returns Failure if it lacks one.
unless null ll_sig goto have_sig

# No signautre yet, but maybe we have a lazy creator.
lazy_name = getattribute self, '$!lazy_sig_init_name'
if lazy_name == '' goto srsly_no_sig
$P0 = do.'get_namespace'()
$P0 = $P0[lazy_name]
ll_sig = $P0()
lazy_sig = getattribute self, '$!lazy_sig_init'
if null lazy_sig goto srsly_no_sig
ll_sig = lazy_sig()
setprop do, '$!signature', ll_sig
goto have_sig
srsly_no_sig:
Expand Down

0 comments on commit a3a650e

Please sign in to comment.