From bae7f5dcb139bccdaa2bcf2cd4bfabd2760feb3c Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 9 Aug 2015 00:52:47 +0300 Subject: [PATCH] better to_s for load constant --- lib/register/instructions/load_constant.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/register/instructions/load_constant.rb b/lib/register/instructions/load_constant.rb index 614125d2..10501ffd 100644 --- a/lib/register/instructions/load_constant.rb +++ b/lib/register/instructions/load_constant.rb @@ -13,8 +13,21 @@ module Register attr_accessor :register , :constant def to_s - "LoadConstant: #{register} <- #{constant}" + "LoadConstant: #{register} <- #{constant_str}" end + private + def constant_str + case @constant + when String , Symbol , Fixnum , Integer + @constant.to_s + else + if( @constant.respond_to? :sof_reference_name ) + constant.sof_reference_name + else + constant.class.name.to_s + end + end + end end end