diff --git a/lib/virtual/constants.rb b/lib/virtual/constants.rb index 8969942d..a17808cf 100644 --- a/lib/virtual/constants.rb +++ b/lib/virtual/constants.rb @@ -2,6 +2,12 @@ module Virtual class Constant < ::Virtual::Value end + class TrueValue < Constant + end + class FalseValue < Constant + end + class NilValue < Constant + end # another abstract "marker" class (so we can check for it) # derived classes are Boot/Meta Class and StringConstant diff --git a/lib/virtual/integer.rb b/lib/virtual/integer.rb deleted file mode 100644 index a4b352ca..00000000 --- a/lib/virtual/integer.rb +++ /dev/null @@ -1,10 +0,0 @@ -require_relative "value" - -module Virtual - class Integer < Value - - def initialize - end - - end -end diff --git a/lib/virtual/machine.rb b/lib/virtual/machine.rb index 1a7a808a..a9c9fdb6 100644 --- a/lib/virtual/machine.rb +++ b/lib/virtual/machine.rb @@ -55,7 +55,7 @@ require_relative "instruction" require_relative "method" require_relative "frame" require_relative "value" -require_relative "mystery" +require_relative "type" require_relative "object" require_relative "constants" require "boot/boot_space" \ No newline at end of file diff --git a/lib/virtual/mystery.rb b/lib/virtual/mystery.rb deleted file mode 100644 index 23488901..00000000 --- a/lib/virtual/mystery.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_relative "constants" - -module Virtual - class Mystery < Value - def initialize - end - - def as type - type.new - end - - end - - class TrueValue < Constant - end - class FalseValue < Constant - end - class NilValue < Constant - end -end diff --git a/lib/virtual/object.rb b/lib/virtual/object.rb index fdafbbc6..6ee7dd35 100644 --- a/lib/virtual/object.rb +++ b/lib/virtual/object.rb @@ -51,6 +51,3 @@ module Virtual end end end - -require_relative "integer" -require_relative "reference" diff --git a/lib/virtual/reference.rb b/lib/virtual/reference.rb deleted file mode 100644 index 36efc859..00000000 --- a/lib/virtual/reference.rb +++ /dev/null @@ -1,19 +0,0 @@ -require_relative "value" - -module Virtual - class Reference < Value - - def initialize clazz = nil - @clazz = clazz - end - attr_accessor :clazz - - def at_index block , left , right - block.ldr( self , left , right ) - self - end - end - - class SelfReference < Reference - end -end diff --git a/lib/virtual/type.rb b/lib/virtual/type.rb new file mode 100644 index 00000000..3cd500cb --- /dev/null +++ b/lib/virtual/type.rb @@ -0,0 +1,42 @@ +require_relative "value" + +module Virtual + # Integer and (Object) References are the main derived classes, but float will come and ... + # The Mystery Type has unknown type and has only casting methods. So it must be cast to be useful. + class Type + end + + class Integer < Type + + def initialize + end + + end + + class Reference < Type + + def initialize clazz = nil + @clazz = clazz + end + attr_accessor :clazz + + def at_index block , left , right + block.ldr( self , left , right ) + self + end + end + + class SelfReference < Reference + end + + class Mystery < Type + def initialize + end + + def as type + type.new + end + + end + +end diff --git a/lib/virtual/value.rb b/lib/virtual/value.rb index 1696d820..f50fa88b 100644 --- a/lib/virtual/value.rb +++ b/lib/virtual/value.rb @@ -1,10 +1,10 @@ module Virtual - # the virtual machine is implemented in values. Values have types which are represented as classes, but it is still - # important to make the distinction. Values are immutable, passed by value and machine word sized. - - # Integer and (Object) References are the main derived classes, but float will come and ... - # The Mystery Value has unknown type and has only casting methods. So it must be cast to be useful. + # 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 + class Value def == other other.class == self.class @@ -13,10 +13,11 @@ module Virtual self.class.name + ".new()" end def type - self.class + raise "abstract called" end private def initialize end end + end \ No newline at end of file