2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
|
|
|
class ReturnStatement < Statement
|
|
|
|
include Normalizer
|
|
|
|
|
|
|
|
attr_reader :return_value
|
|
|
|
|
|
|
|
def initialize(value)
|
2019-08-17 22:27:55 +02:00
|
|
|
@return_value = value || NilConstant.new
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
|
|
|
|
2018-07-19 13:59:10 +02:00
|
|
|
def to_vool
|
2019-08-16 19:39:08 +02:00
|
|
|
val , hoisted = *normalized_vool(@return_value)
|
|
|
|
me = Vool::ReturnStatement.new(val)
|
|
|
|
return me unless hoisted
|
|
|
|
Vool::Statements.new( hoisted ) << me
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_s(depth = 0)
|
|
|
|
at_depth(depth , "return #{@return_value.to_s}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|