Sha256: d47e2eaf3a30e143f42b4ce107ceaec21e1230c50482f8fee6166b0e1c00938f

Contents?: true

Size: 615 Bytes

Versions: 42

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

module Parser

  class StaticEnvironment
    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
  end

end

Version data entries

42 entries across 31 versions & 6 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/static_environment.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/static_environment.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/static_environment.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/static_environment.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/static_environment.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/static_environment.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/static_environment.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/static_environment.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/static_environment.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/static_environment.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/parser-2.6.5.0/lib/parser/static_environment.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/static_environment.rb
parser-2.6.5.0 lib/parser/static_environment.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/static_environment.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/parser-2.6.4.1/lib/parser/static_environment.rb
parser-2.6.4.1 lib/parser/static_environment.rb
parser-2.6.4.0 lib/parser/static_environment.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/static_environment.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/static_environment.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/parser-2.6.3.0/lib/parser/static_environment.rb