rubyx/lib/vool/statements/basic_values.rb

94 lines
2.2 KiB
Ruby
Raw Normal View History

2017-04-01 21:28:57 +03:00
module Vool
class Constant < Expression
#gobble it up
def each(&block)
end
end
class IntegerConstant < Constant
attr_reader :value
2017-04-01 21:28:57 +03:00
def initialize(value)
@value = value
end
def slot_definition(method)
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(@value) , [])
2018-03-13 12:30:51 +05:30
end
def ct_type
Parfait.object_space.get_class_by_name(:Integer).instance_type
end
def to_s
value.to_s
end
def each(&block)
end
2017-04-01 21:28:57 +03:00
end
class FloatConstant < Constant
attr_reader :value
2017-04-01 21:28:57 +03:00
def initialize(value)
@value = value
end
def ct_type
true
end
2017-04-01 21:28:57 +03:00
end
class TrueConstant < Constant
def ct_type
Parfait.object_space.get_class_by_name(:True).instance_type
end
2018-04-19 19:23:12 +03:00
def slot_definition(method)
return Mom::SlotDefinition.new(Parfait.object_space.true_object , [])
end
2017-04-01 21:28:57 +03:00
end
class FalseConstant < Constant
def ct_type
Parfait.object_space.get_class_by_name(:False).instance_type
end
2018-04-19 19:23:12 +03:00
def slot_definition(method)
return Mom::SlotDefinition.new(Parfait.object_space.false_object , [])
end
2017-04-01 21:28:57 +03:00
end
class NilConstant < Constant
def ct_type
Parfait.object_space.get_class_by_name(:Nil).instance_type
end
2018-04-19 19:23:12 +03:00
def slot_definition(method)
return Mom::SlotDefinition.new(Parfait.object_space.nil_object , [])
end
2017-04-01 21:28:57 +03:00
end
class SelfExpression < Expression
2018-03-16 10:32:11 +05:30
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 12:30:51 +05:30
end
def ct_type
2018-03-16 10:32:11 +05:30
@my_type
end
def to_s
"self"
end
2017-04-02 12:59:07 +03:00
end
class SuperExpression < Statement
end
class StringConstant < Constant
attr_reader :value
2017-04-01 21:28:57 +03:00
def initialize(value)
@value = value
end
def slot_definition(method)
return Mom::SlotDefinition.new(Mom::StringConstant.new(@value),[])
2018-03-13 12:30:51 +05:30
end
def ct_type
Parfait.object_space.get_class_by_name(:Word).instance_type
end
2017-04-01 21:28:57 +03:00
end
class SymbolConstant < StringConstant
def ct_type
Parfait.object_space.get_class_by_name(:Word).instance_type
end
2017-04-01 21:28:57 +03:00
end
end