2017-04-01 21:28:57 +03:00
|
|
|
module Vool
|
2018-03-15 11:24:14 +05:30
|
|
|
class Constant < Expression
|
2018-03-16 11:03:29 +05:30
|
|
|
#gobble it up
|
|
|
|
def each(&block)
|
|
|
|
end
|
2017-09-10 12:57:25 +03:00
|
|
|
end
|
|
|
|
|
2018-03-15 11:24:14 +05:30
|
|
|
class IntegerConstant < Constant
|
2017-04-06 16:06:51 +03:00
|
|
|
attr_reader :value
|
2017-04-01 21:28:57 +03:00
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
2018-03-15 20:33:38 +05:30
|
|
|
def slot_definition(method)
|
2018-03-17 20:57:35 +05:30
|
|
|
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(@value) , [])
|
2018-03-13 12:30:51 +05:30
|
|
|
end
|
2017-04-19 20:59:13 +03:00
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_class_by_name(:Integer).instance_type
|
|
|
|
end
|
2018-04-27 09:59:01 +03:00
|
|
|
def to_s
|
|
|
|
value.to_s
|
|
|
|
end
|
2018-03-15 20:33:38 +05:30
|
|
|
def each(&block)
|
|
|
|
end
|
2017-04-01 21:28:57 +03:00
|
|
|
end
|
2018-03-15 11:24:14 +05:30
|
|
|
class FloatConstant < Constant
|
2017-04-06 16:06:51 +03:00
|
|
|
attr_reader :value
|
2017-04-01 21:28:57 +03:00
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
2017-04-19 20:59:13 +03:00
|
|
|
def ct_type
|
|
|
|
true
|
|
|
|
end
|
2017-04-01 21:28:57 +03:00
|
|
|
end
|
2018-03-15 11:24:14 +05:30
|
|
|
class TrueConstant < Constant
|
2017-04-19 20:59:13 +03:00
|
|
|
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
|
2018-03-15 11:24:14 +05:30
|
|
|
class FalseConstant < Constant
|
2017-04-19 20:59:13 +03:00
|
|
|
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
|
2018-03-15 11:24:14 +05:30
|
|
|
class NilConstant < Constant
|
2017-04-19 20:59:13 +03:00
|
|
|
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
|
2018-03-15 11:24:14 +05:30
|
|
|
class SelfExpression < Expression
|
2018-03-16 10:32:11 +05:30
|
|
|
attr_reader :my_type
|
|
|
|
def initialize(type = nil)
|
|
|
|
@my_type = type
|
|
|
|
end
|
2018-03-16 12:33:11 +05:30
|
|
|
def slot_definition(in_method)
|
|
|
|
@my_type = in_method.for_type
|
2018-03-14 20:26:13 +05:30
|
|
|
Mom::SlotDefinition.new(:message , [:receiver])
|
2018-03-13 12:30:51 +05:30
|
|
|
end
|
2017-04-25 09:40:09 +03:00
|
|
|
def ct_type
|
2018-03-16 10:32:11 +05:30
|
|
|
@my_type
|
2017-04-25 09:40:09 +03:00
|
|
|
end
|
2018-04-27 09:59:01 +03:00
|
|
|
def to_s
|
|
|
|
"self"
|
|
|
|
end
|
2017-04-02 12:59:07 +03:00
|
|
|
end
|
2018-03-15 11:24:14 +05:30
|
|
|
class SuperExpression < Statement
|
2017-04-02 18:42:52 +03:00
|
|
|
end
|
2018-03-15 11:24:14 +05:30
|
|
|
class StringConstant < Constant
|
2017-04-06 16:06:51 +03:00
|
|
|
attr_reader :value
|
2017-04-01 21:28:57 +03:00
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
2018-03-15 20:33:38 +05:30
|
|
|
def slot_definition(method)
|
2018-03-17 20:57:35 +05:30
|
|
|
return Mom::SlotDefinition.new(Mom::StringConstant.new(@value),[])
|
2018-03-13 12:30:51 +05:30
|
|
|
end
|
2017-04-19 20:59:13 +03:00
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_class_by_name(:Word).instance_type
|
|
|
|
end
|
2017-04-01 21:28:57 +03:00
|
|
|
end
|
2018-03-15 11:24:14 +05:30
|
|
|
class SymbolConstant < StringConstant
|
2017-04-19 20:59:13 +03:00
|
|
|
def ct_type
|
|
|
|
Parfait.object_space.get_class_by_name(:Word).instance_type
|
|
|
|
end
|
2017-04-01 21:28:57 +03:00
|
|
|
end
|
|
|
|
end
|