Class: Wilson::Operand
Overview
Operand is any kind of operand used in a command or instruction, eg: registers, memory addresses, labels, immediates, etc.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bits ⇒ Object
Returns the value of attribute bits.
-
#machine ⇒ Object
Returns the value of attribute machine.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(bits = nil, machine = nil) ⇒ Operand
constructor
TODO: fix all initialize methods from here down to have cleaner args.
- #instructionFromMessage(msg, *args, &b) ⇒ Object
- #method_missing(msg, *args, &b) ⇒ Object
- #operand? ⇒ Boolean
Constructor Details
#initialize(bits = nil, machine = nil) ⇒ Operand
TODO: fix all initialize methods from here down to have cleaner args
810 811 812 813 |
# File 'lib/wilson.rb', line 810 def initialize bits = nil, machine = nil @bits = bits @machine = machine end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(msg, *args, &b) ⇒ Object
815 816 817 |
# File 'lib/wilson.rb', line 815 def method_missing msg, *args, &b super unless self.instructionFromMessage(msg, *args, &b).assemble end |
Instance Attribute Details
#bits ⇒ Object
Returns the value of attribute bits.
801 802 803 |
# File 'lib/wilson.rb', line 801 def bits @bits end |
#machine ⇒ Object
Returns the value of attribute machine.
801 802 803 |
# File 'lib/wilson.rb', line 801 def machine @machine end |
Class Method Details
.on(machine) ⇒ Object
803 804 805 806 807 |
# File 'lib/wilson.rb', line 803 def self.on machine x = self.new x.machine = machine x end |
Instance Method Details
#instructionFromMessage(msg, *args, &b) ⇒ Object
819 820 821 |
# File 'lib/wilson.rb', line 819 def instructionFromMessage msg, *args, &b Instruction. machine, [msg, self, *args] + (b ? [b] : []) end |
#operand? ⇒ Boolean
823 824 825 |
# File 'lib/wilson.rb', line 823 def operand? true end |