minor
This commit is contained in:
parent
13eb017394
commit
da5502e301
@ -140,6 +140,7 @@ module Interpreter
|
|||||||
|
|
||||||
def execute_FunctionCall
|
def execute_FunctionCall
|
||||||
@link = [@block , @instruction]
|
@link = [@block , @instruction]
|
||||||
|
#puts "Call link #{@link}"
|
||||||
next_block = @instruction.method.source.blocks.first
|
next_block = @instruction.method.source.blocks.first
|
||||||
set_block next_block
|
set_block next_block
|
||||||
false
|
false
|
||||||
@ -148,34 +149,38 @@ module Interpreter
|
|||||||
def execute_SaveReturn
|
def execute_SaveReturn
|
||||||
object = object_for @instruction.register
|
object = object_for @instruction.register
|
||||||
raise "save return has nothing to save" unless @link
|
raise "save return has nothing to save" unless @link
|
||||||
trigger(:object_changed, @instruction.register , @instruction.index )
|
#puts "Save Return link #{@link}"
|
||||||
object.internal_object_set @instruction.index , @link
|
object.internal_object_set @instruction.index , @link
|
||||||
|
trigger(:object_changed, @instruction.register , @instruction.index )
|
||||||
@link = nil
|
@link = nil
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def execute_FunctionReturn
|
||||||
|
object = object_for( @instruction.register )
|
||||||
|
link = object.internal_object_get( @instruction.index )
|
||||||
|
#puts "FunctionReturn link #{@link}"
|
||||||
|
@block , @instruction = link
|
||||||
|
# we jump back to the call instruction. so it is as if the call never happened and we continue
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def execute_Syscall
|
def execute_Syscall
|
||||||
name = @instruction.name
|
name = @instruction.name
|
||||||
|
ret_value = 0
|
||||||
case name
|
case name
|
||||||
when :putstring
|
when :putstring
|
||||||
str = object_for( :r1 ) # should test length, ie r2
|
str = object_for( :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
|
||||||
when :exit
|
when :exit
|
||||||
set_instruction(nil)
|
set_instruction(nil)
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
raise "un-implemented syscall #{name}"
|
raise "un-implemented syscall #{name}"
|
||||||
end
|
end
|
||||||
true
|
set_register( :r0 , ret_value ) # syscalls return into r0 , usually some int
|
||||||
end
|
|
||||||
|
|
||||||
def execute_FunctionReturn
|
|
||||||
object = object_for( @instruction.register )
|
|
||||||
#wouldn't need to assign to link, but makes testing easier
|
|
||||||
link = object.internal_object_get( @instruction.index )
|
|
||||||
@block , @instruction = link
|
|
||||||
# we jump back to the call instruction. so it is as if the call never happened and we continue
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class TestPositioning < MiniTest::Test
|
|||||||
list = Virtual.new_list([1,2,3,4,5])
|
list = Virtual.new_list([1,2,3,4,5])
|
||||||
list.set_layout( Parfait::Layout.new Object)
|
list.set_layout( Parfait::Layout.new Object)
|
||||||
# TODO check why this is 64 and not 32
|
# TODO check why this is 64 and not 32
|
||||||
assert_equal 64 , list.word_length
|
assert_equal 32 , list.word_length
|
||||||
end
|
end
|
||||||
def test_layout
|
def test_layout
|
||||||
layout = Parfait::Layout.new Object
|
layout = Parfait::Layout.new Object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user