move generator functions to the instructions they generate
This commit is contained in:
parent
bd77db656a
commit
60c8f8ef73
@ -28,4 +28,15 @@ module Register
|
|||||||
end
|
end
|
||||||
attr_accessor :register , :array , :index
|
attr_accessor :register , :array , :index
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Produce a GetSlot instruction.
|
||||||
|
# From and to are registers or symbols that can be transformed to a register by resolve_to_register
|
||||||
|
# index resolves with resolve_index.
|
||||||
|
def self.get_slot from , index , to
|
||||||
|
index = resolve_index( from , index)
|
||||||
|
from = resolve_to_register from
|
||||||
|
to = resolve_to_register to
|
||||||
|
GetSlot.new( from , index , to)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -13,4 +13,14 @@ module Register
|
|||||||
end
|
end
|
||||||
attr_reader :register , :index
|
attr_reader :register , :index
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Produce a SaveReturn instruction.
|
||||||
|
# From is a register or symbol that can be transformed to a register by resolve_to_register
|
||||||
|
# index resolves with resolve_index.
|
||||||
|
def self.save_return from , index
|
||||||
|
index = resolve_index( from , index)
|
||||||
|
from = resolve_to_register from
|
||||||
|
SaveReturn.new( from , index )
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -27,4 +27,15 @@ module Register
|
|||||||
end
|
end
|
||||||
attr_accessor :register , :array , :index
|
attr_accessor :register , :array , :index
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Produce a SetSlot instruction.
|
||||||
|
# From and to are registers or symbols that can be transformed to a register by resolve_to_register
|
||||||
|
# index resolves with resolve_index.
|
||||||
|
def self.set_slot from , to , index
|
||||||
|
index = resolve_index( to , index)
|
||||||
|
from = resolve_to_register from
|
||||||
|
to = resolve_to_register to
|
||||||
|
SetSlot.new( from , to , index)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -86,35 +86,6 @@ module Register
|
|||||||
RegisterReference.new :r4
|
RegisterReference.new :r4
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produce a GetSlot instruction (see there).
|
|
||||||
# From and to are registers or symbols that can be transformed to a register by resolve_to_register
|
|
||||||
# index resolves with resolve_index.
|
|
||||||
def self.get_slot from , index , to
|
|
||||||
index = resolve_index( from , index)
|
|
||||||
from = resolve_to_register from
|
|
||||||
to = resolve_to_register to
|
|
||||||
GetSlot.new( from , index , to)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Produce a SetSlot instruction (see there).
|
|
||||||
# From and to are registers or symbols that can be transformed to a register by resolve_to_register
|
|
||||||
# index resolves with resolve_index.
|
|
||||||
def self.set_slot from , to , index
|
|
||||||
index = resolve_index( to , index)
|
|
||||||
from = resolve_to_register from
|
|
||||||
to = resolve_to_register to
|
|
||||||
SetSlot.new( from , to , index)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Produce a SaveReturn instruction (see there).
|
|
||||||
# From is a register or symbol that can be transformed to a register by resolve_to_register
|
|
||||||
# index resolves with resolve_index.
|
|
||||||
def self.save_return from , index
|
|
||||||
index = resolve_index( from , index)
|
|
||||||
from = resolve_to_register from
|
|
||||||
SaveReturn.new( from , index )
|
|
||||||
end
|
|
||||||
|
|
||||||
# The first arg is a class name (possibly lowercase) and the second an instance variable name.
|
# The first arg is a class name (possibly lowercase) and the second an instance variable name.
|
||||||
# By looking up the class and the layout for that class, we can resolve the instance
|
# By looking up the class and the layout for that class, we can resolve the instance
|
||||||
# variable name to an index.
|
# variable name to an index.
|
||||||
|
Loading…
Reference in New Issue
Block a user