2017-04-01 20:28:57 +02:00
|
|
|
module Vool
|
2017-04-12 19:29:45 +02:00
|
|
|
|
2017-04-01 20:28:57 +02:00
|
|
|
class Assignment < Statement
|
2017-04-06 15:06:51 +02:00
|
|
|
attr_reader :name , :value
|
2017-04-02 11:59:07 +02:00
|
|
|
def initialize(name , value )
|
|
|
|
@name , @value = name , value
|
2017-04-01 20:28:57 +02:00
|
|
|
end
|
2018-03-15 06:54:14 +01:00
|
|
|
|
2018-03-15 16:03:38 +01:00
|
|
|
def each(&block)
|
|
|
|
block.call(self)
|
|
|
|
@value.each(&block)
|
2017-04-08 11:10:42 +02:00
|
|
|
end
|
2018-07-03 21:18:19 +02:00
|
|
|
|
|
|
|
def to_s(depth = 0)
|
|
|
|
at_depth(depth , "#{@name} = #{@value}")
|
|
|
|
end
|
|
|
|
|
2017-04-01 20:28:57 +02:00
|
|
|
end
|
2017-04-12 13:45:02 +02:00
|
|
|
|
2017-04-12 19:29:45 +02:00
|
|
|
class IvarAssignment < Assignment
|
2018-03-15 16:03:38 +01:00
|
|
|
|
2018-07-05 13:02:38 +02:00
|
|
|
def to_mom( compiler )
|
2018-03-15 16:03:38 +01:00
|
|
|
to = Mom::SlotDefinition.new(:message ,[ :receiver , @name])
|
2018-07-05 13:02:38 +02:00
|
|
|
from = @value.slot_definition(compiler)
|
|
|
|
return chain_assign( Mom::SlotLoad.new(to,from) , compiler)
|
2017-04-12 19:29:45 +02:00
|
|
|
end
|
|
|
|
|
2017-04-04 17:10:28 +02:00
|
|
|
end
|
2017-04-01 20:28:57 +02:00
|
|
|
end
|