2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
|
|
|
class ReturnStatement < Statement
|
|
|
|
include Normalizer
|
|
|
|
|
|
|
|
attr_reader :return_value
|
|
|
|
|
|
|
|
def initialize(value)
|
2019-08-19 10:33:12 +02:00
|
|
|
@return_value = value || NilConstant.new
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
|
|
|
|
2019-10-03 23:36:49 +02:00
|
|
|
def to_sol
|
|
|
|
val , hoisted = *normalized_sol(@return_value)
|
|
|
|
me = Sol::ReturnStatement.new(val)
|
2019-08-16 19:39:08 +02:00
|
|
|
return me unless hoisted
|
2019-10-03 23:36:49 +02:00
|
|
|
Sol::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
|