class Patm::Pattern::LogicalOp
Public Class Methods
new(name, pats, op_str)
click to toggle source
# File lib/patm.rb, line 439 def initialize(name, pats, op_str) @name = name @pats = pats @op_str = op_str end
Public Instance Methods
compile_internal(free_index, target_name = "_obj")
click to toggle source
# File lib/patm.rb, line 444 def compile_internal(free_index, target_name = "_obj") srcs = [] i = free_index ctxs = [] @pats.each do|pat| s, c, i = pat.compile_internal(i, target_name) if !s && @op_str == '||' # dirty... srcs << 'true' else srcs << s end ctxs << c end [ srcs.compact.map{|s| "(#{s})" }.join(" #{@op_str}\n"), ctxs.flatten(1), i ] end
inspect()
click to toggle source
# File lib/patm.rb, line 470 def inspect "#{@name}(#{@pats.map(&:inspect).join(',')})" end
opt?()
click to toggle source
# File lib/patm.rb, line 467 def opt? @pats.any?(&:opt?) end
rest?()
click to toggle source
# File lib/patm.rb, line 464 def rest? @pats.any?(&:rest?) end