Skip to content

Commit

Permalink
War on Q:PIR - PAST::Compiler.register
Browse files Browse the repository at this point in the history
  • Loading branch information
Benabik committed Jun 10, 2011
1 parent 778bc2b commit bfb8aab
Showing 1 changed file with 19 additions and 35 deletions.
54 changes: 19 additions & 35 deletions compilers/pct/src/PAST/Compiler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2209,45 +2209,29 @@ multi method attribute(PAST::Var $node, $bindpost) {


multi method register(PAST::Var $node, $bindpost) {
Q:PIR {
.local pmc node
node = find_lex '$node'
.local pmc bindpost
bindpost = find_lex '$bindpost'
.local string name
name = node.'name'()
if name goto have_name
name = self.'uniquereg'('P')
node.'name'(name)
have_name:

.local pmc ops
$P0 = get_hll_global ['POST'], 'Ops'
ops = $P0.'new'('result'=>name, 'node'=>node)

.local int isdecl
isdecl = node.'isdecl'()
unless isdecl goto decl_done
ops.'push_pirop'('.local pmc', ops)
decl_done:

if bindpost goto register_bind
my $name := $node.name();

.local pmc viviself, vivipost
viviself = node.'viviself'()
unless viviself goto end
vivipost = self.'as_vivipost'(viviself, 'rtype'=>'P')
ops.'push'(vivipost)
ops.'push_pirop'('set', ops, vivipost)
goto end
unless $name {
$name := self.uniquereg('P');
$node.name($name);
}

my $ops := POST::Ops.new(result => $name, node => $node);

register_bind:
ops.'push_pirop'('set', ops, bindpost)
$ops.push_pirop('.local pmc', $ops) if $node.isdecl();

end:
.return (ops)
if $bindpost {
$ops.push_pirop('set', $ops, $bindpost);
} else {
my $viviself := $node.viviself();
if $viviself {
my $vivipost := self.as_vivipost($viviself, rtype => 'P');
$ops.push($vivipost);
$ops.push_pirop('set', $ops, $vivipost);
}
}

$ops;
}


Expand Down

0 comments on commit bfb8aab

Please sign in to comment.