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