Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Convert new of parrot-based things to root_new (src/classes)
  • Loading branch information
pmichaud committed May 20, 2009
1 parent 20ec24c commit 6079a97
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 64 deletions.
6 changes: 3 additions & 3 deletions src/classes/Array.pir
Expand Up @@ -49,7 +49,7 @@ Remove items from an array.
.sub 'delete' :method :multi() :subid('array_delete')
.param pmc indices :slurpy
.local pmc result
result = new 'List'
result = new ['List']
null $P99

indices.'!flatten'()
Expand Down Expand Up @@ -280,7 +280,7 @@ Return Array as a List of its values.

.namespace ['Perl6Array']
.sub 'values' :method
$P0 = new 'List'
$P0 = new ['List']
splice $P0, self, 0, 0
.return ($P0)
.end
Expand Down Expand Up @@ -350,7 +350,7 @@ Store things into an Array (e.g., upon assignment)
type = self.'of'()
## we create a new array here instead of emptying self in case
## the source argument contains self or elements of self.
array = new 'ResizablePMCArray'
array = root_new ['parrot';'ResizablePMCArray']
source = 'list'(source)
it = iter source
array_loop:
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Associative.pir
Expand Up @@ -72,7 +72,7 @@ Returns a list element or slice.
self[$S0] = result
goto end
slice:
result = new 'List'
result = new ['List']
slice_loop:
unless args goto slice_done
$S0 = shift args
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Capture.pir
Expand Up @@ -64,7 +64,7 @@ Build a capture from its argument(s).
.param pmc arg
$I0 = isa arg, 'Perl6Scalar'
if $I0 goto have_ref
arg = new 'Perl6Scalar', arg
arg = root_new ['parrot';'Perl6Scalar'], arg
have_ref:
.return (arg)
.end
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Code.pir
Expand Up @@ -58,7 +58,7 @@ for executable objects.
if match goto store_match
goto it_loop
it_loop_end:
match = new 'Undef' # Otherwise we'd get a Null PMC Exception later
match = root_new ['parrot';'Undef'] # Otherwise we'd get a Null PMC Exception later
goto store_match

# Otherwise, just match on the topic.
Expand All @@ -70,7 +70,7 @@ for executable objects.
push_eh not_regex
$P0 = getinterp
$P1 = $P0['lexpad';1]
$P2 = new 'Perl6Scalar', match
$P2 = root_new ['parrot';'Perl6Scalar'], match
$P1['$/'] = $P2
not_regex:
.return (match)
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Complex.pir
Expand Up @@ -124,7 +124,7 @@ Casts a value to a complex number.
$P0 = deref self
.return ($P0)
cast:
$P0 = new 'Complex'
$P0 = root_new ['parrot';'Complex']
$N0 = self
$P0[0] = $N0
.return ($P0)
Expand All @@ -145,7 +145,7 @@ Casts a value to a complex number.
.sub 'postfix:i' :multi(_)
.param pmc a
.local pmc proto
$P0 = new 'Complex'
$P0 = root_new ['parrot';'Complex']
$P0[1] = 1.0
mul $P0, $P0, a
.return ($P0)
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Failure.pir
Expand Up @@ -56,7 +56,7 @@
unless x goto no_args
die "Obsolete use of undef; in Perl 6 please use undefine instead"
no_args:
$P0 = new 'Failure'
$P0 = new ['Failure']
.return ($P0)
.end

Expand All @@ -73,7 +73,7 @@
$I0 = isa exception, 'Exception'
if $I0 goto have_exception
make_exception:
exception = new 'Exception'
exception = root_new ['parrot';'Exception']
exception['message'] = 'Use of uninitialized value'
setattribute self, '$!exception', exception
have_exception:
Expand Down
6 changes: 3 additions & 3 deletions src/classes/Hash.pir
Expand Up @@ -64,7 +64,7 @@ src/classes/Hash.pir - Perl 6 Hash class and related functions
.local pmc result
.local string key
.local pmc tmp
result = new 'List'
result = new ['List']
keys.'!flatten'()
keys_loop:
unless keys goto done
Expand Down Expand Up @@ -148,7 +148,7 @@ Create a Hash (hashref).
.sub 'circumfix:{ }'
.param pmc values :slurpy
$P0 = values.'Hash'()
$P0 = new 'Perl6Scalar', $P0
$P0 = root_new ['parrot';'Perl6Scalar'], $P0
.return ($P0)
.end

Expand All @@ -170,7 +170,7 @@ Store a value into a hash.
## we create a new hash here instead of emptying self in case
## the source argument contains self or elements of self.
.local pmc hash, it, type
hash = new 'Perl6Hash'
hash = new ['Perl6Hash']

