Class: TypeProf::Core::ActualArguments
- Inherits:
-
Object
- Object
- TypeProf::Core::ActualArguments
show all
- Defined in:
- lib/typeprof/core/env/method.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#add_box_edges(genv, box) ⇒ Object
-
#get_keyword_arg(genv, changes, name) ⇒ Object
-
#get_rest_args(genv, changes, start_rest, end_rest) ⇒ Object
-
#initialize(positionals, splat_flags, keywords, block) ⇒ ActualArguments
constructor
A new instance of ActualArguments.
-
#new_vertexes(genv, node) ⇒ Object
-
#normalize_for_method_call(_genv) ⇒ Object
-
#prepend_positionals(positionals, splat_flags) ⇒ Object
-
#with_block(block, omittable: false) ⇒ Object
-
#with_keywords(keywords) ⇒ Object
-
#with_keywords_as_last_positional_hash ⇒ Object
-
#with_keywords_normalized_for(node) ⇒ Object
Keywords passed to formals that take none are the last positional hash.
Constructor Details
#initialize(positionals, splat_flags, keywords, block) ⇒ ActualArguments
Returns a new instance of ActualArguments.
157
158
159
160
161
162
|
# File 'lib/typeprof/core/env/method.rb', line 157
def initialize(positionals, splat_flags, keywords, block)
@positionals = positionals
@splat_flags = splat_flags
@keywords = keywords
@block = block
end
|
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
164
165
166
|
# File 'lib/typeprof/core/env/method.rb', line 164
def block
@block
end
|
#keywords ⇒ Object
Returns the value of attribute keywords.
164
165
166
|
# File 'lib/typeprof/core/env/method.rb', line 164
def keywords
@keywords
end
|
#positionals ⇒ Object
Returns the value of attribute positionals.
164
165
166
|
# File 'lib/typeprof/core/env/method.rb', line 164
def positionals
@positionals
end
|
#splat_flags ⇒ Object
Returns the value of attribute splat_flags.
164
165
166
|
# File 'lib/typeprof/core/env/method.rb', line 164
def splat_flags
@splat_flags
end
|
Instance Method Details
#add_box_edges(genv, box) ⇒ Object
208
209
210
211
|
# File 'lib/typeprof/core/env/method.rb', line 208
def add_box_edges(genv, box)
@keywords.add_edge(genv, box) if @keywords
@block.add_edge(genv, box) if @block
end
|
#get_keyword_arg(genv, changes, name) ⇒ Object
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
# File 'lib/typeprof/core/env/method.rb', line 239
def get_keyword_arg(genv, changes, name)
vtx = Vertex.new(self)
@keywords.each_type do |ty|
case ty
when Type::Hash
changes.add_edge(genv, ty.get_value(name), vtx)
when Type::Record
field_vtx = ty.get_value(name)
changes.add_edge(genv, field_vtx, vtx) if field_vtx
when Type::Instance
if ty.mod == genv.mod_hash
changes.add_edge(genv, ty.args[1], vtx)
end
else
end
end
vtx
end
|
#get_rest_args(genv, changes, start_rest, end_rest) ⇒ Object
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
# File 'lib/typeprof/core/env/method.rb', line 217
def get_rest_args(genv, changes, start_rest, end_rest)
vtxs = []
start_rest.upto(end_rest - 1) do |i|
a_arg = @positionals[i]
if @splat_flags[i]
a_arg.each_type do |ty|
ty = ty.base_type(genv)
if ty.is_a?(Type::Instance) && ty.mod == genv.mod_ary && ty.args[0]
vtxs << changes.new_vertex(genv, self, ty.args[0])
else
"???"
end
end
else
vtxs << a_arg
end
end
vtxs.uniq
end
|
#new_vertexes(genv, node) ⇒ Object
166
167
168
169
170
171
172
|
# File 'lib/typeprof/core/env/method.rb', line 166
def new_vertexes(genv, node)
positionals = @positionals.map {|arg| arg.new_vertex(genv, node) }
splat_flags = @splat_flags
keywords = @keywords ? @keywords.new_vertex(genv, node) : nil
block = @block ? @block.new_vertex(genv, node) : nil
ActualArguments.new(positionals, splat_flags, keywords, block)
end
|
#normalize_for_method_call(_genv) ⇒ Object
213
214
215
|
# File 'lib/typeprof/core/env/method.rb', line 213
def normalize_for_method_call(_genv)
self
end
|
#prepend_positionals(positionals, splat_flags) ⇒ Object
194
195
196
197
198
|
# File 'lib/typeprof/core/env/method.rb', line 194
def prepend_positionals(positionals, splat_flags)
return self if positionals.empty?
ActualArguments.new(positionals + @positionals, splat_flags + @splat_flags, @keywords, @block)
end
|
#with_block(block, omittable: false) ⇒ Object
204
205
206
|
# File 'lib/typeprof/core/env/method.rb', line 204
def with_block(block, omittable: false)
ActualArguments.new(@positionals, @splat_flags, @keywords, block)
end
|
#with_keywords(keywords) ⇒ Object
200
201
202
|
# File 'lib/typeprof/core/env/method.rb', line 200
def with_keywords(keywords)
ActualArguments.new(@positionals, @splat_flags, keywords, @block)
end
|
#with_keywords_as_last_positional_hash ⇒ Object
174
175
176
177
178
179
180
181
182
183
|
# File 'lib/typeprof/core/env/method.rb', line 174
def with_keywords_as_last_positional_hash
return self unless @keywords
ActualArguments.new(
@positionals + [@keywords],
@splat_flags + [false],
nil,
@block,
)
end
|
#with_keywords_normalized_for(node) ⇒ Object
Keywords passed to formals that take none are the last positional hash.
186
187
188
189
190
191
192
|
# File 'lib/typeprof/core/env/method.rb', line 186
def with_keywords_normalized_for(node)
return self unless keywords
return self if node.no_keywords || node.rest_keywords
return self unless node.req_keywords.empty? && node.opt_keywords.empty?
with_keywords_as_last_positional_hash
end
|