5346077a72
thus every method only has one exit should make multi return messages smaller especially when we have escape analisis (maybe will help with inlining too)
29 lines
802 B
Ruby
29 lines
802 B
Ruby
module Vool
|
|
class ReturnStatement < Statement
|
|
|
|
attr_reader :return_value
|
|
|
|
def initialize(value)
|
|
@return_value = value
|
|
end
|
|
|
|
def each(&block)
|
|
block.call(@return_value)
|
|
end
|
|
|
|
# Since the return is normalized to only allow simple values it is simple.
|
|
# To return form a method in mom instructions we only need to do two things:
|
|
# - store the given return value, this is a SlotMove
|
|
# - activate return sequence (reinstantiate old message and jump to return address)
|
|
def to_mom( compiler )
|
|
ret = Mom::SlotLoad.new( [:message , :return_value] ,
|
|
@return_value.slot_definition(compiler) )
|
|
ret << Mom::ReturnJump.new
|
|
end
|
|
|
|
def to_s(depth = 0)
|
|
at_depth(depth , "return #{@return_value.to_s}")
|
|
end
|
|
end
|
|
end
|