## Need to preserve typing.
type = self.'of'()
Expand Down
2 changes: 1 addition & 1 deletion src/classes/IO.pir
Expand Up @@ -100,7 +100,7 @@ Read all of the lines and return them as a List.
$P0 = getattribute self, "$!IO"
pio = getattribute $P0, "$!PIO"
pio = '!DEREF'(pio)
res = new 'List'
res = new ['List']
chomper = get_hll_global 'chomp'
loop:
Expand Down
7 changes: 3 additions & 4 deletions src/classes/Junction.pir
Expand Up @@ -228,7 +228,7 @@ Return the components of the Junction.
.param pmc comparer

.local pmc ulist
ulist = new 'ResizablePMCArray'
ulist = root_new ['parrot';'ResizablePMCArray']

.local pmc it_inner, it_outer, val
it_outer = iter self
Expand Down Expand Up @@ -370,9 +370,8 @@ parameters for the dispatcher.
# We build tuples of the args and pass them onto the main junction
# dispatcher.
.local pmc pos_args, name_args, it, param
pos_args = new ['ResizablePMCArray']
$P0 = get_root_namespace ['parrot';'Hash']
name_args = new $P0
pos_args = root_new ['parrot';'ResizablePMCArray']
name_args = root_new ['parrot';'Hash']
$P0 = signature.'params'()
it = iter $P0
param_loop:
Expand Down
16 changes: 8 additions & 8 deletions src/classes/List.pir
Expand Up @@ -143,7 +143,7 @@ A list in Scalar context becomes a Scalar containing an Array.

.sub 'Scalar' :method
$P0 = self.'Array'()
$P0 = new 'Perl6Scalar', $P0
$P0 = root_new ['parrot';'Perl6Scalar'], $P0
.return ($P0)
.end

Expand Down Expand Up @@ -325,13 +325,13 @@ The zip operator.
.local pmc result

# create a list to hold the results
result = new 'List'
result = new ['List']

unless arglist goto result_done

# create a set of iterators, one per argument
.local pmc iterlist, arglist_it
iterlist = new 'ResizablePMCArray'
iterlist = root_new ['parrot';'ResizablePMCArray']
arglist_it = iter arglist
arglist_loop:
unless arglist_it goto arglist_done
Expand All @@ -349,7 +349,7 @@ The zip operator.
outer_loop:
.local pmc iterlist_it, reselem
iterlist_it = iter iterlist
reselem = new 'List'
reselem = new ['List']
iterlist_loop:
unless iterlist_it goto iterlist_done
arg_it = shift iterlist_it
Expand Down Expand Up @@ -377,7 +377,7 @@ The non-hyper cross operator.
.local pmc res

.local pmc res, outer, inner, it, val
res = new 'List'
res = new ['List']

## if the are no arguments, result is empty list
unless args goto done
Expand Down Expand Up @@ -422,7 +422,7 @@ The non-hyper cross operator.
one_arg_loop:
unless it goto done
val = shift it
$P0 = new 'List'
$P0 = new ['List']
push $P0, val
push res, $P0
goto one_arg_loop
Expand All @@ -445,7 +445,7 @@ The min operator.
.local int elems
elems = elements args
if elems > 0 goto have_args
$P0 = new 'Undef'
$P0 = root_new ['parrot';'Undef']
.return($P0)
have_args:

Expand Down Expand Up @@ -479,7 +479,7 @@ The max operator.
.local int elems
elems = elements args
if elems > 0 goto have_args
$P0 = new 'Undef'
$P0 = root_new ['parrot';'Undef']
.return($P0)
have_args:

Expand Down
14 changes: 7 additions & 7 deletions src/classes/Mapping.pir
Expand Up @@ -48,7 +48,7 @@ every pair, joined by newlines or an explicitly given separator.

have_sep:
it = self.'iterator'()
rv = new 'List'
rv = new ['List']

loop:
.local pmc pairfmt
Expand Down Expand Up @@ -89,7 +89,7 @@ every pair, joined by newlines or an explicitly given separator.
.local pmc rv

it = iter self
rv = new 'List'
rv = new ['List']

loop:
.local string key
Expand Down Expand Up @@ -130,7 +130,7 @@ Returns keys of hash as a List
.local pmc rv

it = self.'iterator'()
rv = new 'List'
rv = new ['List']
loop:
.local string key
.local pmc pair
Expand Down Expand Up @@ -167,7 +167,7 @@ Returns elements of hash as array of C<Pair(key, value)>
.local pmc rv

it = self.'iterator'()
rv = new 'List'
rv = new ['List']

loop:
.local string key
Expand Down Expand Up @@ -273,7 +273,7 @@ Return perl representation of the invocant.
.local pmc it
.local pmc rv

