class PosxmlCompiler::JumpPoint

Constants

INSTRUCTION_WHILE

Attributes

changed[R]
jump[R]
number[R]
persistence[R]
reference[R]
type[R]

Public Class Methods

new(jump, type, persistence, reference, number) click to toggle source
# File lib/posxml_compiler/jump_point.rb, line 7
def initialize(jump, type, persistence, reference, number)
  @jump        = jump
  @type        = type
  @persistence = persistence
  @reference   = reference
  @number      = number
end

Public Instance Methods

add(index, value) click to toggle source
# File lib/posxml_compiler/jump_point.rb, line 26
def add(index, value)
  return if index.nil? || value.nil?
  if self.reference > index
    old_number = @number
    @number += value
    check_chars(old_number, @number)
  end
end
changed?() click to toggle source
# File lib/posxml_compiler/jump_point.rb, line 15
def changed?
  @changed
end
check_chars(old, new) click to toggle source
# File lib/posxml_compiler/jump_point.rb, line 41
def check_chars(old, new)
  addition = new.to_s.size - old.to_s.size
  if addition > 0
    @changed = true
    check_others(addition)
  end
end
check_itself!() click to toggle source
# File lib/posxml_compiler/jump_point.rb, line 19
def check_itself!
  chars = (@number.to_s.size + 1) # \n separator between parameters
  # chars sizes already changed and propogate, so 1 char must not included
  chars -= 1 if changed?
  self.check_others(chars)
end
check_others(value) click to toggle source
# File lib/posxml_compiler/jump_point.rb, line 35
def check_others(value)
  self.jump.jumps.each do |jump_point|
    jump_point.add(self.persistence, value)
  end
end
jump_value() click to toggle source
# File lib/posxml_compiler/jump_point.rb, line 49
def jump_value
  self.number.to_s
end