From 4d4b691a4b2bf8b3f1f60c811ec60b8e78e058a8 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 2 Aug 2018 17:34:44 +0300 Subject: [PATCH] adds a return jump that will be used to jump to the return sequence --- lib/mom/instruction/instruction.rb | 1 + lib/mom/instruction/return_jump.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 lib/mom/instruction/return_jump.rb diff --git a/lib/mom/instruction/instruction.rb b/lib/mom/instruction/instruction.rb index de6cc5a4..0e4d5d21 100644 --- a/lib/mom/instruction/instruction.rb +++ b/lib/mom/instruction/instruction.rb @@ -37,6 +37,7 @@ require_relative "resolve_method" require_relative "truth_check" require_relative "not_same_check" require_relative "jump" +require_relative "return_jump" require_relative "slot_load" require_relative "return_sequence" require_relative "message_setup" diff --git a/lib/mom/instruction/return_jump.rb b/lib/mom/instruction/return_jump.rb new file mode 100644 index 00000000..d5de1131 --- /dev/null +++ b/lib/mom/instruction/return_jump.rb @@ -0,0 +1,16 @@ +module Mom + + # the return jump jumps to the return label + # the method setup is such that there is exactly one return_label in a method + # This is so the actual code that executes the return can be quite complicated + # and big, and won't be repeated + # + class ReturnJump < Instruction + + def to_risc(compiler) + Risc::Branch.new(self , compiler.return_label) + end + end + + +end