Class: Wilson::Label

Inherits:
Operand show all
Defined in:
lib/wilson.rb

Overview

Label is a known point in the byte stream that we can jmp/loop back to.

Direct Known Subclasses

FutureLabel

Instance Attribute Summary collapse

Attributes inherited from Operand

#machine

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Operand

#initialize, #instructionFromMessage, #method_missing, on, #operand?

Constructor Details

This class inherits a constructor from Wilson::Operand

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wilson::Operand

Instance Attribute Details

#positionObject

Returns the value of attribute position.



993
994
995
# File 'lib/wilson.rb', line 993

def position
  @position
end

Class Method Details

.on_at(machine, position) ⇒ Object



995
996
997
998
999
1000
# File 'lib/wilson.rb', line 995

def self.on_at machine, position
  label = self.new
  label.machine = machine
  label.position = position
  label
end

Instance Method Details

#bitsObject



1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
# File 'lib/wilson.rb', line 1002

def bits
  distance = machine.stream.size - position

  if distance < 256 then
    8
  elsif distance < 65536 then
    16
  else
    32
  end
end

#label?Boolean

Returns:

  • (Boolean)


1014
1015
1016
# File 'lib/wilson.rb', line 1014

def label?
  true
end