Module: Datadog::CI::Utils::SourceCode

Defined in:
lib/datadog/ci/utils/source_code.rb,
ext/datadog_ci_native/datadog_source_code.c

Class Method Summary collapse

Class Method Details

._native_last_line_from_iseq(iseqw) ⇒ Object



11
12
13
14
15
16
17
18
# File 'ext/datadog_ci_native/datadog_source_code.c', line 11

static VALUE last_line_from_iseq(VALUE self, VALUE iseqw) {
  const rb_iseq_t *iseq = rb_iseqw_to_iseq(iseqw);

  int line;
  rb_iseq_code_location(iseq, NULL, NULL, &line, NULL);

  return INT2NUM(line);
}

.last_line(target) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/datadog/ci/utils/source_code.rb', line 15

def self.last_line(target)
  return nil if target.nil?
  return nil unless LAST_LINE_AVAILABLE

  # Ruby has outdated RBS for RubyVM::InstructionSequence where method `of` is not defined
  # steep:ignore:start
  iseq = RubyVM::InstructionSequence.of(target)
  return nil unless iseq.is_a?(RubyVM::InstructionSequence)
  # steep:ignore:end

  # this function is implemented in ext/datadog_ci_native/datadog_source_code.c
  _native_last_line_from_iseq(iseq)
end