to_s for reg instructions
This commit is contained in:
parent
fa552bf751
commit
139b0174d8
@ -8,10 +8,10 @@ module Register
|
||||
raise "No block" unless to
|
||||
@block = to
|
||||
end
|
||||
attr_reader :block
|
||||
attr_reader :block
|
||||
|
||||
def to_s
|
||||
"Branch(to: #{block.name})"
|
||||
"Branch(block: #{block.name})"
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -8,5 +8,10 @@ module Register
|
||||
@method = method
|
||||
end
|
||||
attr_reader :method
|
||||
|
||||
def to_s
|
||||
"FunctionCall(#{method.name})"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -9,5 +9,10 @@ module Register
|
||||
@index = index
|
||||
end
|
||||
attr_reader :register , :index
|
||||
|
||||
def to_s
|
||||
"FunctionReturn(#{register}: #{index})"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -27,6 +27,11 @@ module Register
|
||||
raise "Not register #{array}" unless Register::RegisterReference.look_like_reg(array)
|
||||
end
|
||||
attr_accessor :register , :array , :index
|
||||
|
||||
def to_s
|
||||
"GetSlot(#{register}: #{array}[#{index}])"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Produce a GetSlot instruction.
|
||||
|
@ -10,5 +10,10 @@ module Register
|
||||
@constant = constant
|
||||
end
|
||||
attr_accessor :register , :constant
|
||||
|
||||
def to_s
|
||||
"LoadConstant(#{register}: #{constant})"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -15,11 +15,16 @@ module Register
|
||||
# First argument from
|
||||
# second arguemnt to
|
||||
#
|
||||
# Note: this may be reversed from some assembler notations (also arm)
|
||||
# Note: this may be reversed from some assembler notations (also arm)
|
||||
def initialize from , to
|
||||
@from = wrap_register(from)
|
||||
@to = wrap_register(to)
|
||||
end
|
||||
attr_reader :from, :to
|
||||
|
||||
def to_s
|
||||
"RegisterTransfer(#{from} -> #{to})"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -12,6 +12,11 @@ module Register
|
||||
@index = index
|
||||
end
|
||||
attr_reader :register , :index
|
||||
|
||||
def to_s
|
||||
"SaveReturn(#{register}[#{index}])"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Produce a SaveReturn instruction.
|
||||
|
@ -26,6 +26,10 @@ module Register
|
||||
raise "Not register #{array}" unless Register::RegisterReference.look_like_reg(array)
|
||||
end
|
||||
attr_accessor :register , :array , :index
|
||||
def to_s
|
||||
"SetSlot(#{register}: #{array}[#{index}])"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Produce a SetSlot instruction.
|
||||
|
@ -13,5 +13,10 @@ module Register
|
||||
@name = name
|
||||
end
|
||||
attr_reader :name
|
||||
|
||||
def to_s
|
||||
"Syscall(#{name})"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -17,6 +17,9 @@ module Register
|
||||
@symbol = r
|
||||
end
|
||||
|
||||
def to_s
|
||||
symbol.to_s
|
||||
end
|
||||
def self.convert something
|
||||
return something unless something.is_a? Symbol
|
||||
return something unless look_like_reg(something)
|
||||
|
Loading…
Reference in New Issue
Block a user