use method missing in resolve method

not just exit
try to print name next
This commit is contained in:
2019-09-15 15:13:11 +03:00
parent 7ee57f2b08
commit d913bb01de
14 changed files with 63 additions and 50 deletions

View File

@ -1,9 +1,17 @@
module Mom
# Init "method" is the first thing that happens in the machine
# There is an inital jump to it, but that's it, no setup, no nothing
#
# The method is in quotes, because it is not really a method, it does not return!!
# This is common to all double underscore "methods", but __init also does not
# rely on the message. In fact it's job is to set up the first message
# and to call the main (possibly later _init_ , single undescrore)
#
class Init < Macro
def to_risc(compiler)
builder = compiler.builder(compiler.source)
main = Parfait.object_space.get_method!(:Space, :main)
# Set up the first message, but advance one, so main has somewhere to return to
builder.build do
factory! << Parfait.object_space.get_factory_for(:Message)
message << factory[:next_object]
@ -11,14 +19,14 @@ module Mom
factory[:next_object] << next_message
end
builder.reset_names
# Set up the call to main, with space as receiver
Mom::MessageSetup.new(main).build_with( builder )
builder.build do
message << message[:next_message]
space? << Parfait.object_space
message[:receiver] << space
end
# set up return address and jump to main
exit_label = Risc.label(compiler.source , "#{compiler.receiver_type.object_class.name}.#{compiler.source.name}" )
ret_tmp = compiler.use_reg(:Label).set_builder(builder)
builder.build do
@ -28,7 +36,7 @@ module Mom
add_code exit_label
end
compiler.reset_regs
Macro.exit_sequence(builder)
Macro.exit_sequence(builder) # exit will use mains return_value as exit_code
return compiler
end
end

View File

@ -1,9 +1,12 @@
module Mom
class MethodMissing < Macro
def to_risc(compiler)
builder = compiler.builder(compiler.source)
builder.prepare_int_return # makes integer_tmp variable as return
Macro.emit_syscall( builder , :exit )
builder = compiler.builder(compiler.source_name)
builder.build do
factory! << Parfait.object_space.get_factory_for(:Integer)
integer_tmp! << factory[:reserve]
Mom::Macro.emit_syscall( builder , :died ) #uses integer_tmp
end
return compiler
end
end