Module: Vernacular::BootsnapMixin

Defined in:
lib/vernacular.rb

Overview

Module that gets included into ‘Bootsnap::CompileCache::ISeq` in order to hook into the bootsnap compilation process.

Instance Method Summary collapse

Instance Method Details

#input_to_storage(contents, filepath) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vernacular.rb', line 32

def input_to_storage(contents, filepath)
  if filepath == PARSER_PATH
    raise ::Bootsnap::CompileCache::Uncompilable, "can't compile parser"
  end

  contents = ::Vernacular.modify(contents)
  iseq = RubyVM::InstructionSequence.compile(contents, filepath, filepath)
  iseq.to_binary
rescue SyntaxError
  raise ::Bootsnap::CompileCache::Uncompilable, 'syntax error'
end