Moving space to object class
away from Parfait module, as that gets collapsed Leaving shortcut outside parfait for now
This commit is contained in:
@ -87,7 +87,7 @@ module Parfait
|
||||
# Nil name means no superclass, and so nil is a valid return value
|
||||
def super_class
|
||||
return nil unless @super_class_name
|
||||
Parfait.object_space.get_class_by_name(@super_class_name)
|
||||
Object.object_space.get_class_by_name(@super_class_name)
|
||||
end
|
||||
|
||||
# ruby 2.1 list (just for reference, keep at bottom)
|
||||
|
@ -25,10 +25,10 @@ module Parfait
|
||||
32
|
||||
end
|
||||
def self.args_start_at
|
||||
Parfait.object_space.get_type_by_class_name(:Message).variable_index(:arguments_given)
|
||||
Object.object_space.get_type_by_class_name(:Message).variable_index(:arguments_given)
|
||||
end
|
||||
def self.locals_start_at
|
||||
Parfait.object_space.get_type_by_class_name(:Message).variable_index(:locals_used)
|
||||
Object.object_space.get_type_by_class_name(:Message).variable_index(:locals_used)
|
||||
end
|
||||
|
||||
def initialize( )
|
||||
|
@ -15,13 +15,23 @@
|
||||
module Parfait
|
||||
class Object
|
||||
attr_reader :type
|
||||
|
||||
def self.type_length
|
||||
1
|
||||
end
|
||||
def self.memory_size
|
||||
4
|
||||
end
|
||||
# Make the object space globally available
|
||||
def self.object_space
|
||||
@object_space
|
||||
end
|
||||
|
||||
def self.new
|
||||
factory = @object_space.get_factory(:Object)
|
||||
object = factory.get_next
|
||||
object.initialize
|
||||
end
|
||||
|
||||
def type=(t)
|
||||
set_type( t )
|
||||
|
@ -8,15 +8,6 @@
|
||||
#
|
||||
#
|
||||
module Parfait
|
||||
# Make the object space globally available
|
||||
def self.object_space
|
||||
@object_space
|
||||
end
|
||||
|
||||
# TODO Must get rid of the setter (move the boot process ?)
|
||||
def self.set_object_space( space )
|
||||
@object_space = space
|
||||
end
|
||||
|
||||
# The Space contains all objects for a program. In functional terms it is a program, but in oo
|
||||
# it is a collection of objects, some of which are data, some classes, some functions
|
||||
|
@ -45,12 +45,12 @@ module Parfait
|
||||
def self.for_hash( hash , object_class = :Object)
|
||||
name = object_class
|
||||
if(object_class.is_a?(Symbol))
|
||||
object_class = Parfait.object_space.get_class_by_name(object_class)
|
||||
object_class = Object.object_space.get_class_by_name(object_class)
|
||||
end
|
||||
raise "No such class #{name}" unless object_class
|
||||
hash = {type: object_class.name }.merge(hash) unless hash[:type]
|
||||
new_type = Type.new( object_class , hash)
|
||||
Parfait.object_space.add_type(new_type)
|
||||
Object.object_space.add_type(new_type)
|
||||
end
|
||||
|
||||
# should not be called directly. Use Type.for_hash instead, that adds the
|
||||
|
Reference in New Issue
Block a user