Class: Patm::Pattern::LogicalOp
Direct Known Subclasses
And, Or
Instance Method Summary
collapse
#&, #[], build_from, #compile, #execute, #opt
Constructor Details
#initialize(pats, op_str) ⇒ LogicalOp
Returns a new instance of LogicalOp.
333
334
335
336
|
# File 'lib/patm.rb', line 333
def initialize(pats, op_str)
@pats = pats
@op_str = op_str
end
|
Instance Method Details
#compile_internal(free_index, target_name = "_obj") ⇒ Object
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
# File 'lib/patm.rb', line 337
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)
srcs << s
ctxs << c
end
[
srcs.compact.map{|s| "(#{s})" }.join(" #{@op_str}\n"),
ctxs.flatten(1),
i
]
end
|
#opt? ⇒ Boolean
356
357
358
|
# File 'lib/patm.rb', line 356
def opt?
@pats.any?(&:opt?)
end
|
#rest? ⇒ Boolean
353
354
355
|
# File 'lib/patm.rb', line 353
def rest?
@pats.any?(&:rest?)
end
|