It is not possible to do this without change to code generation at this point. 
Essentially you could do something like this:

public class MyCallbackClass {
    public void MyCallback() {
        //
    }
}

And then emit call to this utility wherever you like:
cg.EmitCall(typeof(MyCallbackClass).GetMethod("MyCallback"))

You can then control the granularity at which you call this. Per statement, or 
even per expression (I am a bit confused about your mention of operators below, 
whether you want to do this for each expression, but it is certainly possible 
as well).

For starters, what you could easily do to get feel for things would be to 
modify SuiteStatement's Emit method (which only loops through enclosed 
statements and emits each of them) and add the above "cg.EmitCall" for each 
statement, run your repro, say:

X = 1
X = 2
X = 3

And put breakpoint in the "MyCallback", or better yet, run the repro:

Ipy.exe -X:SaveAssemblies x.py

And examine the x.exe we'll generate with ildasm or reflector. Then you can add 
calls to your callbacks wherever desired.

Hope this helps
Martin


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Markus Hajek
Sent: Monday, April 16, 2007 3:37 AM
To: 'Discussion of IronPython'
Subject: [IronPython] Callback per statement


Hi,

is there a way to execute a callback whenever a Python statement is about to be 
executed (or just has executed)? With Python statements, I mean method calls, 
operators, assignments.

And if there's no such way, how would I have to go about changing code 
generation to facilitate that?

Many thanks,

Markus Hajek

Team Vienna - Kazemi, Hajek & Pisarik OG
_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to