2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
|
|
|
|
|
|
|
class Assignment < Statement
|
|
|
|
attr_reader :name , :value
|
|
|
|
def initialize(name , value )
|
|
|
|
@name , @value = name , value
|
|
|
|
end
|
|
|
|
|
2018-07-19 13:59:10 +02:00
|
|
|
def to_vool()
|
2018-07-19 13:46:51 +02:00
|
|
|
raise "not named left #{name.class}" unless name.is_a?(Symbol)
|
|
|
|
case value
|
|
|
|
when Named , Constant
|
|
|
|
return copy
|
|
|
|
when SendStatement
|
|
|
|
return normalize_send
|
|
|
|
else
|
|
|
|
raise "unsupported right #{value}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def copy(value = nil)
|
|
|
|
value ||= @value
|
|
|
|
self.class.new(name,value)
|
|
|
|
end
|
|
|
|
|
2018-07-19 13:59:10 +02:00
|
|
|
def to_vool_send
|
2018-07-19 13:46:51 +02:00
|
|
|
statements = value.normalize()
|
|
|
|
return copy( statements ) if statements.is_a?(SendStatement)
|
|
|
|
assign = statements.statements.pop
|
|
|
|
statements << copy(assign)
|
|
|
|
statements
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s(depth = 0)
|
|
|
|
at_depth(depth , "#{@name} = #{@value}")
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
class IvarAssignment < Assignment
|
|
|
|
|
2018-07-19 13:59:10 +02:00
|
|
|
def to_vool()
|
2018-07-19 13:46:51 +02:00
|
|
|
super()
|
|
|
|
return IvarAssignment.new(@name , @value)
|
|
|
|
end
|
2018-07-19 13:59:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class LocalAssignment < Assignment
|
2018-07-19 13:46:51 +02:00
|
|
|
|
|
|
|
end
|
2018-07-19 13:59:10 +02:00
|
|
|
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|