May 16, 2010 at 7:59 PM
Edited May 16, 2010 at 8:13 PM
Ok. I found the problem. I was calling a static method so ThisArgument was not set but I didn't set IsStatic to true.
Now this is a bug in my code but it stresses a weak point in CCI: it's very easy to generate bad metadata with it.
Does it make any sense to generate a non static call to a static method?
Why nothing happens if an instance call has a dummy "this" instance?
If you want to make it "smart" CCI should treat a method call without "this" instance to a static method as a static call.
Otherwise - if you want it to behave in a "strict" way - it should complain or abort.
This piece of code has the responsability to emit code for both loading the "this" instance and calling the method so it has all the information to decide if something is wrong.
Another thing: maybe using a normal Int32 for the "current simulated stack size" would allow you to detect similar problems in general.