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
|
2018-07-20 08:07:09 +02:00
|
|
|
self.vool_brother.new(name,value)
|
2018-07-19 13:46:51 +02:00
|
|
|
end
|
|
|
|
|
2018-07-19 13:59:10 +02:00
|
|
|
def to_vool_send
|
2018-07-19 13:46:51 +02:00
|
|
|
statements = value.normalize()
|
2018-07-20 08:07:09 +02:00
|
|
|
return copy( statements ) if statements.is_a?(Vool::SendStatement)
|
2018-07-19 13:46:51 +02:00
|
|
|
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()
|
2018-07-20 08:07:09 +02:00
|
|
|
return Vool::IvarAssignment.new(@name , @value)
|
2018-07-19 13:46:51 +02:00
|
|
|
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
|