Class: Parser::MaxNumparamStack Private

Inherits:
Object
  • Object
show all
Defined in:
lib/parser/max_numparam_stack.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Holds p->max_numparam from parse.y

Constant Summary collapse

ORDINARY_PARAMS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

-1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMaxNumparamStack

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MaxNumparamStack.



13
14
15
# File 'lib/parser/max_numparam_stack.rb', line 13

def initialize
  @stack = []
end

Instance Attribute Details

#stackObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/parser/max_numparam_stack.rb', line 9

def stack
  @stack
end

Instance Method Details

#empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


17
18
19
# File 'lib/parser/max_numparam_stack.rb', line 17

def empty?
  @stack.size == 0
end

#has_numparams?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


29
30
31
# File 'lib/parser/max_numparam_stack.rb', line 29

def has_numparams?
  top && top > 0
end

#has_ordinary_params!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/parser/max_numparam_stack.rb', line 21

def has_ordinary_params!
  set(ORDINARY_PARAMS)
end

#has_ordinary_params?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


25
26
27
# File 'lib/parser/max_numparam_stack.rb', line 25

def has_ordinary_params?
  top == ORDINARY_PARAMS
end

#popObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
# File 'lib/parser/max_numparam_stack.rb', line 45

def pop
  @stack.pop[:value]
end

#push(static:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/parser/max_numparam_stack.rb', line 41

def push(static:)
  @stack.push(value: 0, static: static)
end

#register(numparam) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
# File 'lib/parser/max_numparam_stack.rb', line 33

def register(numparam)
  set( [top, numparam].max )
end

#topObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
# File 'lib/parser/max_numparam_stack.rb', line 37

def top
  @stack.last[:value]
end