Control-Monad-MultiPass- A Library for Writing Multi-Pass Algorithms.

Safe HaskellSafe



This example is a variation on the assembler example. It illustrates how one might convert a control flow graph into a linear sequence of instructions. The example is less complete than the assembler example, so the output is not real machine code. Instead the output is a simple serialised representation of the control flow graph.

In this example, the control flow graph is represented as a Array, which is an immutable datatype. The example can also be implemented with a mutable representation of the control flow graph, as shown in Control.Monad.MultiPass.Example.CFG2.


newtype Node Source


Node Int 


emitCFG :: CFG -> ST2 r w (ST2Array r w Position Int)Source