From c3318f8f612dbf4ae8fc44dd39b67214c29530f4 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 14 Sep 2017 18:42:01 +0300 Subject: [PATCH] send refactor, green by stubbing --- lib/vool/statements/send_statement.rb | 27 ++++++++++++------- .../to_mom/send/test_send_cached_simple.rb | 10 +++++-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/vool/statements/send_statement.rb b/lib/vool/statements/send_statement.rb index 7b91a626..6b77e5f3 100644 --- a/lib/vool/statements/send_statement.rb +++ b/lib/vool/statements/send_statement.rb @@ -74,16 +74,11 @@ module Vool # if not, change and find method for the type (simple_call to resolve_method) # conceptually easy in ruby, but we have to compile that "easy" ruby def cache_check(in_method) - # return if cached_type == current_type - # cached_type = current_type - # cached_method = current_type.resolve_method(method.name) - check = [] - cached_type = Mom::SlotDefinition.new(:message , [:frame , type_var_name]) - current_type = Mom::SlotDefinition.new(:message , [:self , :type]) - cond = Mom::NotSameCheck.new(cached_type , current_type) - if_true = nil #@if_true.to_mom( in_method ) #find and assign - check << Mom::IfStatement.new( cond , if_true ) - check + # if cached_type != current_type + # cached_type = current_type + # cached_method = current_type.resolve_method(method.name) + if_true = [build_type_cache_update , build_method_cache_update] #@if_true.to_mom( in_method ) #find and assign + [Mom::IfStatement.new( build_condition , if_true )] end # this may look like a simple_call, but the difference is that we don't know @@ -105,5 +100,17 @@ module Vool def type_var_name "cached_type_#{object_id}" end + private + def build_condition + cached_type = Mom::SlotDefinition.new(:message , [:frame , type_var_name]) + current_type = Mom::SlotDefinition.new(:message , [:self , :type]) + Mom::NotSameCheck.new(cached_type , current_type) + end + def build_type_cache_update + + end + def build_method_cache_update + + end end end diff --git a/test/vool/to_mom/send/test_send_cached_simple.rb b/test/vool/to_mom/send/test_send_cached_simple.rb index e8360c80..5b80d61d 100644 --- a/test/vool/to_mom/send/test_send_cached_simple.rb +++ b/test/vool/to_mom/send/test_send_cached_simple.rb @@ -13,8 +13,14 @@ module Vool def test_compiles_not_array assert Array != @stats.class , @stats end - def test_class_compiles - assert_equal Mom::IfStatement , @first.class , @stats + def test_if_first + assert_equal Mom::IfStatement , @first.class , @first + end + def test_if_condition_set + assert_equal Mom::NotSameCheck , @first.condition.class , @first + end + def test_if_true_set + assert @first.if_true , @first end def est_slot_is_set assert @stats.first.left