Class: RubyParserStuff::StackState
- Inherits:
-
Object
- Object
- RubyParserStuff::StackState
- Defined in:
- lib/ruby_parser_extras.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Instance Method Summary collapse
-
#initialize(name) ⇒ StackState
constructor
A new instance of StackState.
- #inspect ⇒ Object
- #is_in_state ⇒ Object
- #lexpop ⇒ Object
- #pop ⇒ Object
- #push(val) ⇒ Object
- #restore(oldstate) ⇒ Object
- #store ⇒ Object
Constructor Details
#initialize(name) ⇒ StackState
Returns a new instance of StackState.
1275 1276 1277 1278 1279 |
# File 'lib/ruby_parser_extras.rb', line 1275 def initialize(name) @name = name @stack = [false] @debug = false end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
1273 1274 1275 |
# File 'lib/ruby_parser_extras.rb', line 1273 def debug @debug end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1271 1272 1273 |
# File 'lib/ruby_parser_extras.rb', line 1271 def name @name end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
1272 1273 1274 |
# File 'lib/ruby_parser_extras.rb', line 1272 def stack @stack end |
Instance Method Details
#inspect ⇒ Object
1281 1282 1283 |
# File 'lib/ruby_parser_extras.rb', line 1281 def inspect "StackState(#{@name}, #{@stack.inspect})" end |
#is_in_state ⇒ Object
1285 1286 1287 1288 |
# File 'lib/ruby_parser_extras.rb', line 1285 def is_in_state p :stack_is_in_state => [name, @stack.last, caller.first] if debug @stack.last end |
#lexpop ⇒ Object
1290 1291 1292 1293 1294 1295 1296 |
# File 'lib/ruby_parser_extras.rb', line 1290 def lexpop p :stack_lexpop => caller.first if debug raise if @stack.size == 0 a = @stack.pop b = @stack.pop @stack.push(a || b) end |
#pop ⇒ Object
1298 1299 1300 1301 1302 1303 |
# File 'lib/ruby_parser_extras.rb', line 1298 def pop r = @stack.pop p :stack_pop => [name, r, @stack, caller.first] if debug @stack.push false if @stack.size == 0 r end |
#push(val) ⇒ Object
1305 1306 1307 1308 1309 |
# File 'lib/ruby_parser_extras.rb', line 1305 def push val @stack.push val p :stack_push => [name, @stack, caller.first] if debug nil end |
#restore(oldstate) ⇒ Object
1317 1318 1319 |
# File 'lib/ruby_parser_extras.rb', line 1317 def restore oldstate @stack.replace oldstate end |
#store ⇒ Object
1311 1312 1313 1314 1315 |
# File 'lib/ruby_parser_extras.rb', line 1311 def store result = @stack.dup @stack.replace [false] result end |