Class: Parser::StaticEnvironment
- Inherits:
-
Object
- Object
- Parser::StaticEnvironment
- Defined in:
- lib/parser/static_environment.rb
Constant Summary collapse
- FORWARD_ARGS =
:FORWARD_ARGS
- ANONYMOUS_RESTARG_IN_CURRENT_SCOPE =
:ANONYMOUS_RESTARG_IN_CURRENT_SCOPE
- ANONYMOUS_RESTARG_INHERITED =
:ANONYMOUS_RESTARG_INHERITED
- ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE =
:ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE
- ANONYMOUS_KWRESTARG_INHERITED =
:ANONYMOUS_KWRESTARG_INHERITED
- ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE =
:ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE
- ANONYMOUS_BLOCKARG_INHERITED =
:ANONYMOUS_BLOCKARG_INHERITED
Instance Method Summary collapse
- #declare(name) ⇒ Object
-
#declare_anonymous_blockarg ⇒ Object
Anonymous blockarg.
-
#declare_anonymous_kwrestarg ⇒ Object
Anonymous kwresarg.
-
#declare_anonymous_restarg ⇒ Object
Anonymous restarg.
-
#declare_forward_args ⇒ Object
Forward args.
- #declared?(name) ⇒ Boolean
- #declared_anonymous_blockarg? ⇒ Boolean
- #declared_anonymous_blockarg_in_current_scpe? ⇒ Boolean
- #declared_anonymous_kwrestarg? ⇒ Boolean
- #declared_anonymous_kwrestarg_in_current_scope? ⇒ Boolean
- #declared_anonymous_restarg? ⇒ Boolean
- #declared_anonymous_restarg_in_current_scope? ⇒ 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.
17 18 19 |
# File 'lib/parser/static_environment.rb', line 17 def initialize reset end |
Instance Method Details
#declare(name) ⇒ Object
55 56 57 58 59 |
# File 'lib/parser/static_environment.rb', line 55 def declare(name) @variables.add(name.to_sym) self end |
#declare_anonymous_blockarg ⇒ Object
Anonymous blockarg
77 78 79 |
# File 'lib/parser/static_environment.rb', line 77 def declare_anonymous_blockarg declare(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE) end |
#declare_anonymous_kwrestarg ⇒ Object
Anonymous kwresarg
113 114 115 |
# File 'lib/parser/static_environment.rb', line 113 def declare_anonymous_kwrestarg declare(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE) end |
#declare_anonymous_restarg ⇒ Object
Anonymous restarg
95 96 97 |
# File 'lib/parser/static_environment.rb', line 95 def declare_anonymous_restarg declare(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE) end |
#declare_forward_args ⇒ Object
Forward args
67 68 69 |
# File 'lib/parser/static_environment.rb', line 67 def declare_forward_args declare(FORWARD_ARGS) end |
#declared?(name) ⇒ Boolean
61 62 63 |
# File 'lib/parser/static_environment.rb', line 61 def declared?(name) @variables.include?(name.to_sym) end |
#declared_anonymous_blockarg? ⇒ Boolean
81 82 83 |
# File 'lib/parser/static_environment.rb', line 81 def declared_anonymous_blockarg? declared?(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE) || declared?(ANONYMOUS_BLOCKARG_INHERITED) end |
#declared_anonymous_blockarg_in_current_scpe? ⇒ Boolean
85 86 87 |
# File 'lib/parser/static_environment.rb', line 85 def declared_anonymous_blockarg_in_current_scpe? declared?(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE) end |
#declared_anonymous_kwrestarg? ⇒ Boolean
117 118 119 |
# File 'lib/parser/static_environment.rb', line 117 def declared_anonymous_kwrestarg? declared?(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE) || declared?(ANONYMOUS_KWRESTARG_INHERITED) end |
#declared_anonymous_kwrestarg_in_current_scope? ⇒ Boolean
121 122 123 |
# File 'lib/parser/static_environment.rb', line 121 def declared_anonymous_kwrestarg_in_current_scope? declared?(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE) end |
#declared_anonymous_restarg? ⇒ Boolean
99 100 101 |
# File 'lib/parser/static_environment.rb', line 99 def declared_anonymous_restarg? declared?(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE) || declared?(ANONYMOUS_RESTARG_INHERITED) end |
#declared_anonymous_restarg_in_current_scope? ⇒ Boolean
103 104 105 |
# File 'lib/parser/static_environment.rb', line 103 def declared_anonymous_restarg_in_current_scope? declared?(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE) end |
#declared_forward_args? ⇒ Boolean
71 72 73 |
# File 'lib/parser/static_environment.rb', line 71 def declared_forward_args? declared?(FORWARD_ARGS) end |
#empty? ⇒ Boolean
129 130 131 |
# File 'lib/parser/static_environment.rb', line 129 def empty? @stack.empty? end |
#extend_dynamic ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/parser/static_environment.rb', line 33 def extend_dynamic @stack.push(@variables) @variables = @variables.dup if @variables.delete(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE) @variables.add(ANONYMOUS_BLOCKARG_INHERITED) end if @variables.delete(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE) @variables.add(ANONYMOUS_RESTARG_INHERITED) end if @variables.delete(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE) @variables.add(ANONYMOUS_KWRESTARG_INHERITED) end self end |
#extend_static ⇒ Object
26 27 28 29 30 31 |
# File 'lib/parser/static_environment.rb', line 26 def extend_static @stack.push(@variables) @variables = Set[] self end |
#parent_has_anonymous_blockarg? ⇒ Boolean
89 90 91 |
# File 'lib/parser/static_environment.rb', line 89 def parent_has_anonymous_blockarg? @stack.any? { |variables| variables.include?(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE) } end |
#parent_has_anonymous_kwrestarg? ⇒ Boolean
125 126 127 |
# File 'lib/parser/static_environment.rb', line 125 def parent_has_anonymous_kwrestarg? @stack.any? { |variables| variables.include?(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE) } end |
#parent_has_anonymous_restarg? ⇒ Boolean
107 108 109 |
# File 'lib/parser/static_environment.rb', line 107 def parent_has_anonymous_restarg? @stack.any? { |variables| variables.include?(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE) } end |
#reset ⇒ Object
21 22 23 24 |
# File 'lib/parser/static_environment.rb', line 21 def reset @variables = Set[] @stack = [] end |
#unextend ⇒ Object
49 50 51 52 53 |
# File 'lib/parser/static_environment.rb', line 49 def unextend @variables = @stack.pop self end |