Sha256: 347d0ccedde4de74559e7ca5f904282b35cfdb558221f8e028035a1028bf4923

Contents?: true

Size: 785 Bytes

Versions: 33

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

module Parser

  class StaticEnvironment
    FORWARD_ARGS = :FORWARD_ARGS

    def initialize
      reset
    end

    def reset
      @variables = Set[]
      @stack     = []
    end

    def extend_static
      @stack.push(@variables)
      @variables = Set[]

      self
    end

    def extend_dynamic
      @stack.push(@variables)
      @variables = @variables.dup

      self
    end

    def unextend
      @variables = @stack.pop

      self
    end

    def declare(name)
      @variables.add(name.to_sym)

      self
    end

    def declared?(name)
      @variables.include?(name.to_sym)
    end

    def declare_forward_args
      declare(FORWARD_ARGS)
    end

    def declared_forward_args?
      declared?(FORWARD_ARGS)
    end
  end

end

Version data entries

33 entries across 30 versions & 6 rubygems

Version Path
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/parser-2.7.2.0/lib/parser/static_environment.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/parser-2.7.2.0/lib/parser/static_environment.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.2.0/lib/parser/static_environment.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/parser-2.7.2.0/lib/parser/static_environment.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.2.0/lib/parser/static_environment.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.2.0/lib/parser/static_environment.rb
passbase-1.3.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
passbase-1.2.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
passbase-1.1.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
passbase-1.0.3 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
passbase-1.0.1 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
parser-2.7.2.0 lib/parser/static_environment.rb
parser-2.7.1.5 lib/parser/static_environment.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.0.2/lib/parser/static_environment.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/parser-2.7.1.4/lib/parser/static_environment.rb
parser-2.7.1.4 lib/parser/static_environment.rb
parser-2.7.1.3 lib/parser/static_environment.rb