Hello people, Using BCEL and interested to get some deeper info/ assistance with generation of method code, specifically conditional control structures.
What patterns and techniques are people using to generate these, in the simplest and most understandable way? I'd be interested as to examples and patterns of usage, especially those which are clean and require no workarounds. My current approach is to build the structure in essentially backwards; generate 'else' and 'after' code first so as to get handles to these; insert the 'then' section which must reference 'after'; and finally insert the conditional which must reference 'else'. I'm also using separate InstructionLists to build fragments and later combining these into the method body. Can I use InstructionHandles which reference between lists, at this interim build stage? --- What I'd *really* like to be doing is building structure in-order; and either inserting instructions into structural containers, or fixing up forward references as I reach that point. However the API and code do not look necessarily reliable for creation of branch instruction with null handles. One thing that springs to mind, if anyone is familiar with graphics APIs, is the distinction between coordinate lines and the pixels in-between them. A similar dichotomy applies between Instructions and Handles. If I was talking about an ideal approach for structural generation I'd either be looking for structural containers which could exist stably while empty, and be later inserted into; or Insertion Point handles which existed *between* instructions and of which multiple could exist in stable order without having any actual Instructions separating them. This would allow control-flow 'nodes' to be defined orthogonal to instruction 'transitions' between nodes, but currently my BCEL usage seems awkward due to non-orthogonality in this area. Regards, Thomas SCE Limited
