allow for registers in get slot
This commit is contained in:
parent
1d07c1fb95
commit
484e2d19d4
@ -25,7 +25,11 @@ module Arm
|
|||||||
|
|
||||||
def translate_GetSlot code
|
def translate_GetSlot code
|
||||||
# times 4 because arm works in bytes, but vm in words
|
# times 4 because arm works in bytes, but vm in words
|
||||||
ArmMachine.ldr( code.register , code.array , 4 * code.index )
|
if(code.index.is_a? Numeric)
|
||||||
|
ArmMachine.ldr( code.register , code.array , 4 * code.index )
|
||||||
|
else
|
||||||
|
ArmMachine.ldr( code.register , code.array , code.index )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def translate_RegisterTransfer code
|
def translate_RegisterTransfer code
|
||||||
|
@ -82,10 +82,6 @@ module Interpreter
|
|||||||
set_instruction @instruction.next
|
set_instruction @instruction.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def object_for reg
|
|
||||||
get_register(reg)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Label is a noop.
|
# Label is a noop.
|
||||||
def execute_Label
|
def execute_Label
|
||||||
true
|
true
|
||||||
@ -119,7 +115,8 @@ module Interpreter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def execute_GetSlot
|
def execute_GetSlot
|
||||||
object = object_for( @instruction.array )
|
puts @instruction
|
||||||
|
object = get_register( @instruction.array )
|
||||||
if( @instruction.index.is_a?(Numeric) )
|
if( @instruction.index.is_a?(Numeric) )
|
||||||
index = @instruction.index
|
index = @instruction.index
|
||||||
else
|
else
|
||||||
@ -132,8 +129,8 @@ module Interpreter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def execute_SetSlot
|
def execute_SetSlot
|
||||||
value = object_for( @instruction.register )
|
value = get_register( @instruction.register )
|
||||||
object = object_for( @instruction.array )
|
object = get_register( @instruction.array )
|
||||||
object.set_internal( @instruction.index , value )
|
object.set_internal( @instruction.index , value )
|
||||||
trigger(:object_changed, @instruction.array , @instruction.index)
|
trigger(:object_changed, @instruction.array , @instruction.index)
|
||||||
true
|
true
|
||||||
@ -151,7 +148,7 @@ module Interpreter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def execute_FunctionReturn
|
def execute_FunctionReturn
|
||||||
object = object_for( @instruction.register )
|
object = get_register( @instruction.register )
|
||||||
link = object.get_internal( @instruction.index )
|
link = object.get_internal( @instruction.index )
|
||||||
@instruction = link
|
@instruction = link
|
||||||
# we jump back to the call instruction. so it is as if the call never happened and we continue
|
# we jump back to the call instruction. so it is as if the call never happened and we continue
|
||||||
@ -163,7 +160,7 @@ module Interpreter
|
|||||||
ret_value = 0
|
ret_value = 0
|
||||||
case name
|
case name
|
||||||
when :putstring
|
when :putstring
|
||||||
str = object_for( :r1 ) # should test length, ie r2
|
str = get_register( :r1 ) # should test length, ie r2
|
||||||
raise "NO string for putstring #{str.class}:#{str.object_id}" unless str.is_a? Symbol
|
raise "NO string for putstring #{str.class}:#{str.object_id}" unless str.is_a? Symbol
|
||||||
@stdout += str.to_s
|
@stdout += str.to_s
|
||||||
ret_value = str.to_s.length
|
ret_value = str.to_s.length
|
||||||
|
Loading…
x
Reference in New Issue
Block a user