Sha256: 1cb7034a1895e53d5175db2979adcf214adc8831f6de83b7530940202579e4a1

Contents?: true

Size: 580 Bytes

Versions: 8

Compression:

Stored size: 580 Bytes

Contents

# frozen_string_literal: true

module Parser

  class MaxNumparamStack
    attr_reader :stack

    def initialize
      @stack = []
    end

    def has_ordinary_params!
      set(-1)
    end

    def has_ordinary_params?
      top < 0
    end

    def has_numparams?
      top && top > 0
    end

    def register(numparam)
      set( [top, numparam].max )
    end

    def top
      @stack.last
    end

    def push
      @stack.push(0)
    end

    def pop
      @stack.pop
    end

    private

    def set(value)
      @stack.pop
      @stack.push(value)
    end
  end

end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/parser-2.7.2.0/lib/parser/max_numparam_stack.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/parser-2.7.2.0/lib/parser/max_numparam_stack.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.2.0/lib/parser/max_numparam_stack.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/parser-2.7.2.0/lib/parser/max_numparam_stack.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.2.0/lib/parser/max_numparam_stack.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.2.0/lib/parser/max_numparam_stack.rb
parser-2.7.2.0 lib/parser/max_numparam_stack.rb
parser-2.7.1.5 lib/parser/max_numparam_stack.rb