This project is read-only.

Proper CodeRewriter inheritance?

Topics: Metadata Model, PE Writer, Source Model
Oct 10, 2014 at 4:53 PM
Using CCI AST, I am trying to modify the PeToPeViaCodeModel sample, in order to write a slightly modified PE.

For this, I am extending the class CodeRewriter (instantiated around line 70 in the sample). In my extension, I am overriding the Rewrite method.

As an example, one of the overridings I do is when the parameter is of type IAssignment. However, I can see that there are many assignments that are not traversed with my code, which only gets called when there is an assignment inside a while loop (even for a toy input, such as a variable initialized, and then a while until the variable reaches 0).

Something similar happens if I extend CodeTraverser class, and override the Traverse method. It seems there are other (internal) extensions of CodeTraverser (for instance SwitchReplacer, PatternReplacer, TryCatchReplacer, etc.), which do get called more often than mine.

I guess that I am extending the wrong class (but I cannot actually extend, for instance, PatternReplacer, because it is internal!). Or what else might be the problem?

Thank you all in advance!!