Class: Bootsnap::CompileCache::ISeq::Compiler
- Inherits:
-
Object
- Object
- Bootsnap::CompileCache::ISeq::Compiler
- Defined in:
- lib/bootsnap/compile_cache/iseq.rb
Instance Attribute Summary collapse
-
#compile_options ⇒ Object
readonly
Returns the value of attribute compile_options.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
-
#initialize(namespace = nil, compile_options = nil) ⇒ Compiler
constructor
A new instance of Compiler.
- #input_to_output(source, path, _kwargs) ⇒ Object
- #input_to_storage(_, path) ⇒ Object
- #storage_to_output(binary, _args) ⇒ Object
Constructor Details
#initialize(namespace = nil, compile_options = nil) ⇒ Compiler
Returns a new instance of Compiler.
25 26 27 28 |
# File 'lib/bootsnap/compile_cache/iseq.rb', line 25 def initialize(namespace = nil, = nil) @namespace = namespace @compile_options = end |
Instance Attribute Details
#compile_options ⇒ Object (readonly)
Returns the value of attribute compile_options.
23 24 25 |
# File 'lib/bootsnap/compile_cache/iseq.rb', line 23 def @compile_options end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
23 24 25 |
# File 'lib/bootsnap/compile_cache/iseq.rb', line 23 def namespace @namespace end |
Instance Method Details
#input_to_output(source, path, _kwargs) ⇒ Object
68 69 70 |
# File 'lib/bootsnap/compile_cache/iseq.rb', line 68 def input_to_output(source, path, _kwargs) RubyVM::InstructionSequence.compile(source, path, path, nil, @compile_options) end |
#input_to_storage(_, path) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/bootsnap/compile_cache/iseq.rb', line 40 def input_to_storage(_, path) iseq = RubyVM::InstructionSequence.compile_file(path, @compile_options) begin iseq.to_binary rescue TypeError UNCOMPILABLE # ruby bug #18250 end end |
#storage_to_output(binary, _args) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bootsnap/compile_cache/iseq.rb', line 55 def storage_to_output(binary, _args) iseq = RubyVM::InstructionSequence.load_from_binary(binary) binary.clear iseq rescue RuntimeError => error if error. == "broken binary format" $stderr.puts("[Bootsnap::CompileCache] warning: rejecting broken binary") nil else raise end end |