         @blocks[d1].in.push idx
         @blocks[d2].in.push idx
 
-    @compile_block(@blocks[0])
+    @compile_block(@blocks[0], 1)
 
-  compile_block: (block) ->
+  compile_block: (block, indent) ->
+    indentation = (" " for i in [0...INDENT_SIZE * indent] by 1).join ''
     if block.in.length <= 1 && block.out.length == 2
-      "if (#{block.cond.condFn block.cond.expr}) {\n#{
-        @compile_block @blocks[block.out[1]]
-      }\n} else {\n#{
-        @compile_block @blocks[block.out[0]]
-      }\n}"
+      "#{indentation}if (#{block.cond.condFn block.cond.expr}) {\n#{
+        @compile_block @blocks[block.out[1]], indent + 1
+      }\n#{indentation}} else {\n#{
+        @compile_block @blocks[block.out[0]], indent + 1
+      }\n#{indentation}}"
     else
-      "#{block}"
+      indentation + block
 
 class BasicBlock
   constructor: ->

          if m.name is '<init>' then class_name
          else if m.name is '<clinit>' then '__clinit__'
          else m.name
        rs = new RuntimeState
        m.code.each_opcode (idx, oc) ->
          opcodes[oc.name]?.execute rs, oc, idx
        "#{name}: function() {\n#{rs.compile()}\n},"
  "var #{class_name} = {\n#{methods.join "\n"}\n};\n"

# TODO: move to a separate file


root = exports ? window.opcodes = {}

INDENT_SIZE = 4

class RuntimeState
  constructor: ->
    @_cs = []
    @locals = []
    @var_count = 0

    @blocks = []
    @block_start_idxs = []
    @new_block 0
