Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

[Parrot] tracing method calls

by Thilosophy (Curate)
on May 25, 2005 at 00:30 UTC ( #460197=perlquestion: print w/replies, xml ) Need Help??
Thilosophy has asked for the wisdom of the Perl Monks concerning the following question:

Monks and pirates,

I have a Parrot assembly language / runtime question:

As part of a test case I need to trace method calls on a certain PMC instance. I set out to write a Decorator class, that will wrap the original object and print trace messages before calling any of the methods.

Now, if I were to do this in Perl, I would use AUTOLOAD to generate all the wrapper methods. Can I do something similar in Parrot IMC or do I have to manually code them (probably using macros)?

Also, do I need to use this Decorator at all? Is there an easier way to get a trace output of all method calls (I would need this filtered for only a specific class if not instance)?


Replies are listed 'Best First'.
Re: [Parrot] tracing method calls
by Limbic~Region (Chancellor) on May 25, 2005 at 13:42 UTC
    The number of Parrot savvy monks is still quite low in comparison to the p6.internals mailing list. I would recommend cross posting there. If you get a good response, reply to your own node here so everyone benefits.

    Cheers - L~R

Re: [Parrot] tracing method calls
by chip (Curate) on Jun 14, 2005 at 07:59 UTC
    I'm just learning the code base ... which is an odd position for a Fearless Leader ("OK, Mr. President. You've been elected by this country ... no, the top of the globe..."). But it looks to me like to do what you want without writing a bunch of explicit wrappers, until we have a PerlObject PMC that implements AUTOLOAD which could handle it, you'll have to write a PMC of your own.

    I'll call this new PMC ObjectWrapper. Give ObjectWrapper a customized find_method() vtable function that always returns your chosen wrapper function, which can do whatever recording you like then look up the actual method by name in the actual target object.

    This is all pretty much the way it should be, except (1) we will have autoload-ish behavior available in a standard PMC eventually, and (2) there's no reason this sort of custom behavior should require writing in C anyway. Eventually. :-,

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Re: [Parrot] tracing method calls
by Anonymous Monk on May 25, 2005 at 01:48 UTC
    So what RegExp are you running on your end that translates "Perl Monks" to "Parrot Pirates"?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://460197]
Approved by monkfan
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2018-06-19 00:32 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.