Method: RunningScript.instrument_script

Defined in:
lib/openc3/utilities/running_script.rb

.instrument_script(text, filename, mark_private = false, line_offset: 0, cache: true) ⇒ Object

Raises:



791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
# File 'lib/openc3/utilities/running_script.rb', line 791

def self.instrument_script(text, filename, mark_private = false, line_offset: 0, cache: true)
  if cache and filename and !filename.empty?
    @@file_cache[filename] = text.clone
  end

  ruby_lex_utils = RubyLexUtils.new
  instrumented_text = ''

  @cancel_instrumentation = false
  num_lines = text.num_lines.to_f
  num_lines = 1 if num_lines < 1
  instrumented_text =
    instrument_script_implementation(ruby_lex_utils,
                                     text,
                                     num_lines,
                                     filename,
                                     mark_private,
                                     line_offset)

  raise OpenC3::StopScript if @cancel_instrumentation
  instrumented_text
end