Class: Marshalsea::Scanner::Candidate
- Inherits:
-
Object
- Object
- Marshalsea::Scanner::Candidate
- Defined in:
- lib/marshalsea/scanner.rb
Instance Attribute Summary collapse
-
#arity ⇒ Object
readonly
Returns the value of attribute arity.
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#formats ⇒ Object
readonly
Returns the value of attribute formats.
-
#gate ⇒ Object
readonly
Returns the value of attribute gate.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#source_location ⇒ Object
readonly
Returns the value of attribute source_location.
Instance Method Summary collapse
- #accepts_dispatch? ⇒ Boolean
- #dispatch_arity ⇒ Object
- #entry_point? ⇒ Boolean
- #gated? ⇒ Boolean
-
#initialize(class_name:, method_name:, gate:, source_location:, arity:, singleton:, touches_state:, formats:) ⇒ Candidate
constructor
A new instance of Candidate.
- #link? ⇒ Boolean
- #reachable? ⇒ Boolean
- #singleton? ⇒ Boolean
- #soft_gated? ⇒ Boolean
- #state_known? ⇒ Boolean
- #to_s ⇒ Object
- #touches_state? ⇒ Boolean
- #unanalysable? ⇒ Boolean
- #unreadable_source? ⇒ Boolean
- #zero_arity? ⇒ Boolean
Constructor Details
#initialize(class_name:, method_name:, gate:, source_location:, arity:, singleton:, touches_state:, formats:) ⇒ Candidate
Returns a new instance of Candidate.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/marshalsea/scanner.rb', line 78 def initialize(class_name:, method_name:, gate:, source_location:, arity:, singleton:, touches_state:, formats:) @class_name = class_name @method_name = method_name @gate = gate @source_location = source_location @arity = arity @singleton = singleton @touches_state = touches_state @formats = formats end |
Instance Attribute Details
#arity ⇒ Object (readonly)
Returns the value of attribute arity.
76 77 78 |
# File 'lib/marshalsea/scanner.rb', line 76 def arity @arity end |
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
76 77 78 |
# File 'lib/marshalsea/scanner.rb', line 76 def class_name @class_name end |
#formats ⇒ Object (readonly)
Returns the value of attribute formats.
76 77 78 |
# File 'lib/marshalsea/scanner.rb', line 76 def formats @formats end |
#gate ⇒ Object (readonly)
Returns the value of attribute gate.
76 77 78 |
# File 'lib/marshalsea/scanner.rb', line 76 def gate @gate end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
76 77 78 |
# File 'lib/marshalsea/scanner.rb', line 76 def method_name @method_name end |
#source_location ⇒ Object (readonly)
Returns the value of attribute source_location.
76 77 78 |
# File 'lib/marshalsea/scanner.rb', line 76 def source_location @source_location end |
Instance Method Details
#accepts_dispatch? ⇒ Boolean
114 115 116 117 118 119 120 |
# File 'lib/marshalsea/scanner.rb', line 114 def accepts_dispatch? required = dispatch_arity return true if required == VARIADIC return arity == required unless arity.negative? required >= (arity.abs - 1) end |
#dispatch_arity ⇒ Object
110 111 112 |
# File 'lib/marshalsea/scanner.rb', line 110 def dispatch_arity ENTRY_POINTS.fetch(method_name).fetch(:arity) end |
#entry_point? ⇒ Boolean
106 107 108 |
# File 'lib/marshalsea/scanner.rb', line 106 def entry_point? !link? end |
#gated? ⇒ Boolean
94 95 96 |
# File 'lib/marshalsea/scanner.rb', line 94 def gated? gate == GATE_GATED end |
#link? ⇒ Boolean
102 103 104 |
# File 'lib/marshalsea/scanner.rb', line 102 def link? gate == GATE_LINK end |
#reachable? ⇒ Boolean
142 143 144 145 146 147 148 |
# File 'lib/marshalsea/scanner.rb', line 142 def reachable? return false unless entry_point? return false unless accepts_dispatch? return true if gated? || soft_gated? touches_state? || unreadable_source? end |
#singleton? ⇒ Boolean
90 91 92 |
# File 'lib/marshalsea/scanner.rb', line 90 def singleton? @singleton end |
#soft_gated? ⇒ Boolean
98 99 100 |
# File 'lib/marshalsea/scanner.rb', line 98 def soft_gated? gate == GATE_SOFT end |
#state_known? ⇒ Boolean
130 131 132 |
# File 'lib/marshalsea/scanner.rb', line 130 def state_known? STATE_VERDICTS.include?(@touches_state) end |
#to_s ⇒ Object
150 151 152 |
# File 'lib/marshalsea/scanner.rb', line 150 def to_s "#{class_name}#{singleton? ? '.' : '#'}#{method_name}" end |
#touches_state? ⇒ Boolean
126 127 128 |
# File 'lib/marshalsea/scanner.rb', line 126 def touches_state? @touches_state == true end |
#unanalysable? ⇒ Boolean
134 135 136 |
# File 'lib/marshalsea/scanner.rb', line 134 def unanalysable? @touches_state == STATE_UNANALYSABLE end |
#unreadable_source? ⇒ Boolean
138 139 140 |
# File 'lib/marshalsea/scanner.rb', line 138 def unreadable_source? @touches_state == STATE_UNREADABLE end |
#zero_arity? ⇒ Boolean
122 123 124 |
# File 'lib/marshalsea/scanner.rb', line 122 def zero_arity? arity.zero? end |