Sha256: 8cfc2f896c62d5270a35feb0bac71d2b10bb884f9d760fe7b16da78afba1901d

Contents?: true

Size: 1.41 KB

Versions: 2789

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module Parser

  class StaticEnvironment
    FORWARD_ARGS = :FORWARD_ARGS
    ANONYMOUS_BLOCKARG = :ANONYMOUS_BLOCKARG
    ANONYMOUS_RESTARG = :ANONYMOUS_RESTARG
    ANONYMOUS_KWRESTARG = :ANONYMOUS_KWRESTARG

    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

    def declare_anonymous_blockarg
      declare(ANONYMOUS_BLOCKARG)
    end

    def declared_anonymous_blockarg?
      declared?(ANONYMOUS_BLOCKARG)
    end

    def declare_anonymous_restarg
      declare(ANONYMOUS_RESTARG)
    end

    def declared_anonymous_restarg?
      declared?(ANONYMOUS_RESTARG)
    end

    def declare_anonymous_kwrestarg
      declare(ANONYMOUS_KWRESTARG)
    end

    def declared_anonymous_kwrestarg?
      declared?(ANONYMOUS_KWRESTARG)
    end

    def empty?
      @stack.empty?
    end
  end

end

Version data entries

2,789 entries across 2,789 versions & 24 rubygems

Version Path
cybrid_api_id_ruby-0.113.41 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_id_ruby-0.113.38 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_bank_ruby-0.113.38 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_organization_ruby-0.113.38 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_id_ruby-0.113.37 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_organization_ruby-0.113.37 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_bank_ruby-0.113.37 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_id_ruby-0.113.36 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_bank_ruby-0.113.36 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_organization_ruby-0.113.36 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_organization_ruby-0.113.35 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_bank_ruby-0.113.35 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_id_ruby-0.113.35 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_bank_ruby-0.113.31 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_id_ruby-0.113.31 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_organization_ruby-0.113.31 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_bank_ruby-0.113.30 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_id_ruby-0.113.30 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_organization_ruby-0.113.30 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb
cybrid_api_bank_ruby-0.113.29 vendor/bundle/ruby/3.2.0/gems/parser-3.2.2.4/lib/parser/static_environment.rb