rubyx/lib/vool/assignment.rb

29 lines
740 B
Ruby
Raw Normal View History

2017-04-01 20:28:57 +02:00
module Vool
2017-04-01 20:28:57 +02:00
class Assignment < Statement
attr_reader :name , :value
2017-04-02 11:59:07 +02:00
def initialize(name , value )
raise "Name nil #{self}" unless name
raise "Value nil #{self}" unless value
raise "Value cant be Assignment #{value}" if value.is_a?(Assignment)
raise "Value cant be Statements #{value}" if value.is_a?(Statements)
2017-04-02 11:59:07 +02:00
@name , @value = name , value
2017-04-01 20:28:57 +02:00
end
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
2018-07-20 19:06:14 +02:00
def chain_assign(assign , compiler)
return assign unless @value.is_a?(CallStatement)
raise "Move me to ruby layer"
2018-07-20 19:06:14 +02:00
@value.to_mom(compiler) << assign
end
2017-04-01 20:28:57 +02:00
end
end