Hey Lofti,

Yeah, your algorithm will work, AND it should ignore dead code. But
it's not simple; it will either need to do multiple passes, or it will
have to know how to follow multiple branches. For example, when the
algorithm hits L2, it can finally start filling in the stack
information at LOOP. There may be lots of opcodes there; "call Body"
is just an abstraction. The algorithm has to remember that it needs to
resume processing at L3. This is recursive since "Body" may contain
similar loops. And what if that Body contains a branch to a label
AFTER L3?

I was keeping the goal specified in the standard, that the code must
be verifiable with a single forward pass through the code.

I'm really surprised that your dead code example will run on .NET,
because it's definitely invalid, as you said. IMO, the right thing to
do with that is to detect the conflicting stack information and throw
an exception. It's not something Cecil should worry about handling in
a valid way, because there IS no valid way to handle it. No self-
respecting compiler would produce such code.

-- Keith
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to