Class: Koto::Parser::AST::Processor::Context::SymbolTable
- Defined in:
- lib/koto/parser/ast/processor/context/symbol_table.rb
Instance Method Summary collapse
- #classes ⇒ Object
- #constants ⇒ Object
-
#initialize(symbol = nil) ⇒ SymbolTable
constructor
A new instance of SymbolTable.
- #instance_methods ⇒ Object
- #instance_variables ⇒ Object
- #methods ⇒ Object
- #modules ⇒ Object
- #private_instance_methods ⇒ Object
- #private_instance_variables ⇒ Object
- #private_methods ⇒ Object
- #record(symbol) ⇒ Object
- #singleton_methods ⇒ Object
- #variables ⇒ Object
Constructor Details
#initialize(symbol = nil) ⇒ SymbolTable
Returns a new instance of SymbolTable.
9 10 11 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 9 def initialize(symbol = nil) record symbol if symbol end |
Instance Method Details
#classes ⇒ Object
75 76 77 78 79 80 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 75 def classes constants.select do |_, constant| _, value = *constant value.type == :class end end |
#constants ⇒ Object
36 37 38 39 40 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 36 def constants select do |_, symbol| symbol.type == :casgn end end |
#instance_methods ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 48 def instance_methods methods.select do |_, method| context = method.context method.type == :def and context.in_class? or context.in_module? end end |
#instance_variables ⇒ Object
24 25 26 27 28 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 24 def instance_variables variables.select do |_, variable| variable.type == :ivasgn end end |
#methods ⇒ Object
42 43 44 45 46 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 42 def methods select do |_, symbol| [:def, :defs].include? symbol.type end end |
#modules ⇒ Object
82 83 84 85 86 87 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 82 def modules constants.select do |_, constant| _, value = *constant value.type == :module end end |
#private_instance_methods ⇒ Object
69 70 71 72 73 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 69 def private_instance_methods instance_methods.select do |_, instance_method| instance_method.access == :private end end |
#private_instance_variables ⇒ Object
30 31 32 33 34 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 30 def private_instance_variables instance_variables.select do |_, instance_variable| instance_variable.access == :private end end |
#private_methods ⇒ Object
63 64 65 66 67 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 63 def private_methods methods.select do |_, method| method.access == :private end end |
#record(symbol) ⇒ Object
13 14 15 16 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 13 def record(symbol) self[symbol.name] = symbol self end |
#singleton_methods ⇒ Object
57 58 59 60 61 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 57 def singleton_methods methods.select do |_, method| method.type == :defs end end |
#variables ⇒ Object
18 19 20 21 22 |
# File 'lib/koto/parser/ast/processor/context/symbol_table.rb', line 18 def variables select do |_, symbol| [:lvasgn, :ivasgn, :cvasgn, :gvasgn].includes? symbol.type end end |