2018-06-26 19:28:27 +02:00
|
|
|
module Vool
|
|
|
|
class BlockStatement < Statement
|
|
|
|
attr_reader :args , :body , :clazz
|
|
|
|
|
|
|
|
def initialize( args , body , clazz = nil)
|
|
|
|
@args , @body = args , body
|
|
|
|
raise "no bod" unless @body
|
|
|
|
@clazz = clazz
|
|
|
|
end
|
|
|
|
|
2018-07-06 19:01:17 +02:00
|
|
|
# because of normalization (of send), slot_definition is called first,
|
|
|
|
# to assign the block to a variable.
|
|
|
|
#
|
|
|
|
# This means we do the compiler here (rather than to_mom, which is in
|
|
|
|
# fact never called)
|
2018-07-05 13:02:38 +02:00
|
|
|
def slot_definition(compiler)
|
2018-07-06 19:01:17 +02:00
|
|
|
@parfait_block = to_parfait(compiler)
|
|
|
|
compiler.add_constant(@parfait_block)
|
2018-07-05 13:02:38 +02:00
|
|
|
return Mom::SlotDefinition.new(Mom::IntegerConstant.new(1) , [])
|
2018-06-26 19:28:27 +02:00
|
|
|
end
|
|
|
|
|
2018-07-06 19:01:17 +02:00
|
|
|
def to_mom( compiler )
|
|
|
|
# raise "should not be called "
|
|
|
|
end
|
|
|
|
|
2018-06-26 19:28:27 +02:00
|
|
|
def each(&block)
|
|
|
|
block.call(self)
|
|
|
|
@body.each(&block)
|
|
|
|
end
|
|
|
|
|
|
|
|
def normalize
|
|
|
|
BlockStatement.new( @args , @body.normalize)
|
|
|
|
end
|
|
|
|
|
2018-07-06 19:01:17 +02:00
|
|
|
private
|
|
|
|
def to_parfait(compiler)
|
2018-06-26 19:28:27 +02:00
|
|
|
|
2018-07-06 19:01:17 +02:00
|
|
|
end
|
2018-06-26 19:28:27 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|