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.



1050
1051
1052
# File 'lib/wilson.rb', line 1050

def position
  @position
end

Class Method Details

.on_at(machine, position) ⇒ Object



1052
1053
1054
1055
1056
1057
# File 'lib/wilson.rb', line 1052

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

Instance Method Details

#bitsObject



1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
# File 'lib/wilson.rb', line 1059

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)


1071
1072
1073
# File 'lib/wilson.rb', line 1071

def label?
  true
end