+_ = require '../third_party/_.js'
 util = require './util'
 
 root = exports ? window.opcodes = {}

  imul: { execute: (rs) -> rs.push new BinaryOp ((a,b) ->
    "gLong.fromInt(#{a}).multiply(gLong.fromInt(#{b})).toInt()"), rs.pop(), rs.pop()
  }
  'ireturn': { execute: (rs) ->
    rv = rs.pop()
    rs.current_block += "return #{rv};"
    rs.finish_block()
  }
  'return': { execute: (rs) -> rs.current_block += 'return;'; rs.finish_block() }
}

root.compile = (class_file) ->

          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
