Class: ExecDoCountInstruction

Inherits:
Instruction show all
Defined in:
lib/instructions/exec/exec_do_count.rb

Instance Attribute Summary

Attributes inherited from Instruction

#context

Instance Method Summary collapse

Methods inherited from Instruction

all_instructions, #go, inherited, #initialize, #needs, #pushes, to_nudgecode

Constructor Details

This class inherits a constructor from Instruction

Instance Method Details

#cleanupObject



18
19
20
21
22
# File 'lib/instructions/exec/exec_do_count.rb', line 18

def cleanup
  recursor = CodeblockPoint.new([ValuePoint.new("int",0), @one_less,
    InstructionPoint.new("exec_do_range"),@code])
  pushes :exec, recursor
end

#deriveObject



13
14
15
16
# File 'lib/instructions/exec/exec_do_count.rb', line 13

def derive
  raise InstructionMethodError, "#{self.class} needs a positive argument" if @destination.value < 1
  @one_less = ValuePoint.new("int",@destination.value-1)
end

#preconditions?Boolean

Returns:

  • (Boolean)


2
3
4
5
6
# File 'lib/instructions/exec/exec_do_count.rb', line 2

def preconditions?
  needs ExecDoRangeInstruction
  needs :exec, 1
  needs :int, 1
end

#setupObject



8
9
10
11
# File 'lib/instructions/exec/exec_do_count.rb', line 8

def setup
  @destination = @context.pop(:int)
  @code = @context.pop(:exec)
end