2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
2018-07-20 09:05:11 +02:00
|
|
|
class Constant < Statement
|
|
|
|
def to_vool
|
|
|
|
vool_brother.new
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
class ValueConstant < Constant
|
2018-07-19 13:46:51 +02:00
|
|
|
attr_reader :value
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
def to_vool
|
|
|
|
vool_brother.new(@value)
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
class IntegerConstant < ValueConstant
|
2018-07-19 13:46:51 +02:00
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_type_by_class_name(:Integer)
|
|
|
|
end
|
|
|
|
def to_s
|
|
|
|
value.to_s
|
|
|
|
end
|
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
class FloatConstant < ValueConstant
|
2018-07-19 13:46:51 +02:00
|
|
|
attr_reader :value
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
|
|
|
def ct_type
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TrueConstant < Constant
|
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_type_by_class_name(:True)
|
|
|
|
end
|
|
|
|
def to_s(depth = 0)
|
|
|
|
"true"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class FalseConstant < Constant
|
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_type_by_class_name(:False)
|
|
|
|
end
|
|
|
|
def to_s(depth = 0)
|
|
|
|
"false"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class NilConstant < Constant
|
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_type_by_class_name(:Nil)
|
|
|
|
end
|
|
|
|
def to_s(depth = 0)
|
|
|
|
"nil"
|
|
|
|
end
|
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
class SelfExpression < Constant
|
2018-07-19 13:46:51 +02:00
|
|
|
def to_s(depth = 0)
|
|
|
|
"self"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class SuperExpression < Statement
|
|
|
|
def to_s(depth = 0)
|
|
|
|
"super"
|
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
def to_vool
|
|
|
|
vool_brother.new
|
|
|
|
end
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
class StringConstant < ValueConstant
|
2018-07-19 13:46:51 +02:00
|
|
|
attr_reader :value
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_type_by_class_name(:Word)
|
|
|
|
end
|
|
|
|
def to_s(depth = 0)
|
|
|
|
"'#{@value}'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class SymbolConstant < StringConstant
|
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_type_by_class_name(:Word)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|