fixed relation of values and types that had got watered in the virtual move
This commit is contained in:
parent
102c5c2327
commit
bb051230f4
@ -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
|
||||
|
@ -1,10 +0,0 @@
|
||||
require_relative "value"
|
||||
|
||||
module Virtual
|
||||
class Integer < Value
|
||||
|
||||
def initialize
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -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"
|
@ -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
|
@ -51,6 +51,3 @@ module Virtual
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require_relative "integer"
|
||||
require_relative "reference"
|
||||
|
@ -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
|
42
lib/virtual/type.rb
Normal file
42
lib/virtual/type.rb
Normal file
@ -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
|
@ -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
|
Loading…
Reference in New Issue
Block a user