-# what the go_button should say when we're not doing anything
-button_idle_text = 'Compile and Parse'
-# stores the parsed ClassFile object
-class_data = undefined
-controller = null
-
 # Read in a binary classfile synchronously. Return an array of bytes.
 read_classfile = (cls) ->
   rv = null


process_bytecode = (bytecode_string) ->
  bytes_array = util.bytestr_to_array bytecode_string
  class_data = new ClassFile(bytes_array)

compile_source = (java_source, cb) ->
  $('#go_button').text('Compiling...')
  $.ajax 'http://people.cs.umass.edu/~ccarey/javac/', {
    type: 'POST'
    data: { pw: 'coffee', source: java_source }
    dataType: 'text'
    beforeSend: (jqXHR) -> jqXHR.overrideMimeType('text/plain; charset=x-user-defined')
    success:  (data) -> process_bytecode(data); cb?(disassembler.disassemble class_data)
    error: (jqXHR, textStatus, errorThrown) -> 
      cb?("AJAX error: #{errorThrown}")
  }


  controller = null
  java_handler = null
  user_input = (n_bytes, resume) ->
    oldPrompt = controller.promptLabel
    controller.promptLabel = '> '
