move from new_object to normal new
This commit is contained in:
parent
08e1852e5f
commit
2c1c38716b
@ -19,7 +19,7 @@ module Parfait
|
||||
super( name , super_class)
|
||||
# the layout for this class (class = object of type Class) carries the class
|
||||
# as an instance. The relation is from an object through the Layout to it's class
|
||||
@object_layout = Layout.new_object(self)
|
||||
@object_layout = Layout.new(self)
|
||||
end
|
||||
|
||||
def object_layout
|
||||
|
@ -7,8 +7,8 @@ module Parfait
|
||||
# internally we store keys and values in lists, which means this does **not** scale well
|
||||
def initialize
|
||||
super()
|
||||
@keys = List.new_object()
|
||||
@values = List.new_object()
|
||||
@keys = List.new()
|
||||
@values = List.new()
|
||||
end
|
||||
|
||||
# return all values as a list
|
||||
|
@ -24,7 +24,7 @@ module Parfait
|
||||
raise "No class #{name}" unless clazz
|
||||
@for_class = clazz
|
||||
@name = name
|
||||
@code = BinaryCode.new_object name
|
||||
@code = BinaryCode.new name
|
||||
@arg_names = arg_names
|
||||
@locals = List.new
|
||||
@tmps = List.new
|
||||
|
@ -16,7 +16,7 @@ module Parfait
|
||||
def initialize name , superclass
|
||||
super()
|
||||
@name = name
|
||||
@instance_methods = List.new_object
|
||||
@instance_methods = List.new
|
||||
@super_class = superclass
|
||||
@meta_class = nil#MetaClass.new(self)
|
||||
end
|
||||
@ -58,7 +58,7 @@ module Parfait
|
||||
raise "uups #{name}.#{name.class}" unless name.is_a?(Symbol)
|
||||
clazz = Space.object_space.get_class_by_name(self.name)
|
||||
raise "??? #{self.name}" unless clazz
|
||||
Method.new_object( clazz , name , arg_names )
|
||||
Method.new( clazz , name , arg_names )
|
||||
end
|
||||
|
||||
# this needs to be done during booting as we can't have all the classes and superclassses
|
||||
|
@ -17,8 +17,9 @@ module Parfait
|
||||
LAYOUT_INDEX = 1
|
||||
CLASS_INDEX = 2 #only used in class, but keep constants together
|
||||
|
||||
def self.new_object *args
|
||||
object = self.new(*args)
|
||||
def self.new *args
|
||||
object = self.allocate
|
||||
object.send :initialize , *args
|
||||
#puts "NEW #{object.class}"
|
||||
object
|
||||
end
|
||||
@ -59,7 +60,7 @@ module Parfait
|
||||
|
||||
def get_layout()
|
||||
l = internal_object_get(LAYOUT_INDEX)
|
||||
raise "No layout #{self.object_id.to_s(16)}=#{self.to_s[0 ... 100]}:#{self.class} " unless l
|
||||
raise "No layout #{self.object_id.to_s(16)}:#{self.class} " unless l
|
||||
return l
|
||||
end
|
||||
|
||||
@ -70,13 +71,13 @@ module Parfait
|
||||
def get_instance_variable name
|
||||
index = instance_variable_defined(name)
|
||||
return nil if index == nil
|
||||
return internal_get(index)
|
||||
return internal_object_get(index)
|
||||
end
|
||||
|
||||
def set_instance_variable name , value
|
||||
index = instance_variable_defined(name)
|
||||
return nil if index == nil
|
||||
return internal_set(index , value)
|
||||
return internal_object_set(index , value)
|
||||
end
|
||||
|
||||
def instance_variable_defined name
|
||||
|
@ -24,7 +24,7 @@ module Parfait
|
||||
def initialize
|
||||
super()
|
||||
Parfait::Space.set_object_space self
|
||||
@classes = Parfait::Dictionary.new_object
|
||||
@classes = Parfait::Dictionary.new
|
||||
end
|
||||
attr_reader :classes , :first_message
|
||||
|
||||
@ -81,7 +81,7 @@ module Parfait
|
||||
# so we get and keep exactly one per name
|
||||
def create_class name , superclass
|
||||
raise "uups #{name.class}" unless name.is_a? Symbol
|
||||
c = Class.new_object(name , superclass)
|
||||
c = Class.new(name , superclass)
|
||||
@classes[name] = c
|
||||
end
|
||||
|
||||
|
@ -17,7 +17,7 @@ module Virtual
|
||||
# The way out is to build empty shell objects and stuff the neccessary data into them
|
||||
# (not use the normal initialize way)
|
||||
def boot_parfait!
|
||||
@space = Parfait::Space.new_object
|
||||
@space = Parfait::Space.new
|
||||
# map from the vm - class_name to the Parfait class (which carries parfait name)
|
||||
class_mappings = {} #will later become instance variable
|
||||
|
||||
|
@ -25,7 +25,7 @@ module FakeMem
|
||||
end
|
||||
module Virtual
|
||||
def self.new_list array
|
||||
list = Parfait::List.new_object
|
||||
list = Parfait::List.new
|
||||
list.set_length array.length
|
||||
index = 1
|
||||
while index <= array.length do
|
||||
|
@ -23,7 +23,7 @@ module Virtual
|
||||
# Functions to generate parfait objects
|
||||
def self.new_word( string )
|
||||
string = string.to_s if string.is_a? Symbol
|
||||
word = Parfait::Word.new_object( string.length )
|
||||
word = Parfait::Word.new( string.length )
|
||||
string.codepoints.each_with_index do |code , index |
|
||||
word.set_char(index + 1 , code)
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ require_relative "../helper"
|
||||
class TestList < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@list = ::Parfait::List.new_object
|
||||
@list = ::Parfait::List.new
|
||||
end
|
||||
def test_list_create
|
||||
assert @list.empty?
|
||||
|
@ -3,7 +3,7 @@ require_relative "../helper"
|
||||
class TestObject < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@object = ::Parfait::Object.new_object
|
||||
@object = ::Parfait::Object.new
|
||||
end
|
||||
|
||||
def test_object_create
|
||||
|
@ -34,4 +34,15 @@ class TestSpace < MiniTest::Test
|
||||
# there is a 5.times in space, but one Message gets created before
|
||||
assert_equal 5 + 1 , all.length
|
||||
end
|
||||
def test_message_layout
|
||||
mess = @machine.space.first_message
|
||||
one_way = mess.get_layout
|
||||
assert one_way
|
||||
assert mess.instance_variable_defined :next_message
|
||||
other_way = mess.get_instance_variable :layout
|
||||
#puts mess.get_instance_variables
|
||||
# assert other_way
|
||||
# assert_equal one_way , other_way , "not same "
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ require_relative "../helper"
|
||||
class TestEmptyWord < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@word = ::Parfait::Word.new_object(0)
|
||||
@word = ::Parfait::Word.new(0)
|
||||
end
|
||||
def test_word_create
|
||||
assert @word.empty?
|
||||
@ -25,7 +25,7 @@ end
|
||||
class TestWord < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@word = ::Parfait::Word.new_object(5)
|
||||
@word = ::Parfait::Word.new(5)
|
||||
end
|
||||
def test_len
|
||||
assert_equal 5 , @word.length
|
||||
@ -42,7 +42,7 @@ class TestWord < MiniTest::Test
|
||||
assert_equal @word.copy , @word
|
||||
end
|
||||
def test_equals_same
|
||||
assert_equal ::Parfait::Word.new_object(5) , @word
|
||||
assert_equal ::Parfait::Word.new(5) , @word
|
||||
end
|
||||
def test_index_check_get
|
||||
assert_raises RuntimeError do
|
||||
|
Loading…
Reference in New Issue
Block a user