Class: Luoma::StaticAnalysis::StaticScope

Inherits:
Object
  • Object
show all
Defined in:
lib/luoma/static_analysis.rb,
sig/luoma/static_analysis.rbs

Overview

Helper to manage variable scope during static analysis.

Instance Method Summary collapse

Constructor Details

#initialize(globals) ⇒ StaticScope

(Set) -> void

Parameters:

  • globals (Set[String])


126
127
128
# File 'lib/luoma/static_analysis.rb', line 126

def initialize(globals)
  @stack = [globals] #: Array[Set[String]]
end

Instance Method Details

#add(name) ⇒ void

This method returns an undefined value.

Parameters:

  • name (String)


143
144
145
# File 'lib/luoma/static_analysis.rb', line 143

def add(name)
  @stack.first.add(name)
end

#include?(key) ⇒ Boolean

Parameters:

  • key (String)

Returns:

  • (Boolean)


130
131
132
# File 'lib/luoma/static_analysis.rb', line 130

def include?(key)
  @stack.any? { |scope| scope.include?(key) }
end

#popObject

Returns:

  • (Object)


139
140
141
# File 'lib/luoma/static_analysis.rb', line 139

def pop
  @stack.pop
end

#push(scope) ⇒ self

Parameters:

  • scope (Set[String])

Returns:

  • (self)


134
135
136
137
# File 'lib/luoma/static_analysis.rb', line 134

def push(scope)
  @stack << scope
  self
end