2017-01-14 18:28:44 +01:00
|
|
|
module Vm
|
2016-12-09 11:13:33 +01:00
|
|
|
module Tree
|
|
|
|
class IntegerExpression < Expression
|
2016-12-23 20:31:31 +01:00
|
|
|
include ValuePrinter
|
2016-12-09 11:13:33 +01:00
|
|
|
attr_accessor :value
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
2016-12-08 18:38:50 +01:00
|
|
|
end
|
2016-12-09 11:13:33 +01:00
|
|
|
class FloatExpression < Expression
|
2016-12-23 20:31:31 +01:00
|
|
|
include ValuePrinter
|
2016-12-09 11:13:33 +01:00
|
|
|
attr_accessor :value
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
2016-12-08 18:38:50 +01:00
|
|
|
end
|
2016-12-09 11:13:33 +01:00
|
|
|
class TrueExpression < Expression
|
2016-12-23 20:31:31 +01:00
|
|
|
def to_s
|
|
|
|
"true"
|
|
|
|
end
|
2016-12-08 18:38:50 +01:00
|
|
|
end
|
2016-12-09 11:13:33 +01:00
|
|
|
class FalseExpression < Expression
|
2016-12-23 20:31:31 +01:00
|
|
|
def to_s
|
2016-12-28 12:59:02 +01:00
|
|
|
"false"
|
2016-12-23 20:31:31 +01:00
|
|
|
end
|
2016-12-08 18:38:50 +01:00
|
|
|
end
|
2016-12-09 11:13:33 +01:00
|
|
|
class NilExpression < Expression
|
2016-12-23 20:31:31 +01:00
|
|
|
def to_s
|
|
|
|
"nil"
|
|
|
|
end
|
2016-12-09 11:13:33 +01:00
|
|
|
end
|
|
|
|
class StringExpression < Expression
|
2016-12-23 20:31:31 +01:00
|
|
|
include ValuePrinter
|
2016-12-09 11:13:33 +01:00
|
|
|
attr_accessor :value
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class NameExpression < Expression
|
2016-12-23 20:31:31 +01:00
|
|
|
include ValuePrinter
|
2016-12-09 11:13:33 +01:00
|
|
|
attr_accessor :value
|
|
|
|
alias :name :value
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class ClassExpression < Expression
|
2016-12-23 20:31:31 +01:00
|
|
|
include ValuePrinter
|
2016-12-09 11:13:33 +01:00
|
|
|
attr_accessor :value
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
2016-12-08 18:38:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|