rv = new 'Perl6Hash'
rv = new ['Perl6Hash']
it = self.'iterator'()

loop:
Expand Down Expand Up @@ -314,7 +314,7 @@ Returns values of hash as a List
.local pmc rv

it = self.'iterator'()
rv = new 'List'
rv = new ['List']

loop:
.local pmc pair
Expand Down Expand Up @@ -357,7 +357,7 @@ return a Perl6Scalar with it.
.namespace ['Mapping']
.sub 'Scalar' :method
$P0 = self.'Hash'()
$P0 = new 'Perl6Scalar', $P0
$P0 = root_new ['parrot';'Perl6Scalar'], $P0
.return ($P0)
.end
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Match.pir
Expand Up @@ -14,7 +14,7 @@ Match - Perl 6 match objects
p6meta = get_hll_global ['Perl6Object'], '$!P6META'
matchproto = p6meta.'new_class'('Match', 'parent'=>'parrot;PGE::Grammar Any')
$P0 = p6meta.'get_parrotclass'(matchproto)
$P1 = new 'ResizablePMCArray'
$P1 = root_new ['parrot';'ResizablePMCArray']
push $P1, 'of'
$P0.'resolve_method'($P1)
$P0 = get_hll_global 'Positional'
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Nil.pir
Expand Up @@ -26,7 +26,7 @@ src/classes/Nil.pir - Nil objects

.namespace ['Nil']
.sub 'list' :method :subid('')
$P0 = new 'List'
$P0 = new ['List']
.return ($P0)
.end

Expand All @@ -52,7 +52,7 @@ src/classes/Nil.pir - Nil objects

.namespace ['Nil']
.sub 'Scalar' :method
$P0 = new 'Failure'
$P0 = new ['Failure']
.return ($P0)
.end

Expand Down
10 changes: 5 additions & 5 deletions src/classes/Object.pir
Expand Up @@ -137,7 +137,7 @@ Return invocant in list context. Default is to return a List containing self.
.namespace ['Perl6Object']
.sub '' :method('list')
$P0 = new 'List'
$P0 = new ['List']
push $P0, self
.return ($P0)
.end
Expand Down Expand Up @@ -189,7 +189,7 @@ Boolean value of object -- defaults to C<.defined> (S02).
.namespace ['Perl6Object']
.sub 'Array' :method
$P0 = new 'Perl6Array'
$P0 = new ['Perl6Array']
$P0.'!STORE'(self)
.return ($P0)
.end
Expand All @@ -200,7 +200,7 @@ Boolean value of object -- defaults to C<.defined> (S02).
.namespace ['Perl6Object']
.sub 'Hash' :method
$P0 = new 'Perl6Hash'
$P0 = new ['Perl6Hash']
$P0.'!STORE'(self)
.return ($P0)
.end
Expand All @@ -227,7 +227,7 @@ an object reference (unless the invocant already is one).
unless $I0 goto not_ref
.return (self)
not_ref:
$P0 = new 'Perl6Scalar', self
$P0 = root_new ['parrot';'Perl6Scalar'], self
.return ($P0)
.end
Expand All @@ -240,7 +240,7 @@ the object's type and address.

.namespace ['Perl6Object']
.sub 'Str' :method
$P0 = new 'ResizableStringArray'
$P0 = root_new ['parrot';'ResizableStringArray']
$P1 = self.'WHAT'()
push $P0, $P1
$I0 = get_addr self
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Pair.pir
Expand Up @@ -54,7 +54,7 @@ Stringify the Pair.
key = key.'item'()
value = value.'item'()
$P0 = new ['Perl6Pair']
$P1 = new ['Perl6Scalar']
$P1 = root_new ['parrot';'Perl6Scalar']
'infix:='($P1, key)
setattribute $P0, '$!key', $P1
setattribute $P0, '$!value', value
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Range.pir
Expand Up @@ -16,7 +16,7 @@ src/classes/Range.pir - methods for the Range class
rangeproto = p6meta.'new_class'('Range', 'parent'=>'Any', 'attr'=>'$!by $!from $!to $!from_exclusive $!to_exclusive')

$P0 = p6meta.'get_parrotclass'(rangeproto)
$P1 = new 'ResizablePMCArray'
$P1 = root_new ['parrot';'ResizablePMCArray']
push $P1, 'postcircumfix:[ ]'
$P0.'resolve_method'($P1)
$P0 = get_hll_global 'Positional'
Expand All @@ -41,7 +41,7 @@ just return a clone of the Range.
.sub '' :method('list')
.local pmc range_it, result
range_it = self.'iterator'()
result = new 'List'
result = new ['List']
range_loop:
unless range_it goto range_end
$P0 = shift range_it
Expand Down

0 comments on commit 6079a97

Please sign in to comment.