rubyx/lib/vool/statements/assign_statement.rb
Torsten Ruger 78ef1368de introducing expressions and constants
not everything statement anymore (as in ruby)
basic statement tests working, rest havoc
2018-03-15 11:24:14 +05:30

34 lines
726 B
Ruby

module Vool
class Assignment < Statement
attr_reader :name , :value
def initialize(name , value )
@name , @value = name , value
end
def normalize()
raise "not named left #{name}" unless @name.is_a?(Named)
raise "unsupported right #{value}" unless @name.is_a?(Named) or
@name.is_a?(SendStatement) or @name.is_a?(Constant)
self
end
def collect(arr)
@value.collect(arr)
super
end
end
class IvarAssignment < Assignment
# used to collect type information
def add_ivar( array )
array << @name
end
def to_mom( method )
@value.slot_class.new([:message , :receiver , @name] , @value.to_mom(method))
end
end
end