adding register_names to instruction protocol
This commit is contained in:
parent
8df1b8126f
commit
d0b734c57c
@ -11,6 +11,11 @@ module Risc
|
||||
end
|
||||
attr_reader :label
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[]
|
||||
end
|
||||
|
||||
def to_s
|
||||
case label
|
||||
when Label
|
||||
|
@ -12,6 +12,11 @@ module Risc
|
||||
end
|
||||
attr_reader :register
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[register.symbol ]
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source( register.to_s)
|
||||
end
|
||||
|
@ -10,6 +10,11 @@ module Risc
|
||||
end
|
||||
attr_reader :method
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[]
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source method.name
|
||||
end
|
||||
|
@ -11,6 +11,11 @@ module Risc
|
||||
end
|
||||
attr_reader :register
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[register.symbol]
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source "#{register} "
|
||||
end
|
||||
|
@ -29,6 +29,13 @@ module Risc
|
||||
end
|
||||
attr_accessor :array , :index , :register
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
names = [array.symbol , register.symbol]
|
||||
names << index.symbol if index.is_a?(RegisterValue)
|
||||
names
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source "#{array}[#{index}] -> #{register}"
|
||||
end
|
||||
|
@ -41,6 +41,11 @@ module Risc
|
||||
def precheck
|
||||
end
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
raise "Not implemented in #{self.class}"
|
||||
end
|
||||
|
||||
def to_cpu( translator )
|
||||
translator.translate( self )
|
||||
end
|
||||
|
@ -23,6 +23,11 @@ module Risc
|
||||
end
|
||||
attr_reader :name , :address
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[]
|
||||
end
|
||||
|
||||
def to_cpu(translator)
|
||||
@cpu_label ||= super
|
||||
end
|
||||
|
@ -14,6 +14,11 @@ module Risc
|
||||
end
|
||||
attr_accessor :register , :constant
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[register.symbol]
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source "#{register} <- #{constant_str}"
|
||||
end
|
||||
|
@ -17,6 +17,11 @@ module Risc
|
||||
end
|
||||
attr_accessor :register , :constant
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[register.symbol]
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source "#{register} <- #{constant}"
|
||||
end
|
||||
|
@ -32,6 +32,11 @@ module Risc
|
||||
end
|
||||
attr_reader :operator, :left , :right , :result
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[left.symbol , right.symbol, result.symbol]
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source "#{left} #{operator} #{right}"
|
||||
end
|
||||
|
@ -27,6 +27,13 @@ module Risc
|
||||
end
|
||||
attr_accessor :register , :array , :index
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
names = [array.symbol , register.symbol]
|
||||
names << index.symbol if index.is_a?(RegisterValue)
|
||||
names
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source "#{register} -> #{array}[#{index}]"
|
||||
end
|
||||
|
@ -16,6 +16,11 @@ module Risc
|
||||
end
|
||||
attr_reader :name
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[]
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source name
|
||||
end
|
||||
|
@ -25,6 +25,11 @@ module Risc
|
||||
end
|
||||
attr_reader :from, :to
|
||||
|
||||
# return an array of names of registers that is used by the instruction
|
||||
def register_names
|
||||
[from.symbol , to.symbol]
|
||||
end
|
||||
|
||||
def to_s
|
||||
class_source "#{from} -> #{to}"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user