move common statements into its only use in vool
This commit is contained in:
@ -51,10 +51,10 @@ module Vool
|
||||
head
|
||||
end
|
||||
|
||||
def collect(arr)
|
||||
@if_true.collect(arr)
|
||||
@if_false.collect(arr) if @if_false
|
||||
super
|
||||
def each(&block)
|
||||
block.call(condition)
|
||||
@if_true.each(&block)
|
||||
@if_false.each(&block) if @if_false
|
||||
end
|
||||
|
||||
def simplify_condition
|
||||
|
@ -60,7 +60,7 @@ module Vool
|
||||
type = @receiver.ct_type
|
||||
called_method = type.resolve_method(@name)
|
||||
raise "No method #{@name} for #{type}" unless called_method
|
||||
Mom::Statements.new( message_setup(in_method) << Mom::SimpleCall.new( called_method) )
|
||||
message_setup(in_method) << Mom::SimpleCall.new( called_method)
|
||||
end
|
||||
|
||||
# this breaks cleanly into two parts:
|
||||
|
@ -1,6 +1,35 @@
|
||||
module Vool
|
||||
class Statements < Statement
|
||||
include Common::Statements
|
||||
attr_reader :statements
|
||||
def initialize(statements)
|
||||
@statements = statements
|
||||
end
|
||||
|
||||
def empty?
|
||||
@statements.empty?
|
||||
end
|
||||
def single?
|
||||
@statements.length == 1
|
||||
end
|
||||
def first
|
||||
@statements.first
|
||||
end
|
||||
def last
|
||||
@statements.last
|
||||
end
|
||||
def length
|
||||
@statements.length
|
||||
end
|
||||
def [](i)
|
||||
@statements[i]
|
||||
end
|
||||
def <<(o)
|
||||
@statements << o
|
||||
self
|
||||
end
|
||||
def add_array(a)
|
||||
@statements += a
|
||||
end
|
||||
|
||||
# create machine instructions
|
||||
def to_mom( method )
|
||||
@ -18,7 +47,7 @@ module Vool
|
||||
|
||||
def each(&block)
|
||||
block.call(self)
|
||||
@statements.each{|a| a.each(block)}
|
||||
@statements.each{|a| a.each(&block)}
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user