Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

[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)?

Thanks

Comment on [Parrot] tracing method calls
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"?
Re: [Parrot] tracing method calls
by Limbic~Region (Chancellor) on May 25, 2005 at 13:42 UTC
    Thilosophy,
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://460197]
Approved by monkfan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2014-12-18 07:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (44 votes), past polls