2018-06-29 21:46:39 +02:00
|
|
|
module Vool
|
|
|
|
module Named
|
|
|
|
attr_reader :name
|
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
end
|
|
|
|
def each(&block)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class LocalVariable < Expression
|
|
|
|
include Named
|
2019-08-19 10:33:12 +02:00
|
|
|
def to_slot(compiler)
|
2018-07-09 18:32:17 +02:00
|
|
|
slot_def = compiler.slot_type_for(@name)
|
|
|
|
Mom::SlotDefinition.new(:message , slot_def)
|
2018-06-29 21:46:39 +02:00
|
|
|
end
|
2019-08-19 10:33:12 +02:00
|
|
|
def to_s(depth = 0)
|
2018-07-03 21:18:19 +02:00
|
|
|
name.to_s
|
|
|
|
end
|
2019-08-17 14:58:27 +02:00
|
|
|
def each(&block)
|
|
|
|
block.call(self)
|
|
|
|
end
|
2018-06-29 21:46:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class InstanceVariable < Expression
|
|
|
|
include Named
|
2019-08-19 10:33:12 +02:00
|
|
|
def to_slot(_)
|
2018-06-29 21:46:39 +02:00
|
|
|
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
|
|
|
|
end
|
|
|
|
# used to collect type information
|
|
|
|
def add_ivar( array )
|
|
|
|
array << @name
|
|
|
|
end
|
2019-08-16 17:42:57 +02:00
|
|
|
def to_s(depth = 0)
|
|
|
|
at_depth(depth , "@#{name}")
|
2018-07-03 21:18:19 +02:00
|
|
|
end
|
2019-08-17 14:58:27 +02:00
|
|
|
def each(&block)
|
|
|
|
block.call(self)
|
|
|
|
end
|
2018-06-29 21:46:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class ClassVariable < Expression
|
|
|
|
include Named
|
2019-08-17 14:58:27 +02:00
|
|
|
def each(&block)
|
|
|
|
block.call(self)
|
|
|
|
end
|
2018-06-29 21:46:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class ModuleName < Expression
|
|
|
|
include Named
|
2019-02-16 16:54:45 +01:00
|
|
|
def ct_type
|
2019-09-24 16:25:19 +02:00
|
|
|
get_named_class.single_class.instance_type
|
2019-02-16 16:54:45 +01:00
|
|
|
end
|
2019-08-19 10:33:12 +02:00
|
|
|
def to_slot(_)
|
2019-02-16 16:54:45 +01:00
|
|
|
return Mom::SlotDefinition.new( get_named_class, [])
|
|
|
|
end
|
|
|
|
def get_named_class
|
|
|
|
Parfait.object_space.get_class_by_name(self.name)
|
|
|
|
end
|
2019-08-17 14:58:27 +02:00
|
|
|
def each(&block)
|
|
|
|
block.call(self)
|
|
|
|
end
|
2019-09-19 19:48:21 +02:00
|
|
|
def to_s
|
|
|
|
@name.to_s
|
|
|
|
end
|
2018-06-29 21:46:39 +02:00
|
|
|
end
|
|
|
|
end
|