Method: AsmCC#run

Defined in:
lib/asmcc.rb

#runObject



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/asmcc.rb', line 390

def run
  parse_settings!

  compiled = nil
  file = nil

  if @input.nil?
    templ = template
  else
    templ = IO.read @input
  end

  file = Tempfile.new(['asmcc', file_extension])

  path = file.path

  file.print template
  file.close()

  compiled = nil
  tried_once = false

  while true
    edit_file path if @input.nil? or tried_once
    tried_once = true
    result = invoke_compiler path
    if result[0]
      compiled = result[1]
      break
    elsif not try_again? "Compilation failed, try again?", true
      exit(1)
    end
  end

  if @edit_asm or not @output.nil?
    out_path = @output.nil? ? path : @output
    File.open(out_path, 'w') { |f| output f, (IO.read path), compiled }
    edit_file out_path if @edit_asm
  else
    output $stdout, (IO.read path), compiled
  end
end