Class: Basic101::NextStatement
- Defined in:
- lib/basic101/next_statement.rb
Instance Attribute Summary
Attributes inherited from Statement
Instance Method Summary collapse
- #execute(runtime) ⇒ Object
-
#initialize(reference) ⇒ NextStatement
constructor
A new instance of NextStatement.
Methods inherited from Statement
#data_items, #exec, #line_number, #raise_error_with_line_number
Methods included from Identity
Constructor Details
#initialize(reference) ⇒ NextStatement
Returns a new instance of NextStatement.
9 10 11 |
# File 'lib/basic101/next_statement.rb', line 9 def initialize(reference) @reference = reference end |
Instance Method Details
#execute(runtime) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/basic101/next_statement.rb', line 13 def execute(runtime) for_statement = if @reference.nil? runtime.for_stack.top else runtime.for_stack[@reference] end raise NextWithoutFor unless for_statement for_statement.increment(runtime) if for_statement.done?(runtime) for_statement.delete_from_stack(runtime) else for_statement.goto_following_statement(runtime) end end |