Class: Wilson::FutureLabel
Overview
FutureLabel is a label in memory that hasn’t been defined yet and will go back and fill in the appropriate memory bytes later
Instance Attribute Summary collapse
-
#positions ⇒ Object
Returns the value of attribute positions.
Attributes inherited from Label
Attributes inherited from Operand
Instance Method Summary collapse
- #add(aPosition) ⇒ Object
- #future_label? ⇒ Boolean
-
#initialize ⇒ FutureLabel
constructor
A new instance of FutureLabel.
- #plant ⇒ Object
Methods inherited from Label
Methods inherited from Operand
#instructionFromMessage, #method_missing, on, #operand?
Constructor Details
#initialize ⇒ FutureLabel
Returns a new instance of FutureLabel.
1102 1103 1104 1105 |
# File 'lib/wilson.rb', line 1102 def initialize super self.positions = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Wilson::Operand
Instance Attribute Details
#positions ⇒ Object
Returns the value of attribute positions.
1100 1101 1102 |
# File 'lib/wilson.rb', line 1100 def positions @positions end |
Instance Method Details
#add(aPosition) ⇒ Object
1135 1136 1137 |
# File 'lib/wilson.rb', line 1135 def add aPosition positions << aPosition end |
#future_label? ⇒ Boolean
1131 1132 1133 |
# File 'lib/wilson.rb', line 1131 def future_label? position.nil? end |
#plant ⇒ Object
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 |
# File 'lib/wilson.rb', line 1107 def plant self.position = machine.stream.size positions.each do |each| size = machine.stream[each + 1] address = [] case size when 2 then address.push_B(position - each - 2) when 3 then address.push_W(position - each - 3) when 5 then address.push_D(position - each - 5) else raise "unhandled size #{size}" end address.each_with_index do |byte, index| idx = each + index + 1 machine.stream[idx] = byte end end end |