class RubyParserStuff::Environment::StackState
Attributes
debug[RW]
name[R]
stack[R]
Public Class Methods
new(name, debug=false)
click to toggle source
# File lib/ruby_parser_extras.rb, line 1837 def initialize name, debug=false @name = name @stack = [false] @debug = debug end
Public Instance Methods
inspect()
click to toggle source
# File lib/ruby_parser_extras.rb, line 1843 def inspect "StackState(#{@name}, #{@stack.inspect})" end
is_in_state()
click to toggle source
# File lib/ruby_parser_extras.rb, line 1847 def is_in_state log :is_in_state if debug @stack.last end
lexpop()
click to toggle source
# File lib/ruby_parser_extras.rb, line 1852 def lexpop raise if @stack.size == 0 a = @stack.pop b = @stack.pop @stack.push(a || b) log :lexpop if debug end
log(action)
click to toggle source
# File lib/ruby_parser_extras.rb, line 1860 def log action c = caller[1] c = caller[2] if c =~ /expr_result/ warn "%s_stack.%s: %p at %s" % [name, action, @stack, c.clean_caller] nil end
pop()
click to toggle source
# File lib/ruby_parser_extras.rb, line 1867 def pop r = @stack.pop @stack.push false if @stack.empty? log :pop if debug r end
push(val)
click to toggle source
# File lib/ruby_parser_extras.rb, line 1874 def push val @stack.push val log :push if debug end
reset()
click to toggle source
# File lib/ruby_parser_extras.rb, line 1879 def reset @stack = [false] log :reset if debug end
restore(oldstate)
click to toggle source
# File lib/ruby_parser_extras.rb, line 1884 def restore oldstate @stack.replace oldstate log :restore if debug end
store(base = false)
click to toggle source
# File lib/ruby_parser_extras.rb, line 1889 def store base = false result = @stack.dup @stack.replace [base] log :store if debug result end