Module: Kernel

Defined in:
lib/rubybreaker.rb

Overview

This method is available by default.

Instance Method Summary collapse

Instance Method Details

#typesig(str) ⇒ Object

:nodoc:



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/rubybreaker.rb', line 211

def typesig(str)
  _TypeDefs = RubyBreaker::TypeDefs

  # This MUST BE set for self type to work in type signatures.
  _TypeDefs::SelfType.set_self(self) 

  t = RubyBreaker::Runtime::TypeSigParser.parse(str)
  t_map = RubyBreaker::Runtime::TYPE_MAP[self]

  # If the type map doesn't exist, create it on the fly. Now this module
  # is broken!
  if !t_map
    t_map = {}
    RubyBreaker::Runtime::TYPE_MAP[self] = t_map
  end

  meth_type = t_map[t.meth_name]
  if meth_type
    if meth_type.instance_of?(_TypeDefs::MethodListType)
      meth_type.types << t
    else
      # then promote it to a method list type
      t_map[t.meth_name] = _TypeDefs::MethodListType.new([meth_type, t])
    end
  else
    t_map[t.meth_name] = t
  end
  return t
end