rubyx/lib/vool/statements/basic_values.rb

80 lines
1.7 KiB
Ruby
Raw Normal View History

2017-04-01 20:28:57 +02:00
module Vool
class Constant < Expression
#gobble it up
def each(&block)
end
end
class IntegerConstant < Constant
attr_reader :value
2017-04-01 20:28:57 +02:00
def initialize(value)
@value = value
end
def slot_definition(method)
2018-03-13 08:00:51 +01:00
return Mom::IntegerConstant.new(@value)
end
def ct_type
Parfait.object_space.get_class_by_name(:Integer).instance_type
end
#gobble it up
def each(&block)
end
2017-04-01 20:28:57 +02:00
end
class FloatConstant < Constant
attr_reader :value
2017-04-01 20:28:57 +02:00
def initialize(value)
@value = value
end
def ct_type
true
end
2017-04-01 20:28:57 +02:00
end
class TrueConstant < Constant
def ct_type
Parfait.object_space.get_class_by_name(:True).instance_type
end
2017-04-01 20:28:57 +02:00
end
class FalseConstant < Constant
def ct_type
Parfait.object_space.get_class_by_name(:False).instance_type
end
2017-04-01 20:28:57 +02:00
end
class NilConstant < Constant
def ct_type
Parfait.object_space.get_class_by_name(:Nil).instance_type
end
2017-04-01 20:28:57 +02:00
end
class SelfExpression < Expression
2018-03-16 06:02:11 +01:00
attr_reader :my_type
def initialize(type = nil)
@my_type = type
end
def slot_definition(in_method)
@my_type = in_method.for_type
Mom::SlotDefinition.new(:message , [:receiver])
2018-03-13 08:00:51 +01:00
end
def ct_type
2018-03-16 06:02:11 +01:00
@my_type
end
2017-04-02 11:59:07 +02:00
end
class SuperExpression < Statement
end
class StringConstant < Constant
attr_reader :value
2017-04-01 20:28:57 +02:00
def initialize(value)
@value = value
end
def slot_definition(method)
2018-03-13 08:00:51 +01:00
return Mom::StringConstant.new(@value)
end
def ct_type
Parfait.object_space.get_class_by_name(:Word).instance_type
end
2017-04-01 20:28:57 +02:00
end
class SymbolConstant < StringConstant
def ct_type
Parfait.object_space.get_class_by_name(:Word).instance_type
end
2017-04-01 20:28:57 +02:00
end
end