class Fable::Divert

Attributes

external_arguments[RW]
is_conditional[RW]
is_conditional?[RW]
is_external[RW]
is_external?[RW]
pushes_to_stack[RW]
pushes_to_stack?[RW]
stack_push_type[RW]
target_path[RW]
target_pointer[RW]
variable_divert_name[RW]

Public Instance Methods

==(other_divert) click to toggle source
# File lib/fable/divert.rb, line 56
def ==(other_divert)
  if other_divert.is_a?(Divert) && !other_divert.nil?
    if self.has_variable_target? == other_divert.has_variable_target?
      if self.has_variable_target?
        return self.variable_divert_name == other_divert.variable_divert_name
      else
        return self.target_path == other_divert.target_path
      end
    end
  end
  return false
end
has_variable_target?() click to toggle source
# File lib/fable/divert.rb, line 69
def has_variable_target?
  !variable_divert_name.nil?
end
target_path=(value) click to toggle source
# File lib/fable/divert.rb, line 23
def target_path=(value)
  @target_path = value
  @target_pointer = Pointer.null_pointer
end
target_path_string() click to toggle source
# File lib/fable/divert.rb, line 42
def target_path_string
  return nil if target_path.nil?

  return compact_path_string(target_path)
end
target_path_string=(value) click to toggle source
# File lib/fable/divert.rb, line 48
def target_path_string=(value)
  if value.nil?
    self.target_path = nil
  else
    self.target_path = Path.new(value)
  end
end
to_s() click to toggle source
# File lib/fable/divert.rb, line 73
def to_s
  if has_variable_target?
    return "Divert(variable: #{variable_divert_name})"
  elsif target_path.nil?
    return "Divert(null)"
  else
    result = ""

    target_string = target_path.to_s
    target_line_number = debug_line_number_of_path(target_path)
    if !target_line_number.nil?
      target_string = "line #{target_line_number}"
    end

    push_type = ""
    if pushes_to_stack?
      if stack_push_type == :FUNCTION
        push_type = " function"
      else
        push_type = " tunnel"
      end
    end

    "Divert#{'?' if is_conditional?}#{push_type} -> #{target_path_string} (#{target_string})"
  end
end