module Bootsnap::CompileCache::ISeq

def self.compile_option_updated

def self.compile_option_updated
  option = RubyVM::InstructionSequence.compile_option
  crc = Zlib.crc32(option.inspect)
  Bootsnap::CompileCache::Native.compile_option_crc32 = crc
end

def self.input_to_output(_)

def self.input_to_output(_)
  nil # ruby handles this
end

def self.input_to_storage(_, path)

def self.input_to_storage(_, path)
  RubyVM::InstructionSequence.compile_file(path).to_binary
rescue SyntaxError
  raise Uncompilable, 'syntax error'
end

def self.install!

def self.install!
  Bootsnap::CompileCache::ISeq.compile_option_updated
  class << RubyVM::InstructionSequence
    prepend InstructionSequenceMixin
  end
end

def self.storage_to_output(binary)

def self.storage_to_output(binary)
  RubyVM::InstructionSequence.load_from_binary(binary)
rescue RuntimeError => e
  if e.message == 'broken binary format'
    STDERR.puts "[Bootsnap::CompileCache] warning: rejecting broken binary"
    return nil
  else
    raise
  end
end