update reader and implement singletons
This commit is contained in:
@ -9,6 +9,22 @@ module Ast
|
||||
end
|
||||
end
|
||||
|
||||
class TrueExpression
|
||||
def compile frame
|
||||
Virtual::TrueValue.new
|
||||
end
|
||||
end
|
||||
class FalseExpression
|
||||
def compile frame
|
||||
Virtual::FalseValue.new
|
||||
end
|
||||
end
|
||||
class NilExpression
|
||||
def compile frame
|
||||
Virtual::NilValue.new
|
||||
end
|
||||
end
|
||||
|
||||
class NameExpression < Expression
|
||||
# attr_reader :name
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
module Virtual
|
||||
|
||||
class Constant < ::Virtual::Object
|
||||
|
||||
end
|
||||
|
||||
# another abstract "marker" class (so we can check for it)
|
||||
|
@ -1,6 +1,6 @@
|
||||
module Virtual
|
||||
class Mystery < Value
|
||||
def initilize
|
||||
def initialize
|
||||
end
|
||||
|
||||
def as type
|
||||
@ -8,4 +8,11 @@ module Virtual
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class TrueValue < Value
|
||||
end
|
||||
class FalseValue < Value
|
||||
end
|
||||
class NilValue < Value
|
||||
end
|
||||
end
|
||||
|
@ -6,6 +6,12 @@ module Virtual
|
||||
# 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.
|
||||
class Value
|
||||
def == other
|
||||
other.class == self.class
|
||||
end
|
||||
def inspect
|
||||
self.class.name + ".new()"
|
||||
end
|
||||
def type
|
||||
self.class
|
||||
end
|
||||
|
Reference in New Issue
Block a user