Class: Parser::StaticEnvironment
- Inherits:
-
Object
- Object
- Parser::StaticEnvironment
- Defined in:
- lib/parser/static_environment.rb
Constant Summary collapse
- FORWARD_ARGS =
:FORWARD_ARGS
- ANONYMOUS_BLOCKARG =
:ANONYMOUS_BLOCKARG
- ANONYMOUS_RESTARG =
:ANONYMOUS_RESTARG
- ANONYMOUS_KWRESTARG =
:ANONYMOUS_KWRESTARG
Instance Method Summary collapse
- #declare(name) ⇒ Object
- #declare_anonymous_blockarg ⇒ Object
- #declare_anonymous_kwrestarg ⇒ Object
- #declare_anonymous_restarg ⇒ Object
- #declare_forward_args ⇒ Object
- #declared?(name) ⇒ Boolean
- #declared_anonymous_blockarg? ⇒ Boolean
- #declared_anonymous_kwrestarg? ⇒ Boolean
- #declared_anonymous_restarg? ⇒ Boolean
- #declared_forward_args? ⇒ Boolean
- #empty? ⇒ Boolean
- #extend_dynamic ⇒ Object
- #extend_static ⇒ Object
-
#initialize ⇒ StaticEnvironment
constructor
A new instance of StaticEnvironment.
- #parent_has_anonymous_blockarg? ⇒ Boolean
- #parent_has_anonymous_kwrestarg? ⇒ Boolean
- #parent_has_anonymous_restarg? ⇒ Boolean
- #reset ⇒ Object
- #unextend ⇒ Object
Constructor Details
#initialize ⇒ StaticEnvironment
Returns a new instance of StaticEnvironment.
11 12 13 |
# File 'lib/parser/static_environment.rb', line 11 def initialize reset end |
Instance Method Details
#declare(name) ⇒ Object
40 41 42 43 44 |
# File 'lib/parser/static_environment.rb', line 40 def declare(name) @variables.add(name.to_sym) self end |
#declare_anonymous_blockarg ⇒ Object
58 59 60 |
# File 'lib/parser/static_environment.rb', line 58 def declare_anonymous_blockarg declare(ANONYMOUS_BLOCKARG) end |
#declare_anonymous_kwrestarg ⇒ Object
82 83 84 |
# File 'lib/parser/static_environment.rb', line 82 def declare_anonymous_kwrestarg declare(ANONYMOUS_KWRESTARG) end |
#declare_anonymous_restarg ⇒ Object
70 71 72 |
# File 'lib/parser/static_environment.rb', line 70 def declare_anonymous_restarg declare(ANONYMOUS_RESTARG) end |
#declare_forward_args ⇒ Object
50 51 52 |
# File 'lib/parser/static_environment.rb', line 50 def declare_forward_args declare(FORWARD_ARGS) end |
#declared?(name) ⇒ Boolean
46 47 48 |
# File 'lib/parser/static_environment.rb', line 46 def declared?(name) @variables.include?(name.to_sym) end |
#declared_anonymous_blockarg? ⇒ Boolean
62 63 64 |
# File 'lib/parser/static_environment.rb', line 62 def declared_anonymous_blockarg? declared?(ANONYMOUS_BLOCKARG) end |
#declared_anonymous_kwrestarg? ⇒ Boolean
86 87 88 |
# File 'lib/parser/static_environment.rb', line 86 def declared_anonymous_kwrestarg? declared?(ANONYMOUS_KWRESTARG) end |
#declared_anonymous_restarg? ⇒ Boolean
74 75 76 |
# File 'lib/parser/static_environment.rb', line 74 def declared_anonymous_restarg? declared?(ANONYMOUS_RESTARG) end |
#declared_forward_args? ⇒ Boolean
54 55 56 |
# File 'lib/parser/static_environment.rb', line 54 def declared_forward_args? declared?(FORWARD_ARGS) end |
#empty? ⇒ Boolean
94 95 96 |
# File 'lib/parser/static_environment.rb', line 94 def empty? @stack.empty? end |
#extend_dynamic ⇒ Object
27 28 29 30 31 32 |
# File 'lib/parser/static_environment.rb', line 27 def extend_dynamic @stack.push(@variables) @variables = @variables.dup self end |
#extend_static ⇒ Object
20 21 22 23 24 25 |
# File 'lib/parser/static_environment.rb', line 20 def extend_static @stack.push(@variables) @variables = Set[] self end |
#parent_has_anonymous_blockarg? ⇒ Boolean
66 67 68 |
# File 'lib/parser/static_environment.rb', line 66 def parent_has_anonymous_blockarg? @stack.any? { |variables| variables.include?(ANONYMOUS_BLOCKARG) } end |
#parent_has_anonymous_kwrestarg? ⇒ Boolean
90 91 92 |
# File 'lib/parser/static_environment.rb', line 90 def parent_has_anonymous_kwrestarg? @stack.any? { |variables| variables.include?(ANONYMOUS_KWRESTARG) } end |
#parent_has_anonymous_restarg? ⇒ Boolean
78 79 80 |
# File 'lib/parser/static_environment.rb', line 78 def parent_has_anonymous_restarg? @stack.any? { |variables| variables.include?(ANONYMOUS_RESTARG) } end |
#reset ⇒ Object
15 16 17 18 |
# File 'lib/parser/static_environment.rb', line 15 def reset @variables = Set[] @stack = [] end |
#unextend ⇒ Object
34 35 36 37 38 |
# File 'lib/parser/static_environment.rb', line 34 def unextend @variables = @stack.pop self end |