Skip to content

Commit

Permalink
Add .^methods and .^isa introspection methods. Also bump us up to the…
Browse files Browse the repository at this point in the history
… Parrot build where I put in the P6object changes that are needed to go with this.
  • Loading branch information
jnthn committed May 5, 2009
1 parent 8009acf commit 9a1cacd
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build/PARROT_REVISION
@@ -1 +1 @@
38385
38492
63 changes: 63 additions & 0 deletions src/parrot/ClassHOW.pir
Expand Up @@ -35,6 +35,69 @@ Tests role membership.
.end


=item isa()

Gets a list of this class' parents.
=cut
.sub 'isa' :method :multi(_,_)
.param pmc obj
.local pmc parrot_class, result_list, parrot_list, it
result_list = get_hll_global 'Array'
result_list = result_list.'new'()
parrot_class = self.'get_parrotclass'(obj)
parrot_list = inspect parrot_class, 'parents'
it = iter parrot_list
it_loop:
unless it goto it_loop_end
$P0 = shift it
$P0 = getprop 'metaclass', $P0
$P0 = $P0.'WHAT'()
result_list.'push'($P0)
goto it_loop
it_loop_end:
.return (result_list)
.end
=item methods(object)
Gets a list of methods.
XXX Spec and implement various flags it takes, which currently aren't in S12.

XXX Fix bugs with introspecting some built-in classes (List, Str...)

=cut

.sub 'methods' :method
.param pmc obj

.local pmc parrot_class, method_hash, result_list, it, cur_meth
parrot_class = self.'get_parrotclass'(obj)

# Create array to put results in.
result_list = get_hll_global 'Array'
result_list = result_list.'new'()

# Get methods hash and build list of methods.
method_hash = inspect parrot_class, "methods"
it = iter method_hash
it_loop:
unless it goto it_loop_end
$S0 = shift it
cur_meth = method_hash[$S0]
result_list.'push'(cur_meth)
goto it_loop
it_loop_end:

.return (result_list)
.end


=item dispatch(obj, name, ...)

Dispatches to method of the given name on this class or one of its parents.
Expand Down

0 comments on commit 9a1cacd

Please sign in to comment.