Sha256: 228c898e0335618de221a14f7c795572c2264944eb002731fc9dbad824d65d84
Contents?: true
Size: 905 Bytes
Versions: 3
Compression:
Stored size: 905 Bytes
Contents
# pops the top 2 item of the +:code+ stack; # pushes a new ValuePoint onto the +:bool+ stack, with value +true+ if the # second argument appears as a sub-block anywhere in the first argument # # note: order matters, and the top stack item is the second argument, the second stack item is the first # # *needs:* 2 +:code+ # # *pushes:* 1 +:bool+ # class CodeContainsQInstruction < Instruction def preconditions? needs :code, 2 end def setup @arg2 = @context.pop_value(:code) @arg1 = @context.pop_value(:code) end def derive looking_for_this = NudgeProgram.new(@arg1) tree = NudgeProgram.new(@arg2) if tree.parses? && looking_for_this.parses? found = tree.linked_code.any? {|point| point.blueprint == looking_for_this.blueprint} else found = false end @result = ValuePoint.new("bool", found) end def cleanup pushes :bool, @result end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nudge-0.2.9 | lib/instructions/code/code_contains_q.rb |
nudge-0.2.8 | lib/instructions/code/code_contains_q.rb |
nudge-0.2.7 | lib/instructions/code/code_contains_q.rb |