From 493b02674cb7ec029ab06e9a2ff595a0bc3084c6 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 30 Sep 2014 12:08:12 +0300 Subject: [PATCH] remove some boiler --- lib/register/instruction.rb | 14 -------------- lib/virtual/object.rb | 3 +++ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/register/instruction.rb b/lib/register/instruction.rb index d6374b01..47398864 100644 --- a/lib/register/instruction.rb +++ b/lib/register/instruction.rb @@ -19,14 +19,6 @@ module Register def opcode @attributes[:opcode] end - #abstract, only should be called from derived - def to_s - atts = @attributes.dup - atts.delete(:opcode) - atts.delete(:update_status) - atts.delete(:condition_code) if atts[:condition_code] == :al - atts.empty? ? "" : ", #{atts}" - end # returns an array of registers (RegisterReferences) that this instruction uses. # ie for r1 = r2 + r3 # which in assembler is add r1 , r2 , r3 @@ -122,9 +114,6 @@ module Register def assigns [@result.register] end - def to_s - "#{opcode} #{result.to_asm} , #{left.to_asm} , #{right.to_asm} #{super}" - end end class CompareInstruction < Instruction def initialize left , right , options = {} @@ -158,9 +147,6 @@ module Register def assigns [@to.register] end - def to_s - "#{opcode} #{@to.to_asm} , #{@from.to_asm} #{super}" - end end class CallInstruction < Instruction def initialize first , options = {} diff --git a/lib/virtual/object.rb b/lib/virtual/object.rb index 7d8509e1..43aa9278 100644 --- a/lib/virtual/object.rb +++ b/lib/virtual/object.rb @@ -40,6 +40,9 @@ module Virtual def inspect Sof::Writer.write(self) end + def to_s + inspect + end def mem_length raise "abstract #{self}" end