Class: Whitespace::ISA::Push
- Inherits:
-
Instruction
- Object
- Instruction
- Whitespace::ISA::Push
- Defined in:
- lib/whitespace/instructions/stack_manipulation/push.rb
Instance Attribute Summary collapse
-
#n ⇒ Object
readonly
Returns the value of attribute n.
Attributes inherited from Instruction
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(vm, n) ⇒ Push
constructor
A new instance of Push.
Constructor Details
#initialize(vm, n) ⇒ Push
Returns a new instance of Push.
5 6 7 8 9 10 11 |
# File 'lib/whitespace/instructions/stack_manipulation/push.rb', line 5 def initialize(vm, n) unless Whitespace::Util.is_integer?(n) raise ArgumentError, "must be an integer: #{n}" end super(vm) @n = n end |
Instance Attribute Details
#n ⇒ Object (readonly)
Returns the value of attribute n.
3 4 5 |
# File 'lib/whitespace/instructions/stack_manipulation/push.rb', line 3 def n @n end |
Instance Method Details
#execute ⇒ Object
13 14 15 |
# File 'lib/whitespace/instructions/stack_manipulation/push.rb', line 13 def execute vm.vstack.push n end |