Class: Nydp::ExecuteConditionalInstruction
- Inherits:
-
Object
- Object
- Nydp::ExecuteConditionalInstruction
- Extended by:
- Helper
- Defined in:
- lib/nydp/cond.rb
Instance Attribute Summary collapse
-
#when_false ⇒ Object
readonly
Returns the value of attribute when_false.
-
#when_true ⇒ Object
readonly
Returns the value of attribute when_true.
Instance Method Summary collapse
- #execute(vm) ⇒ Object
-
#initialize(when_true, when_false) ⇒ ExecuteConditionalInstruction
constructor
A new instance of ExecuteConditionalInstruction.
- #inspect ⇒ Object
- #to_s ⇒ Object
Methods included from Helper
cons, list, literal?, pair?, sym, sym?
Constructor Details
#initialize(when_true, when_false) ⇒ ExecuteConditionalInstruction
Returns a new instance of ExecuteConditionalInstruction.
6 7 8 |
# File 'lib/nydp/cond.rb', line 6 def initialize when_true, when_false @when_true, @when_false = when_true, when_false end |
Instance Attribute Details
#when_false ⇒ Object (readonly)
Returns the value of attribute when_false.
4 5 6 |
# File 'lib/nydp/cond.rb', line 4 def when_false @when_false end |
#when_true ⇒ Object (readonly)
Returns the value of attribute when_true.
4 5 6 |
# File 'lib/nydp/cond.rb', line 4 def when_true @when_true end |
Instance Method Details
#execute(vm) ⇒ Object
10 11 12 13 14 |
# File 'lib/nydp/cond.rb', line 10 def execute vm arg = vm.pop_arg truth = !Nydp.NIL.is?(arg) vm.push_instructions (truth ? when_true : when_false), vm.peek_context end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/nydp/cond.rb', line 16 def inspect "when_true:#{when_true.inspect}:when_false:#{when_false.inspect}" end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/nydp/cond.rb', line 19 def to_s "#{when_true.car.to_s} #{when_false.car.to_s}" end |