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.
1026 1027 1028 1029 |
# File 'lib/wilson.rb', line 1026 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.
1024 1025 1026 |
# File 'lib/wilson.rb', line 1024 def positions @positions end |
Instance Method Details
#add(aPosition) ⇒ Object
1059 1060 1061 |
# File 'lib/wilson.rb', line 1059 def add aPosition positions << aPosition end |
#future_label? ⇒ Boolean
1055 1056 1057 |
# File 'lib/wilson.rb', line 1055 def future_label? position.nil? end |
#plant ⇒ Object
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 |
# File 'lib/wilson.rb', line 1031 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 |