get those integers crated and used
This commit is contained in:
parent
5b92b6b785
commit
4725b81270
@ -12,9 +12,9 @@ module Parfait
|
|||||||
def initialize(value , next_i = nil)
|
def initialize(value , next_i = nil)
|
||||||
super()
|
super()
|
||||||
@value = value
|
@value = value
|
||||||
@next_i = next_i
|
@next_integer = next_i
|
||||||
end
|
end
|
||||||
attr_reader :next_i, :value
|
attr_reader :next_integer, :value
|
||||||
|
|
||||||
def self.integer_index
|
def self.integer_index
|
||||||
3 # 1 type, 2 next_i
|
3 # 1 type, 2 next_i
|
||||||
|
@ -35,6 +35,7 @@ module Parfait
|
|||||||
@classes = classes
|
@classes = classes
|
||||||
@types = Dictionary.new
|
@types = Dictionary.new
|
||||||
message = Message.new(nil)
|
message = Message.new(nil)
|
||||||
|
100.times { @next_integer = Integer.new(0,@next_integer) }
|
||||||
50.times do
|
50.times do
|
||||||
@first_message = Message.new message
|
@first_message = Message.new message
|
||||||
#puts "INIT caller #{message.object_id} to #{@first_message.object_id}"
|
#puts "INIT caller #{message.object_id} to #{@first_message.object_id}"
|
||||||
@ -49,7 +50,7 @@ module Parfait
|
|||||||
@nil_object = Parfait::NilClass.new
|
@nil_object = Parfait::NilClass.new
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :classes , :first_message , :first_integer
|
attr_reader :classes , :first_message , :next_integer
|
||||||
attr_reader :true_object , :false_object , :nil_object
|
attr_reader :true_object , :false_object , :nil_object
|
||||||
|
|
||||||
def each_type
|
def each_type
|
||||||
|
@ -129,7 +129,7 @@ module Risc
|
|||||||
Message: { next_message: :Message, receiver: :Object, frame: :NamedList ,
|
Message: { next_message: :Message, receiver: :Object, frame: :NamedList ,
|
||||||
return_address: :Integer, return_value: :Integer,
|
return_address: :Integer, return_value: :Integer,
|
||||||
caller: :Message , name: :Word , arguments: :NamedList },
|
caller: :Message , name: :Word , arguments: :NamedList },
|
||||||
Integer: {next_i: :Integer},
|
Integer: {next_integer: :Integer},
|
||||||
DataObject: {},
|
DataObject: {},
|
||||||
Data4: {},
|
Data4: {},
|
||||||
Data8: {},
|
Data8: {},
|
||||||
@ -140,7 +140,7 @@ module Risc
|
|||||||
Kernel: {}, #fix, kernel is a class, but should be a module
|
Kernel: {}, #fix, kernel is a class, but should be a module
|
||||||
BinaryCode: {next: :BinaryCode} ,
|
BinaryCode: {next: :BinaryCode} ,
|
||||||
Space: {classes: :Dictionary , types: :Dictionary ,
|
Space: {classes: :Dictionary , types: :Dictionary ,
|
||||||
first_message: :Message , first_integer: :Integer ,
|
first_message: :Message , next_integer: :Integer ,
|
||||||
true_object: :TrueClass,
|
true_object: :TrueClass,
|
||||||
false_object: :FalseClass , nil_object: :NilClass},
|
false_object: :FalseClass , nil_object: :NilClass},
|
||||||
NamedList: {},
|
NamedList: {},
|
||||||
|
@ -23,9 +23,9 @@ module Risc
|
|||||||
compiler.add_slot_to_reg( source + "2" , me , Parfait::Integer.integer_index , me)
|
compiler.add_slot_to_reg( source + "2" , me , Parfait::Integer.integer_index , me)
|
||||||
compiler.add_slot_to_reg( source + "3", other , Parfait::Integer.integer_index , other)
|
compiler.add_slot_to_reg( source + "3", other , Parfait::Integer.integer_index , other)
|
||||||
compiler.add_code Risc.op( source + "4", :+ , me , other)
|
compiler.add_code Risc.op( source + "4", :+ , me , other)
|
||||||
#TODO must get an Integer and put the value there then return the integer (object not value)
|
compiler.add_new_int(other)
|
||||||
# and put it back into the return value
|
compiler.add_reg_to_slot( source + "5" , me , other , Parfait::Integer.integer_index)
|
||||||
compiler.add_reg_to_slot( source + "5" , me , :message , :return_value)
|
compiler.add_reg_to_slot( source + "5" , other , :message , :return_value)
|
||||||
return compiler.method
|
return compiler.method
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -132,6 +132,18 @@ module Risc
|
|||||||
@regs.clear
|
@regs.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# grab an integer from space and stick it in the register.
|
||||||
|
def add_new_int( register )
|
||||||
|
source = "add_new_int "
|
||||||
|
space = use_reg(:Space)
|
||||||
|
int = use_reg(:Integer)
|
||||||
|
space_i = Risc.resolve_to_index(:Space, :next_integer)
|
||||||
|
add_load_constant( source + "space" , Parfait.object_space , space )
|
||||||
|
add_slot_to_reg( source + "next_i1" , space , space_i , register)
|
||||||
|
add_slot_to_reg( source + "next_i2" , register , Risc.resolve_to_index(:Integer, :next_integer) , int)
|
||||||
|
add_reg_to_slot( source + "store link" , int , space , space_i )
|
||||||
|
# store 2nd next_i to spce next_i
|
||||||
|
end
|
||||||
def add_constant(const)
|
def add_constant(const)
|
||||||
Risc.machine.add_constant(const)
|
Risc.machine.add_constant(const)
|
||||||
end
|
end
|
||||||
|
@ -22,6 +22,17 @@ class TestSpace < MiniTest::Test
|
|||||||
assert @space.false_object , "No lies"
|
assert @space.false_object , "No lies"
|
||||||
assert @space.nil_object , "No nothing"
|
assert @space.nil_object , "No nothing"
|
||||||
end
|
end
|
||||||
|
def test_integer_first
|
||||||
|
assert @space.next_integer
|
||||||
|
end
|
||||||
|
def test_integer_20
|
||||||
|
int = @space.next_integer
|
||||||
|
20.times do
|
||||||
|
assert int
|
||||||
|
assert_equal Parfait::Integer , int.class
|
||||||
|
int = int.next_integer
|
||||||
|
end
|
||||||
|
end
|
||||||
def test_methods_booted
|
def test_methods_booted
|
||||||
word = @space.get_class_by_name(:Word).instance_type
|
word = @space.get_class_by_name(:Word).instance_type
|
||||||
assert_equal 4 , word.method_names.get_length
|
assert_equal 4 , word.method_names.get_length
|
||||||
|
@ -9,7 +9,7 @@ module Risc
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def est_add
|
def test_add
|
||||||
#show_ticks # get output of what is
|
#show_ticks # get output of what is
|
||||||
check_chain [Branch, Label, LoadConstant, SlotToReg, LoadConstant,
|
check_chain [Branch, Label, LoadConstant, SlotToReg, LoadConstant,
|
||||||
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||||
@ -23,10 +23,11 @@ module Risc
|
|||||||
LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
||||||
SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
|
SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
|
||||||
Label, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
Label, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
||||||
SlotToReg, OperatorInstruction, RegToSlot, Label, NilClass]
|
SlotToReg, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg,
|
||||||
assert_equal 10 , get_return
|
RegToSlot, RegToSlot, RegToSlot, Label, NilClass]
|
||||||
|
assert_equal Parfait::Integer , get_return.class
|
||||||
|
# assert_equal 10 , get_return.value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_5
|
def test_load_5
|
||||||
lod = ticks( 46 )
|
lod = ticks( 46 )
|
||||||
assert_equal LoadConstant , lod.class
|
assert_equal LoadConstant , lod.class
|
||||||
|
Loading…
Reference in New Issue
Block a user