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 -~----------~----~----~----~------~----~------~--~---
