add set_internal
and the set_slot with register very much like the get_slot for get_internal
This commit is contained in:
parent
ede7639861
commit
c38775e933
@ -40,7 +40,11 @@ module Arm
|
||||
|
||||
def translate_SetSlot code
|
||||
# times 4 because arm works in bytes, but vm in words
|
||||
if(code.index.is_a? Numeric)
|
||||
ArmMachine.str( code.register , code.array , 4 * code.index )
|
||||
else
|
||||
ArmMachine.str( code.register , code.array , code.index )
|
||||
end
|
||||
end
|
||||
|
||||
def translate_FunctionCall code
|
||||
|
@ -130,7 +130,11 @@ module Interpreter
|
||||
def execute_SetSlot
|
||||
value = get_register( @instruction.register )
|
||||
object = get_register( @instruction.array )
|
||||
if( @instruction.index.is_a?(Numeric) )
|
||||
object.set_internal( @instruction.index , value )
|
||||
else
|
||||
object.set_internal( get_register(@instruction.index) , value )
|
||||
end
|
||||
trigger(:object_changed, @instruction.array , @instruction.index)
|
||||
true
|
||||
end
|
||||
|
@ -140,7 +140,7 @@ module Register
|
||||
# have to define some dummies, just for the other to compile
|
||||
# TODO go through the virtual parfait layer and adjust function names to what they really are
|
||||
obj = @space.get_class_by_name(:Object)
|
||||
[:main , :get_internal ].each do |f|
|
||||
[:main , :get_internal , :set_internal ].each do |f|
|
||||
obj.add_instance_method Builtin::Object.send(f , nil)
|
||||
end
|
||||
obj = @space.get_class_by_name(:Kernel)
|
||||
|
@ -15,7 +15,7 @@ module Register
|
||||
|
||||
# self[index] basically. Index is the first arg
|
||||
# return is stored in return_value
|
||||
# (this method returns a new method off course, like all builting)
|
||||
# (this method returns a new method off course, like all builtin)
|
||||
def get_internal context
|
||||
compiler = Soml::Compiler.new.create_method(:Object , :get_internal , []).init_method
|
||||
source = "get_internal"
|
||||
@ -31,6 +31,24 @@ module Register
|
||||
return compiler.method
|
||||
end
|
||||
|
||||
# self[index] = val basically. Index is the first arg , vlaue the second
|
||||
# no return
|
||||
def set_internal context
|
||||
compiler = Soml::Compiler.new.create_method(:Object , :set_internal , []).init_method
|
||||
source = "set_internal"
|
||||
#Load self by "calling" on_name
|
||||
me = compiler.process( s(:name , :self) )
|
||||
# Load the index
|
||||
index = compiler.use_reg :Integer
|
||||
compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(1), index )
|
||||
# Load the value
|
||||
value = compiler.use_reg :Integer
|
||||
compiler.add_code Register.get_slot(source , :message , Parfait::Message.get_indexed(2), value )
|
||||
# do the set
|
||||
compiler.add_code SetSlot.new( source , value , me , index)
|
||||
return compiler.method
|
||||
end
|
||||
|
||||
end
|
||||
extend ClassMethods
|
||||
end
|
||||
|
@ -22,7 +22,8 @@ module Register
|
||||
@register = register
|
||||
@array = array
|
||||
@index = index
|
||||
raise "not integer #{index}" unless index.is_a? Numeric
|
||||
raise "index 0 " if index == 0
|
||||
raise "Not integer or reg #{index}" unless index.is_a?(Numeric) or RegisterValue.look_like_reg(index)
|
||||
raise "Not register #{register}" unless RegisterValue.look_like_reg(register)
|
||||
raise "Not register #{array}" unless RegisterValue.look_like_reg(array)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user