2014-06-26 17:39:02 +02:00
|
|
|
module Virtual
|
|
|
|
|
2014-07-15 08:31:25 +02:00
|
|
|
# the virtual machine is implemented in values (a c++ version of oo).
|
|
|
|
# Values have types which are represented as classes, instances of Type to be precise
|
|
|
|
|
|
|
|
# Values must really be Constants or Variables, ie have a storage space
|
|
|
|
|
2014-06-26 17:39:02 +02:00
|
|
|
class Value
|
|
|
|
def type
|
2014-07-15 09:35:29 +02:00
|
|
|
raise "abstract called for #{self.class}"
|
|
|
|
end
|
|
|
|
def == other
|
|
|
|
return false unless other.class == self.class
|
2014-08-19 21:54:28 +02:00
|
|
|
Sof::Util.attributes(self).each do |a|
|
|
|
|
begin
|
|
|
|
left = send(a)
|
|
|
|
rescue NoMethodError
|
|
|
|
next # not using instance variables that are not defined as attr_readers for equality
|
|
|
|
end
|
|
|
|
begin
|
|
|
|
right = other.send(a)
|
|
|
|
rescue NoMethodError
|
|
|
|
return false
|
|
|
|
end
|
2014-07-15 09:35:29 +02:00
|
|
|
return false unless left.class == right.class
|
|
|
|
return false unless left == right
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
2014-08-20 16:14:52 +02:00
|
|
|
private #can't instantiate, must be constant or variable
|
2014-06-26 17:39:02 +02:00
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
end
|
2014-08-19 21:54:28 +02:00
|
|
|
end
|
2014-08-20 16:14:52 +02:00
|
|
|
|
|
|
|
require_relative "slot"
|