Module: ASTTransform::InstructionSequence::Mixin

Defined in:
lib/ast_transform/instruction_sequence/mixin.rb

Instance Method Summary collapse

Instance Method Details

#load_iseq(source_path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ast_transform/instruction_sequence/mixin.rb', line 11

def load_iseq(source_path)
  return ASTTransform::MixinUtils.try_super(self, :load_iseq, source_path) if source_path == __FILE__

  # Binary read avoids encoding errors during the fast-path check below.
  # Downstream (Prism, RubyVM::InstructionSequence) handle encoding natively
  # via magic comments, so we never need to set it ourselves.
  source = File.binread(source_path)

  return ASTTransform::MixinUtils.try_super(self, :load_iseq, source_path) unless source.include?("transform!".b)

  ASTTransform::InstructionSequence.source_to_transformed_iseq(source, source_path)
end