new get_type_by_class_name helper for space

sorely needed, with 36 occurences replaced
This commit is contained in:
Torsten Ruger
2018-07-13 21:50:40 +03:00
parent 27a142f2a3
commit a095515b0e
10 changed files with 32 additions and 27 deletions

View File

@ -16,7 +16,7 @@ module Risc
end
# test hack to in place change object type
def add_space_field(name,type)
class_type = Parfait.object_space.get_class_by_name(:Space).instance_type
class_type = Parfait.object_space.get_type_by_class_name(:Space)
class_type.send(:private_add_instance_variable, name , type)
end
def produce_body

View File

@ -8,7 +8,7 @@ module Parfait
@space = Parfait.object_space
end
def make_method
@obj = Parfait.object_space.get_class_by_name(:Object).instance_type
@obj = Parfait.object_space.get_type_by_class_name(:Object)
@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})
@method = Parfait::CallableMethod.new( @obj , :meth , @args , @frame)

View File

@ -14,15 +14,15 @@ module Parfait
end
def foo_method( for_class = :Try)
args = Parfait::Type.for_hash( @try_class , { bar: :Integer})
::Parfait::CallableMethod.new( @space.get_class_by_name(for_class).instance_type , :foo , args,empty_frame)
::Parfait::CallableMethod.new( @space.get_type_by_class_name(for_class) , :foo , args,empty_frame)
end
def add_foo_to( clazz = :Try )
foo = foo_method( clazz )
assert_equal foo , @space.get_class_by_name(clazz).instance_type.add_method(foo)
assert_equal foo , @space.get_type_by_class_name(clazz).add_method(foo)
foo
end
def object_type
@space.get_class_by_name(:Object).instance_type
@space.get_type_by_class_name(:Object)
end
def test_new_methods
assert_equal Parfait::List , @try_type.method_names.class
@ -59,7 +59,7 @@ module Parfait
end
def test_get_instance
foo = foo_method :Object
type = @space.get_class_by_name(:Object).instance_type
type = @space.get_type_by_class_name(:Object)
type.add_method(foo)
assert_equal :foo , type.get_method(:foo).name
end

View File

@ -36,9 +36,9 @@ module RubyX
end
def test_space_type_is_unchanged_by_compile
space1 = Parfait.object_space.get_class_by_name(:Space).instance_type
space1 = Parfait.object_space.get_type_by_class_name(:Space)
ruby_to_vool "class Space ;end"
space2 = Parfait.object_space.get_class_by_name(:Space).instance_type
space2 = Parfait.object_space.get_type_by_class_name(:Space)
assert_equal space1 , space2
end

View File

@ -25,9 +25,9 @@ module RubyX
end
def test_space_type_is_unchanged_by_compile
space1 = Parfait.object_space.get_class_by_name(:Space).instance_type
space1 = Parfait.object_space.get_type_by_class_name(:Space)
ruby_to_vool "class Space ;end"
space2 = Parfait.object_space.get_class_by_name(:Space).instance_type
space2 = Parfait.object_space.get_type_by_class_name(:Space)
assert_equal space1 , space2
end