From dd0674c7dd0c4c323d55ea39e049bad27363d38c Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 26 Aug 2014 12:05:49 +0300 Subject: [PATCH] dummy implementation of enter and return --- lib/register/assembler.rb | 6 ------ lib/register/enter_implementation.rb | 13 +++++++++++++ lib/register/register_machine.rb | 2 ++ lib/register/return_implementation.rb | 12 ++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 lib/register/enter_implementation.rb create mode 100644 lib/register/return_implementation.rb diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index 7737584b..bcc8aa2e 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -51,12 +51,6 @@ module Register link_object code , at end end - def link_MethodEnter str , at - end - def link_MethodReturn str , at - end - def link_FunctionCall str , at - end def link_String str , at end def link_Symbol sym , at diff --git a/lib/register/enter_implementation.rb b/lib/register/enter_implementation.rb new file mode 100644 index 00000000..f0663a02 --- /dev/null +++ b/lib/register/enter_implementation.rb @@ -0,0 +1,13 @@ +module Register + + class EnterImplementation + def run block + block.codes.dup.each do |code| + next unless code.is_a? Virtual::MethodEnter + # save return register and create a new frame + block.replace(code , [] ) + end + end + end + Virtual::BootSpace.space.add_pass_after EnterImplementation , CallImplementation +end diff --git a/lib/register/register_machine.rb b/lib/register/register_machine.rb index f9c0c18b..ddb23206 100644 --- a/lib/register/register_machine.rb +++ b/lib/register/register_machine.rb @@ -149,5 +149,7 @@ require_relative "register_reference" require_relative "get_implementation" require_relative "set_implementation" require_relative "call_implementation" +require_relative "enter_implementation" +require_relative "return_implementation" require "arm/arm_machine" require_relative "assembler" \ No newline at end of file diff --git a/lib/register/return_implementation.rb b/lib/register/return_implementation.rb new file mode 100644 index 00000000..16d3aad7 --- /dev/null +++ b/lib/register/return_implementation.rb @@ -0,0 +1,12 @@ +module Register + class ReturnImplementation + def run block + block.codes.dup.each do |code| + next unless code.is_a? Virtual::MethodReturn +# call = RegisterMachine.instance.call( code.method ) + block.replace(code , [] ) + end + end + end + Virtual::BootSpace.space.add_pass_after ReturnImplementation , CallImplementation +end