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.



1069
1070
1071
# File 'lib/wilson.rb', line 1069

def position
  @position
end

Class Method Details

.on_at(machine, position) ⇒ Object



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

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

Instance Method Details

#bitsObject



1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
# File 'lib/wilson.rb', line 1078

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)


1090
1091
1092
# File 'lib/wilson.rb', line 1090

def label?
  true
end