I use the technique to create the instruction (of which gets appended at a later moment) and references it (I'd guess it can be considered as same approach as you have described). The bad thing is that it has to be created in forehand as supposed to a "synthetic" label that the actual il can be created at a later moment. But it is suffient for me anyhow, //Mario
On Sat, Jan 31, 2009 at 9:42 PM, Keith <[email protected]> wrote: > > On Jan 30, 6:12 am, Augusto Radtke <[email protected]> wrote: > > how is your approach for generating code that needs to jump > > ahead (like a switch block), do you build from bottom-up or there is > another > > interesting technique? > > I'm not sure how it works with Cecil, but the typical compiler > technique is to have a "label" pseudo-instruction which is the target > of all branching instructions (including br, leave, switch, etc.). It > has no length and emits no opcode. You emit it like other > instructions, independently of (i.e. before or after) those which > branch to it. This allows emitting your code top-down, which is WAY > easier than bottom up. I use this for my compiler, so all code can be > emitted first-to-last, never needing to back up to emit anything. > > > --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~---
