create methods with binaries and extend them later
Binary is new jump target for function call
This commit is contained in:
parent
105e8f7092
commit
85ddf53429
@ -11,11 +11,14 @@ module Parfait
|
||||
|
||||
def initialize(total_size)
|
||||
super()
|
||||
extend_to(total_size)
|
||||
#puts "Init with #{total_size} for #{object_id}"
|
||||
(1..(data_length+1)).each{ |index| set_word(index , 0) }
|
||||
end
|
||||
def extend_to(total_size)
|
||||
if total_size > self.data_length
|
||||
@next = BinaryCode.new(total_size - data_length)
|
||||
end
|
||||
#puts "Init with #{total_size} for #{object_id}"
|
||||
(1..(data_length+1)).each{ |index| set_word(index , 0) }
|
||||
end
|
||||
def to_s
|
||||
"BinaryCode #{}"
|
||||
|
@ -43,6 +43,7 @@ module Parfait
|
||||
raise "Wrong frame type, expect Type not #{frame.class}" unless frame.is_a? Type
|
||||
@arguments = arguments
|
||||
@frame = frame
|
||||
@binary = BinaryCode.new(0)
|
||||
source = "_init_method"
|
||||
name = "#{@for_type.name}.#{@name}"
|
||||
@risc_instructions = Risc.label(source, name)
|
||||
@ -58,7 +59,7 @@ module Parfait
|
||||
nekst = nekst.next
|
||||
end
|
||||
total = @cpu_instructions.total_byte_length / 4 + 1
|
||||
@binary = BinaryCode.new( total )
|
||||
@binary.extend_to( total )
|
||||
@cpu_instructions
|
||||
end
|
||||
|
||||
|
@ -64,5 +64,10 @@ module Parfait
|
||||
@code.set_word(20,1)
|
||||
assert_equal 1 , @code.get_word(20)
|
||||
end
|
||||
def test_extend
|
||||
@code.extend_to(20)
|
||||
assert @code.next
|
||||
assert_nil @code.next.next
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,6 +3,7 @@ require_relative "../helper"
|
||||
class TestMethod < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
obj = Parfait.object_space.get_class_by_name(:Object).instance_type
|
||||
args = Parfait::Type.for_hash( obj.object_class , { bar: :Integer , foo: :Type})
|
||||
frame = Parfait::Type.for_hash( obj.object_class , { local_bar: :Integer , local_foo: :Type})
|
||||
@ -90,5 +91,7 @@ class TestMethod < MiniTest::Test
|
||||
index = @method.has_local(:local_bar)
|
||||
assert_equal :Integer , @method.frame_type(index)
|
||||
end
|
||||
|
||||
def test_created_with_binary
|
||||
assert @method.binary
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user