2017-04-01 21:28:57 +03:00
|
|
|
module Vool
|
|
|
|
class WhileStatement < Statement
|
2017-04-06 16:06:51 +03:00
|
|
|
attr_reader :condition , :statements
|
2017-04-03 11:49:21 +03:00
|
|
|
|
2017-04-06 16:06:51 +03:00
|
|
|
def initialize( condition , statements )
|
2017-04-03 11:49:21 +03:00
|
|
|
@condition = condition
|
2017-04-06 16:06:51 +03:00
|
|
|
@statements = statements
|
|
|
|
simplify_condition
|
2017-04-03 11:49:21 +03:00
|
|
|
end
|
2017-04-06 16:06:51 +03:00
|
|
|
|
|
|
|
def simplify_condition
|
|
|
|
return unless @condition.is_a?(ScopeStatement)
|
|
|
|
@condition = @condition.first if @condition.single?
|
|
|
|
end
|
|
|
|
|
2017-04-08 12:10:42 +03:00
|
|
|
def collect(arr)
|
|
|
|
@condition.collect(arr)
|
|
|
|
@statements.collect(arr)
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2017-04-01 21:28:57 +03:00
|
|
|
end
|
|
|
|
end
|