Sha256: 32f650c23d1e0934d3bc7cf61b6de1d35307fcfa8e1c41f495bb21e1908790b5

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

require_relative 'send'
require_relative 'keywords'

module DeepCover
  class Node
    module WithBlock
      def flow_completion_count
        parent.flow_completion_count
      end

      def execution_count
        last = children_nodes.last
        return last.flow_completion_count if last
        super
      end
    end

    class SendWithBlock < Node
      include WithBlock
      has_child receiver: [Node, nil]
      has_child method_name: Symbol
      has_extra_children arguments: Node
    end

    class SuperWithBlock < Node
      include WithBlock
      has_extra_children arguments: Node
    end

    class Block < Node
      check_completion
      has_tracker :body
      has_child call: {send: SendWithBlock, zsuper: SuperWithBlock, super: SuperWithBlock}
      has_child args: Args
      has_child body: Node,
                can_be_empty: -> { base_node.loc.end.begin },
                rewrite: '%{body_tracker};%{local}=nil;%{node}',
                flow_entry_count: :body_tracker_hits,
                is_statement: true
      executed_loc_keys # none

      def children_nodes_in_flow_order
        [call, args] # Similarly to a def, the body is actually not part of the flow of this node...
      end
    end

    # &foo
    class BlockPass < Node
      has_child block: Node
      # TODO
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
deep-cover-0.1.8 lib/deep_cover/node/block.rb
deep-cover-0.1.7 lib/deep_cover/node/block.rb
deep-cover-0.1.6 lib/deep_cover/node/block.rb
deep-cover-0.1.5 lib/deep_cover/node/block.rb