Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More new -> root_new conversions.
  • Loading branch information
pmichaud committed May 20, 2009
1 parent 6079a97 commit 064be63
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
18 changes: 13 additions & 5 deletions src/builtins/guts.pir
Expand Up @@ -787,18 +787,18 @@ Add a trait with the given C<type> and C<name> to C<metaclass>.
.end


=item !meta_attribute(metaclass, name, itype [, 'type'=>type] )
=item !meta_attribute(metaclass, name, itypename [, 'type'=>type] )

Add attribute C<name> to C<metaclass> with the given C<itype>
Add attribute C<name> to C<metaclass> with the given C<itypename>
and C<type>.

=cut

.sub '!meta_attribute'
.param pmc metaclass
.param string name
.param string itype :optional
.param int has_itype :opt_flag
.param string itypename :optional
.param int has_itypename :opt_flag
.param pmc attr :slurpy :named

# twigil handling
Expand All @@ -823,7 +823,15 @@ and C<type>.
attrhash = $P0[name]

# Set any itype for the attribute.
unless has_itype goto itype_done
unless has_itypename goto itype_done
.local pmc itype
if itypename == 'Perl6Scalar' goto itype_pmc
itype = get_class itypename
goto have_itype
itype_pmc:
$P0 = get_root_namespace ['parrot';'Perl6Scalar']
itype = get_class $P0
have_itype:
attrhash['itype'] = itype
itype_done:

Expand Down
3 changes: 2 additions & 1 deletion src/classes/Object.pir
Expand Up @@ -289,7 +289,8 @@ the object's type and address.
unless null itypeclass goto attrinit_itype
if $S0 == '@' goto attrinit_array
if $S0 == '%' goto attrinit_hash
itypeclass = get_class ['Perl6Scalar']
$P0 = get_root_namespace ['parrot';'Perl6Scalar']
itypeclass = get_class $P0
goto attrinit_itype
attrinit_array:
itypeclass = get_class ['Perl6Array']
Expand Down
17 changes: 9 additions & 8 deletions src/parser/actions.pm
Expand Up @@ -618,7 +618,7 @@ method statement_prefix($/) {

## Add an 'else' node to the try op that clears $! if
## no exception occurred.
my $elsepir := " new %r, 'Failure'\n store_lex '$!', %r";
my $elsepir := " new %r, ['Failure']\n store_lex '$!', %r";
$past.push( PAST::Op.new( :inline( $elsepir ) ) );
}
elsif $sym eq 'gather' {
Expand Down Expand Up @@ -2209,7 +2209,7 @@ method integer($/) {
my $str;
PIR q< $P0 = find_lex '$/' >;
PIR q< $S0 = $P0 >;
PIR q< $P1 = new 'Str' >;
PIR q< $P1 = new ['Str'] >;
PIR q< assign $P1, $S0 >;
PIR q< store_lex '$str', $P1 >;
make PAST::Val.new(
Expand All @@ -2224,7 +2224,7 @@ method dec_number($/) {
my $str;
PIR q< $P0 = find_lex '$/' >;
PIR q< $S0 = $P0 >;
PIR q< $P1 = new 'Str' >;
PIR q< $P1 = new ['Str'] >;
PIR q< assign $P1, $S0 >;
PIR q< store_lex '$str', $P1 >;
make PAST::Val.new(
Expand Down Expand Up @@ -2821,10 +2821,11 @@ sub build_call($args) {
sub declare_implicit_routine_vars($block) {
for ('$_', '$/', '$!') {
unless $block.symbol($_) {
$block[0].push( PAST::Var.new( :name($_),
:scope('lexical'),
:isdecl(1),
:viviself('Perl6Scalar') ) );
$block[0].push( PAST::Var.new(
:name($_), :scope('lexical'), :isdecl(1),
:viviself(PAST::Op.new(
:inline(' %r = root_new ["parrot";"Perl6Scalar"]') ) )
) );
$block.symbol($_, :scope('lexical') );
}
}
Expand Down Expand Up @@ -2901,7 +2902,7 @@ sub make_accessor($/, $method_name, $attr_name, $rw, $scope) {
else {
$getset := PAST::Op.new(
:inline(
' %r = new "ObjectRef", %0',
' %r = root_new ["parrot";"ObjectRef"], %0',
' $P0 = get_hll_global [ "Bool" ], "True"',
' setprop %r, "readonly", $P0'
),
Expand Down
4 changes: 2 additions & 2 deletions src/setting/IO/Socket/INET.pm
Expand Up @@ -20,7 +20,7 @@ class IO::Socket::INET does IO::Socket {
port = $P0
# Create the socket handle
sock = new 'Socket'
sock = root_new ['parrot';'Socket']
unless sock goto ERR
sock.'socket'(.PIO_PF_INET, .PIO_SOCK_STREAM, .PIO_PROTO_TCP)
Expand All @@ -34,7 +34,7 @@ class IO::Socket::INET does IO::Socket {
}

method socket(Int $domain, Int $type, Int $protocol) {
my $listener := Q:PIR {{ %r = new 'Socket' }};
my $listener := Q:PIR {{ %r = root_new ['parrot';'Socket'] }};
$listener.socket($domain, $type, $protocol);
return IO::Socket::INET.new( :listener($listener) );
}
Expand Down

0 comments on commit 064be63

Please sign in to comment.