2014-06-26 17:39:02 +02:00
|
|
|
module Virtual
|
|
|
|
# our machine is made up of objects, some of which are code, some data
|
|
|
|
#
|
|
|
|
# during compilation objects are module Virtual objects, but during execution they are not scoped
|
|
|
|
#
|
|
|
|
# functions on these classes express their functionality as function objects
|
|
|
|
class Object
|
|
|
|
def initialize
|
2014-06-30 13:56:58 +02:00
|
|
|
@layout = Layout.new( attributes )
|
2014-06-26 17:39:02 +02:00
|
|
|
end
|
|
|
|
def attributes
|
2014-06-30 13:56:58 +02:00
|
|
|
[:layout]
|
2014-06-26 17:39:02 +02:00
|
|
|
end
|
|
|
|
def == other
|
|
|
|
return false unless other.class == self.class
|
|
|
|
attributes.each do |a|
|
|
|
|
left = send(a)
|
|
|
|
right = other.send(a)
|
|
|
|
return false unless left.class == right.class
|
|
|
|
return false unless left == right
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Layout < Object
|
|
|
|
def initialize members
|
|
|
|
@members = members
|
|
|
|
end
|
|
|
|
def attributes
|
2014-06-30 13:56:58 +02:00
|
|
|
super << :members
|
2014-06-26 17:39:02 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Class < Object
|
|
|
|
def initialize name , sup = :Object
|
|
|
|
@name = name
|
|
|
|
@super_class = sup
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|