2015-05-04 13:22:22 +02:00
|
|
|
module Compiler
|
|
|
|
|
|
|
|
# return attr_reader :expression
|
|
|
|
def compile_return expression, scope ,method
|
2014-07-14 20:28:21 +02:00
|
|
|
Virtual::Reference.new
|
2014-07-14 15:19:47 +02:00
|
|
|
end
|
2015-05-04 13:22:22 +02:00
|
|
|
def old
|
2014-06-25 01:47:59 +02:00
|
|
|
into = context.function
|
|
|
|
puts "compiling return expression #{expression}, now return in return_regsiter"
|
|
|
|
expression_value = expression.compile(context)
|
|
|
|
# copied from function expression: TODO make function
|
|
|
|
|
2014-06-26 16:52:15 +02:00
|
|
|
return_reg = Virtual::Integer.new(Virtual::RegisterMachine.instance.return_register)
|
|
|
|
if expression_value.is_a?(Virtual::IntegerConstant) or expression_value.is_a?(Virtual::ObjectConstant)
|
2015-05-04 13:22:22 +02:00
|
|
|
return_reg.load into , expression_value
|
2014-06-25 01:47:59 +02:00
|
|
|
else
|
|
|
|
return_reg.move( into, expression_value ) if expression_value.register_symbol != return_reg.register_symbol
|
|
|
|
end
|
|
|
|
#function.set_return return_reg
|
|
|
|
return return_reg
|
|
|
|
end
|
2015-05-04 13:22:22 +02:00
|
|
|
end
|