Class: TypeProf::Core::ActualArguments

Inherits:
Object
  • Object
show all
Defined in:
lib/typeprof/core/env/method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(positionals, splat_flags, keywords, block) ⇒ ActualArguments

Returns a new instance of ActualArguments.



27
28
29
30
31
32
# File 'lib/typeprof/core/env/method.rb', line 27

def initialize(positionals, splat_flags, keywords, block)
  @positionals = positionals
  @splat_flags = splat_flags
  @keywords = keywords
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



34
35
36
# File 'lib/typeprof/core/env/method.rb', line 34

def block
  @block
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



34
35
36
# File 'lib/typeprof/core/env/method.rb', line 34

def keywords
  @keywords
end

#positionalsObject (readonly)

Returns the value of attribute positionals.



34
35
36
# File 'lib/typeprof/core/env/method.rb', line 34

def positionals
  @positionals
end

#splat_flagsObject (readonly)

Returns the value of attribute splat_flags.



34
35
36
# File 'lib/typeprof/core/env/method.rb', line 34

def splat_flags
  @splat_flags
end

Instance Method Details

#get_keyword_arg(genv, changes, name) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/typeprof/core/env/method.rb', line 66

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::Instance
      if ty.mod == genv.mod_hash
        changes.add_edge(genv, ty.args[1], vtx)
      end
    else
      # what to do?
    end
  end
  vtx
end

#get_rest_args(genv, start_rest, end_rest) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/typeprof/core/env/method.rb', line 44

def get_rest_args(genv, 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 << ty.args[0].new_vertex(genv, self)
        else
          "???"
        end
      end
    else
      vtxs << a_arg
    end
  end

  vtxs.uniq
end

#new_vertexes(genv, node) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/typeprof/core/env/method.rb', line 36

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