rubyx/lib/vool/statements/variables.rb

40 lines
744 B
Ruby
Raw Normal View History

module Vool
module Named
attr_reader :name
def initialize name
@name = name
end
end
class LocalVariable < Expression
include Named
2017-09-04 20:31:49 +02:00
def to_mom(method)
if method.args_type.variable_index(@name)
type = :arguments
else
type = :frame
end
Mom::SlotDefinition.new(:message , [type , @name])
end
end
class InstanceVariable < Expression
include Named
2017-09-04 20:31:49 +02:00
def to_mom(method)
Mom::SlotDefinition.new(:message , [ :receiver , @name] )
2017-09-04 20:31:49 +02:00
end
2017-04-08 11:11:52 +02:00
# used to collect type information
def add_ivar( array )
array << @name
end
end
class ClassVariable < Expression
include Named
end
class ModuleName < Expression
2017-04-04 17:00:21 +02:00
include Named
end
end