~ubuntu-branches/ubuntu/precise/rakudo/precise

« back to all changes in this revision

Viewing changes to src/parrot/misc.pir

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghedini
  • Date: 2011-05-17 11:31:09 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517113109-rmfir654u1axbpt4
Tags: 0.1~2011.04-1
* New upstream release (Closes: #601862, #585762, #577502)
* New maintainer
* Switch to 3.0 (quilt) format
* Update dependencies (Closes: #584498)
* Update debian/copyright to lastest DEP5 revision
* Do not generate/install perl6 manpage (now done by the build system)
* Enable tests
* Bump Standards-Version to 3.9.2 (no changes needed)
* Do not install extra LICENSE files and duplicated docs
* Remove debian/clean (no more needed)
* Add Vcs-* fields in debian/control
* Rewrite (short) description
* Update upstream copyright years
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
=item ResizablePMCArray.list
2
 
 
3
 
This version of list morphs a ResizablePMCArray into a List.
4
 
 
5
 
=cut
6
 
 
7
 
.namespace ['ResizablePMCArray']
8
 
.sub 'list' :method :subid('')
9
 
    ##  this code morphs a ResizablePMCArray into a List
10
 
    ##  without causing a clone of any of the elements
11
 
    $P0 = new 'ResizablePMCArray'
12
 
    splice $P0, self, 0, 0
13
 
    $P1 = new 'List'
14
 
    copy self, $P1
15
 
    splice self, $P0, 0, 0
16
 
    .return (self)
17
 
.end
18
 
 
19
 
 
20
 
## special method to cast Parrot String into Rakudo Str.
21
 
.namespace ['String']
22
 
.sub 'Scalar' :method
23
 
    $P0 = new 'Str'
24
 
    assign $P0, self
25
 
    copy self, $P0
26
 
    .return (self)
27
 
.end
28
 
 
29
 
 
30
 
=item count()
31
 
 
32
 
Return the number of required and optional parameters for a Block.
33
 
Note that we currently do this by adding the method to Parrot's
34
 
"Sub" PMC, so that it works for non-Rakudo subs.
35
 
 
36
 
=cut
37
 
 
38
 
.namespace ['Sub']
39
 
.sub 'count' :method
40
 
    $P0 = inspect self, "pos_required"
41
 
    $P1 = inspect self, "pos_optional"
42
 
    add $P0, $P1
43
 
    .return ($P0)
44
 
.end
45
 
 
46
 
 
47
 
.namespace []
48
 
# work around a parrot bug.
49
 
.sub 'load-language'
50
 
    .param string lang
51
 
    load_language lang
52
 
.end
53
 
 
54
 
 
55
 
# Twiddle MultiSub - at most of these can go away when it stops inheriting
56
 
# from RPA.
57
 
 
58
 
.namespace ['MultiSub']
59
 
 
60
 
.sub 'Scalar' :method
61
 
    .return (self)
62
 
.end
63
 
 
64
 
.sub 'perl' :method
65
 
    .return ('{ ... }')
66
 
.end
67
 
 
68
 
=item name
69
 
 
70
 
Gets the name of the routine.
71
 
 
72
 
=cut
73
 
 
74
 
.sub 'name' :method
75
 
    # We'll just use the name of the first candidate.
76
 
    $S0 = ''
77
 
    $P0 = self[0]
78
 
    if null $P0 goto done
79
 
    $S0 = $P0
80
 
  done:
81
 
    .return ($S0)
82
 
.end
83
 
 
84
 
 
85
 
=item Class.attriter
86
 
 
87
 
Return an iterator that iterates over a Class' attributes.
88
 
If the Class object has a @!attribute_list property, use
89
 
that as the order of attributes, otherwise introspect the
90
 
class and use its list.  (As of Parrot 1.4.0 we can't
91
 
always introspect the class directly, as the order of
92
 
attributes in the class isn't guaranteed.)
93
 
 
94
 
=cut
95
 
 
96
 
.namespace ['Class']
97
 
.sub 'attriter' :method
98
 
    $P0 = getprop '@!attribute_list', self
99
 
    unless null $P0 goto have_list
100
 
    $P0 = inspect self, 'attributes'
101
 
  have_list:
102
 
    $P1 = iter $P0
103
 
    .return ($P1)
104
 
.end