Skip to content

Commit

Permalink
PCT: PAST.Compiler.uniquereq in Winxed
Browse files Browse the repository at this point in the history
  • Loading branch information
Benabik committed Apr 26, 2012
1 parent 7fa3e9b commit 77371b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
26 changes: 0 additions & 26 deletions compilers/pct/src/PAST/Compiler.pir
Expand Up @@ -24,32 +24,6 @@ PAST::Compiler - PAST Compiler

.namespace [ 'PAST';'Compiler' ]

=item uniquereg(rtype)

Generate a unique register based on C<rtype>, where C<rtype>
is one of the signature flags described above.

=cut

.sub 'uniquereg' :method
.param string rtype
unless rtype goto err_nortype
if rtype == 'v' goto reg_void
.local string reg
$I0 = index 'Ss~Nn+Ii', rtype
rtype = 'P'
if $I0 < 0 goto have_rtype
rtype = substr 'SSSNNNII', $I0, 1
have_rtype:
reg = concat '$', rtype
.tailcall self.'unique'(reg)
reg_void:
.return ('')
err_nortype:
self.'panic'('rtype not set')
.end


=item tempreg_frame()

Create a new temporary register frame, using register
Expand Down
20 changes: 20 additions & 0 deletions compilers/pct/src/PAST/Compiler.winxed
Expand Up @@ -251,6 +251,26 @@ unique number.
return ret;
}

/*
=item uniquereg(rtype)

Generate a unique register based on C<rtype>, where C<rtype>
is one of the signature flags described above.

=cut

*/
function uniquereg[method](string rtype) {
if (!rtype)
return self.panic('rtype not set');
if (rtype == 'v')
return '';
int i = indexof('Ss~Nn+Ii', rtype);
rtype = 'P';
if (i >= 0)
rtype = substr('SSSNNNII', i, 1);
return self.unique('$' + rtype);
}
}

/*
Expand Down

0 comments on commit 77371b2

Please sign in to comment.