fixed the SetImplementation with new register instructions
This commit is contained in:
16
lib/register/instructions/get_slot.rb
Normal file
16
lib/register/instructions/get_slot.rb
Normal file
@ -0,0 +1,16 @@
|
||||
module Register
|
||||
# offset memory get access
|
||||
# so the value to be set must be given as the first register
|
||||
# the second argument holds the base address
|
||||
# and the third a possible (small) offset into the "object"
|
||||
#
|
||||
# if for example the value is pointed to by a register, a VariableGet (load) is needed first
|
||||
class GetSlot < Instruction
|
||||
def initialize value , reference , index = 0
|
||||
@value = value
|
||||
@reference = reference
|
||||
@index = index
|
||||
end
|
||||
attr_accessor :value , :reference , :index
|
||||
end
|
||||
end
|
14
lib/register/instructions/load_constant.rb
Normal file
14
lib/register/instructions/load_constant.rb
Normal file
@ -0,0 +1,14 @@
|
||||
module Register
|
||||
# load a constant into a register
|
||||
#
|
||||
# first arguemnt is the register the constant is loaded into
|
||||
# second is the actual constant
|
||||
|
||||
class LoadConstant < Instruction
|
||||
def initialize value , constant
|
||||
@value = value
|
||||
@constant = constant
|
||||
end
|
||||
attr_accessor :value , :constant
|
||||
end
|
||||
end
|
16
lib/register/instructions/set_slot.rb
Normal file
16
lib/register/instructions/set_slot.rb
Normal file
@ -0,0 +1,16 @@
|
||||
module Register
|
||||
# offset memory set access
|
||||
# so the value must be given as the first register
|
||||
# the second argument holds the base address
|
||||
# and the third a possible (small) offset into the "object"
|
||||
#
|
||||
# if for example the value is pointed to by a register, a VariableGet (load) is needed first
|
||||
class SetSlot < Instruction
|
||||
def initialize value , reference , index = 0
|
||||
@value = value
|
||||
@reference = reference
|
||||
@index = index
|
||||
end
|
||||
attr_accessor :value , :reference , :index
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user