In Files

  • typeprof-0.12.0/lib/typeprof/analyzer.rb
  • typeprof-0.12.0/lib/typeprof/type.rb
  • typeprof-0.12.0/smoke/alias.rb
  • typeprof-0.12.0/smoke/any1.rb
  • typeprof-0.12.0/smoke/any2.rb
  • typeprof-0.12.0/smoke/arguments.rb
  • typeprof-0.12.0/smoke/arguments2.rb
  • typeprof-0.12.0/smoke/array-each.rb
  • typeprof-0.12.0/smoke/array-each2.rb
  • typeprof-0.12.0/smoke/array-each3.rb
  • typeprof-0.12.0/smoke/array-ltlt.rb
  • typeprof-0.12.0/smoke/array-ltlt2.rb
  • typeprof-0.12.0/smoke/array-map.rb
  • typeprof-0.12.0/smoke/array-map2.rb
  • typeprof-0.12.0/smoke/array-map3.rb
  • typeprof-0.12.0/smoke/array-mul.rb
  • typeprof-0.12.0/smoke/array-plus1.rb
  • typeprof-0.12.0/smoke/array-pop.rb
  • typeprof-0.12.0/smoke/array-range-aref.rb
  • typeprof-0.12.0/smoke/array-replace.rb
  • typeprof-0.12.0/smoke/array-s-aref.rb
  • typeprof-0.12.0/smoke/array1.rb
  • typeprof-0.12.0/smoke/array10.rb
  • typeprof-0.12.0/smoke/array11.rb
  • typeprof-0.12.0/smoke/array12.rb
  • typeprof-0.12.0/smoke/array13.rb
  • typeprof-0.12.0/smoke/array14.rb
  • typeprof-0.12.0/smoke/array2.rb
  • typeprof-0.12.0/smoke/array4.rb
  • typeprof-0.12.0/smoke/array5.rb
  • typeprof-0.12.0/smoke/array6.rb
  • typeprof-0.12.0/smoke/array7.rb
  • typeprof-0.12.0/smoke/array9.rb
  • typeprof-0.12.0/smoke/autoload.rb
  • typeprof-0.12.0/smoke/backtrace.rb
  • typeprof-0.12.0/smoke/block-ambiguous.rb
  • typeprof-0.12.0/smoke/block-args1-rest.rb
  • typeprof-0.12.0/smoke/block-args1.rb
  • typeprof-0.12.0/smoke/block-args2-rest.rb
  • typeprof-0.12.0/smoke/block-args2.rb
  • typeprof-0.12.0/smoke/block-args3-rest.rb
  • typeprof-0.12.0/smoke/block-args3.rb
  • typeprof-0.12.0/smoke/block-blockarg.rb
  • typeprof-0.12.0/smoke/block-kwarg.rb
  • typeprof-0.12.0/smoke/block1.rb
  • typeprof-0.12.0/smoke/block10.rb
  • typeprof-0.12.0/smoke/block11.rb
  • typeprof-0.12.0/smoke/block12.rb
  • typeprof-0.12.0/smoke/block14.rb
  • typeprof-0.12.0/smoke/block2.rb
  • typeprof-0.12.0/smoke/block4.rb
  • typeprof-0.12.0/smoke/block5.rb
  • typeprof-0.12.0/smoke/block6.rb
  • typeprof-0.12.0/smoke/block7.rb
  • typeprof-0.12.0/smoke/block8.rb
  • typeprof-0.12.0/smoke/block9.rb
  • typeprof-0.12.0/smoke/block_given.rb
  • typeprof-0.12.0/smoke/blown.rb
  • typeprof-0.12.0/smoke/break1.rb
  • typeprof-0.12.0/smoke/break2.rb
  • typeprof-0.12.0/smoke/break3.rb
  • typeprof-0.12.0/smoke/case.rb
  • typeprof-0.12.0/smoke/case2.rb
  • typeprof-0.12.0/smoke/case3.rb
  • typeprof-0.12.0/smoke/class-hierarchy.rb
  • typeprof-0.12.0/smoke/class-new.rb
  • typeprof-0.12.0/smoke/constant1.rb
  • typeprof-0.12.0/smoke/constant2.rb
  • typeprof-0.12.0/smoke/constant3.rb
  • typeprof-0.12.0/smoke/constant4.rb
  • typeprof-0.12.0/smoke/context-sensitive1.rb
  • typeprof-0.12.0/smoke/cvar.rb
  • typeprof-0.12.0/smoke/define_method6.rb
  • typeprof-0.12.0/smoke/demo.rb
  • typeprof-0.12.0/smoke/demo1.rb
  • typeprof-0.12.0/smoke/demo10.rb
  • typeprof-0.12.0/smoke/demo11.rb
  • typeprof-0.12.0/smoke/demo2.rb
  • typeprof-0.12.0/smoke/demo3.rb
  • typeprof-0.12.0/smoke/demo7.rb
  • typeprof-0.12.0/smoke/demo8.rb
  • typeprof-0.12.0/smoke/demo9.rb
  • typeprof-0.12.0/smoke/dummy-execution1.rb
  • typeprof-0.12.0/smoke/ensure1.rb
  • typeprof-0.12.0/smoke/enum_for.rb
  • typeprof-0.12.0/smoke/enumerator.rb
  • typeprof-0.12.0/smoke/expandarray1.rb
  • typeprof-0.12.0/smoke/expandarray2.rb
  • typeprof-0.12.0/smoke/flip-flop.rb
  • typeprof-0.12.0/smoke/flow1.rb
  • typeprof-0.12.0/smoke/flow10.rb
  • typeprof-0.12.0/smoke/flow2.rb
  • typeprof-0.12.0/smoke/flow3.rb
  • typeprof-0.12.0/smoke/flow5.rb
  • typeprof-0.12.0/smoke/flow6.rb
  • typeprof-0.12.0/smoke/flow7.rb
  • typeprof-0.12.0/smoke/flow8.rb
  • typeprof-0.12.0/smoke/flow9.rb
  • typeprof-0.12.0/smoke/freeze.rb
  • typeprof-0.12.0/smoke/function.rb
  • typeprof-0.12.0/smoke/gvar.rb
  • typeprof-0.12.0/smoke/gvar2.rb
  • typeprof-0.12.0/smoke/hash-bot.rb
  • typeprof-0.12.0/smoke/hash-fetch.rb
  • typeprof-0.12.0/smoke/hash-merge-bang.rb
  • typeprof-0.12.0/smoke/hash1.rb
  • typeprof-0.12.0/smoke/hash2.rb
  • typeprof-0.12.0/smoke/hash3.rb
  • typeprof-0.12.0/smoke/hash4.rb
  • typeprof-0.12.0/smoke/initialize.rb
  • typeprof-0.12.0/smoke/int_times.rb
  • typeprof-0.12.0/smoke/integer.rb
  • typeprof-0.12.0/smoke/ivar.rb
  • typeprof-0.12.0/smoke/ivar4.rb
  • typeprof-0.12.0/smoke/kernel-class.rb
  • typeprof-0.12.0/smoke/keyword1.rb
  • typeprof-0.12.0/smoke/keyword2.rb
  • typeprof-0.12.0/smoke/keyword3.rb
  • typeprof-0.12.0/smoke/keyword4.rb
  • typeprof-0.12.0/smoke/keyword5.rb
  • typeprof-0.12.0/smoke/kwsplat1.rb
  • typeprof-0.12.0/smoke/kwsplat2.rb
  • typeprof-0.12.0/smoke/lit-complex.rb
  • typeprof-0.12.0/smoke/lit-encoding.rb
  • typeprof-0.12.0/smoke/manual-rbs.rb
  • typeprof-0.12.0/smoke/manual-rbs2.rb
  • typeprof-0.12.0/smoke/masgn1.rb
  • typeprof-0.12.0/smoke/masgn2.rb
  • typeprof-0.12.0/smoke/masgn3.rb
  • typeprof-0.12.0/smoke/method_in_branch.rb
  • typeprof-0.12.0/smoke/module6.rb
  • typeprof-0.12.0/smoke/multiple-superclass.rb
  • typeprof-0.12.0/smoke/next1.rb
  • typeprof-0.12.0/smoke/next2.rb
  • typeprof-0.12.0/smoke/object-send1.rb
  • typeprof-0.12.0/smoke/object-send2.rb
  • typeprof-0.12.0/smoke/object-send3.rb
  • typeprof-0.12.0/smoke/once.rb
  • typeprof-0.12.0/smoke/optional1.rb
  • typeprof-0.12.0/smoke/optional2.rb
  • typeprof-0.12.0/smoke/optional3.rb
  • typeprof-0.12.0/smoke/parameterizedd-self.rb
  • typeprof-0.12.0/smoke/parameterizedd-self2.rb
  • typeprof-0.12.0/smoke/pathname1.rb
  • typeprof-0.12.0/smoke/pathname2.rb
  • typeprof-0.12.0/smoke/pattern-match1.rb
  • typeprof-0.12.0/smoke/pattern-match2.rb
  • typeprof-0.12.0/smoke/prepend2.rb
  • typeprof-0.12.0/smoke/primitive_method.rb
  • typeprof-0.12.0/smoke/proc.rb
  • typeprof-0.12.0/smoke/proc2.rb
  • typeprof-0.12.0/smoke/proc3.rb
  • typeprof-0.12.0/smoke/proc4.rb
  • typeprof-0.12.0/smoke/proc5.rb
  • typeprof-0.12.0/smoke/public.rb
  • typeprof-0.12.0/smoke/range.rb
  • typeprof-0.12.0/smoke/rbs-alias.rb
  • typeprof-0.12.0/smoke/rbs-attr.rb
  • typeprof-0.12.0/smoke/rbs-extend.rb
  • typeprof-0.12.0/smoke/rbs-interface.rb
  • typeprof-0.12.0/smoke/rbs-opt-and-rest.rb
  • typeprof-0.12.0/smoke/rbs-proc1.rb
  • typeprof-0.12.0/smoke/rbs-proc2.rb
  • typeprof-0.12.0/smoke/rbs-proc3.rb
  • typeprof-0.12.0/smoke/rbs-record.rb
  • typeprof-0.12.0/smoke/rbs-tyvar.rb
  • typeprof-0.12.0/smoke/rbs-tyvar2.rb
  • typeprof-0.12.0/smoke/rbs-tyvar3.rb
  • typeprof-0.12.0/smoke/rbs-tyvar5.rb
  • typeprof-0.12.0/smoke/rbs-tyvar6.rb
  • typeprof-0.12.0/smoke/rbs-tyvar7.rb
  • typeprof-0.12.0/smoke/rbs-vars.rb
  • typeprof-0.12.0/smoke/redo1.rb
  • typeprof-0.12.0/smoke/redo2.rb
  • typeprof-0.12.0/smoke/req-keyword.rb
  • typeprof-0.12.0/smoke/rescue1.rb
  • typeprof-0.12.0/smoke/rescue2.rb
  • typeprof-0.12.0/smoke/rescue3.rb
  • typeprof-0.12.0/smoke/rescue4.rb
  • typeprof-0.12.0/smoke/respond_to.rb
  • typeprof-0.12.0/smoke/rest-farg.rb
  • typeprof-0.12.0/smoke/rest1.rb
  • typeprof-0.12.0/smoke/rest2.rb
  • typeprof-0.12.0/smoke/rest3.rb
  • typeprof-0.12.0/smoke/rest4.rb
  • typeprof-0.12.0/smoke/rest5.rb
  • typeprof-0.12.0/smoke/rest6.rb
  • typeprof-0.12.0/smoke/retry1.rb
  • typeprof-0.12.0/smoke/return.rb
  • typeprof-0.12.0/smoke/simple.rb
  • typeprof-0.12.0/smoke/singleton_method.rb
  • typeprof-0.12.0/smoke/step.rb
  • typeprof-0.12.0/smoke/string-split.rb
  • typeprof-0.12.0/smoke/struct-keyword_init.rb
  • typeprof-0.12.0/smoke/struct2.rb
  • typeprof-0.12.0/smoke/struct5.rb
  • typeprof-0.12.0/smoke/stub-keyword.rb
  • typeprof-0.12.0/smoke/super1.rb
  • typeprof-0.12.0/smoke/svar1.rb
  • typeprof-0.12.0/smoke/symbol-proc-attr.rb
  • typeprof-0.12.0/smoke/symbol-proc-bot.rb
  • typeprof-0.12.0/smoke/symbol-proc.rb
  • typeprof-0.12.0/smoke/tap1.rb
  • typeprof-0.12.0/smoke/toplevel.rb
  • typeprof-0.12.0/smoke/two-map.rb
  • typeprof-0.12.0/smoke/type_var.rb
  • typeprof-0.12.0/smoke/typed_method.rb
  • typeprof-0.12.0/smoke/uninitialize-var.rb
  • typeprof-0.12.0/smoke/wrong-rbs.rb
  • typeprof-0.12.0/testbed/ao.rb
  • typeprof-0.12.0/tools/setup-insns-def.rb

Class/Module Index [+]

Quicksearch

Object

Constants

A
ARY
Ary
BAR
Base
C
CONST
DummySubstitution
F
Foo
FooBar
IMAGE_HEIGHT
IMAGE_WIDTH

AO render benchmark Original program (C) Syoyo Fujita in Javascript (and other languages)

https://code.google.com/p/aobench/

Ruby(yarv2llvm) version by Hideki Miura mruby version by Hideki Miura

INSN_TABLE
Insn
NAO_SAMPLES
NSUBSAMPLES
StringArray
V

Public Class Methods

any() click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 403
def self.any
  @any ||= Any.new
end
            
bool() click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 411
def self.bool
  @bool ||= Union.new(Utils::Set[
    Instance.new(Type::Builtin[:true]),
    Instance.new(Type::Builtin[:false])
  ], nil)
end
            
bot() click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 407
def self.bot
  @bot ||= Union.new(Utils::Set[], nil)
end
            
builtin_global_variable_type(var) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 760
def self.builtin_global_variable_type(var)
  case var
  when :$_, :$/, :$\, :$,, :$;
    Type.optional(Type::Instance.new(Type::Builtin[:str]))
  when :$0, :$PROGRAM_NAME
    Type::Instance.new(Type::Builtin[:str])
  when :$~
    Type.optional(Type::Instance.new(Type::Builtin[:matchdata]))
  when :$., :$$
    Type::Instance.new(Type::Builtin[:int])
  when :$?
    Type.optional(Type::Instance.new(Type::Builtin[:int]))
  when :$!
    Type.optional(Type::Instance.new(Type::Builtin[:exc]))
  when :$@
    str = Type::Instance.new(Type::Builtin[:str])
    base_ty = Type::Instance.new(Type::Builtin[:ary])
    Type.optional(Type::Array.new(Type::Array::Elements.new([], str), base_ty))
  when :$*, :$:, :$LOAD_PATH, :$", :$LOADED_FEATURES
    str = Type::Instance.new(Type::Builtin[:str])
    base_ty = Type::Instance.new(Type::Builtin[:ary])
    Type::Array.new(Type::Array::Elements.new([], str), base_ty)
  when :$<
    :ARGF
  when :$>
    :STDOUT
  when :$DEBUG
    Type.bool
  when :$FILENAME
    Type::Instance.new(Type::Builtin[:str])
  when :$stdin
    :STDIN
  when :$stdout
    :STDOUT
  when :$stderr
    :STDERR
  when :$VERBOSE
    Type.bool.union(Type.nil)
  else
    nil
  end
end
            
gen_hash(base_ty = Type::Instance.new(Type::Builtin[:hash])) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 701
def self.gen_hash(base_ty = Type::Instance.new(Type::Builtin[:hash]))
  hg = HashGenerator.new
  yield hg
  Type::Hash.new(Type::Hash::Elements.new(hg.map_tys), base_ty)
end
            
guess_literal_type(obj) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 707
def self.guess_literal_type(obj)
  case obj
  when ::Symbol
    Type::Symbol.new(obj, Type::Instance.new(Type::Builtin[:sym]))
  when ::Integer
    Type::Literal.new(obj, Type::Instance.new(Type::Builtin[:int]))
  when ::Rational
    Type::Literal.new(obj, Type::Instance.new(Type::Builtin[:rational]))
  when ::Complex
    Type::Literal.new(obj, Type::Instance.new(Type::Builtin[:complex]))
  when ::Float
    Type::Literal.new(obj, Type::Instance.new(Type::Builtin[:float]))
  when ::Class
    return Type.any if obj < Exception
    case obj
    when ::Object
      Type::Builtin[:obj]
    when ::Array
      Type::Builtin[:ary]
    else
      raise "unknown class: #{ obj.inspect }"
    end
  when ::TrueClass
    Type::Instance.new(Type::Builtin[:true])
  when ::FalseClass
    Type::Instance.new(Type::Builtin[:false])
  when ::Array
    base_ty = Type::Instance.new(Type::Builtin[:ary])
    lead_tys = obj.map {|arg| guess_literal_type(arg) }
    Type::Array.new(Type::Array::Elements.new(lead_tys), base_ty)
  when ::Hash
    Type.gen_hash do |h|
      obj.each do |k, v|
        k_ty = guess_literal_type(k).globalize(nil, {}, Config.options[:type_depth_limit])
        v_ty = guess_literal_type(v)
        h[k_ty] = v_ty
      end
    end
  when ::String
    Type::Literal.new(obj, Type::Instance.new(Type::Builtin[:str]))
  when ::Regexp
    Type::Literal.new(obj, Type::Instance.new(Type::Builtin[:regexp]))
  when ::NilClass
    Type.nil
  when ::Range
    Type::Literal.new(obj, Type::Instance.new(Type::Builtin[:range]))
  when ::Encoding
    Type::Literal.new(obj, Type::Instance.new(Type::Builtin[:encoding]))
  else
    raise "unknown object: #{ obj.inspect }"
  end
end
            
nil() click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 418
def self.nil
  @nil ||= Instance.new(Type::Builtin[:nil])
end
            
optional(ty) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 422
def self.optional(ty)
  ty.union(Type.nil)
end
            

Public Instance Methods

array(obj) click to toggle source
 
               # File typeprof-0.12.0/smoke/array11.rb, line 1
def array(obj)
    Array(obj)
end
            
ary() click to toggle source
 
               # File typeprof-0.12.0/smoke/masgn2.rb, line 1
def ary
  [1, "str", :sym, 1.0]
end
            
bar(x) click to toggle source
Alias for: foo
baz(n) click to toggle source
 
               # File typeprof-0.12.0/smoke/array1.rb, line 5
def baz(n); end
            
clamp(f) click to toggle source
 
               # File typeprof-0.12.0/testbed/ao.rb, line 142
def clamp(f)
  i = f * 255.5
  if i > 255.0
    i = 255.0
  end
  if i < 0.0
    i = 0.0
  end
  i.to_i
end
            
cond1?() click to toggle source
 
               # File typeprof-0.12.0/smoke/flip-flop.rb, line 1
def cond1?
  rand < 0.5
end
            
cond2?() click to toggle source
 
               # File typeprof-0.12.0/smoke/flip-flop.rb, line 5
def cond2?
  rand < 0.5
end
            
corge() click to toggle source
 
               # File typeprof-0.12.0/smoke/public.rb, line 18
def corge
end
            
dispatch(*ary) click to toggle source
 
               # File typeprof-0.12.0/smoke/array-range-aref.rb, line 41
def dispatch(*ary)
  f1(*ary)
  f2(*ary)
  f3(*ary)
  f4(*ary)
  f5(*ary)
  f6(*ary)
  f7(*ary)
  f8(*ary)
  f9(*ary)
  f10(*ary)
end
            
do_define_iseq_method(ep, env, mid, iseq, outer_ep) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/analyzer.rb, line 2105
def do_define_iseq_method(ep, env, mid, iseq, outer_ep)
  cref = ep.ctx.cref
  if cref.klass.is_a?(Type::Class)
    typed_mdef = check_typed_method(cref.klass, mid, ep.ctx.cref.singleton)
    recv = cref.klass
    recv = Type::Instance.new(recv) unless ep.ctx.cref.singleton
    if typed_mdef
      mdef = ISeqMethodDef.new(iseq, cref, outer_ep, env.static_env.pub_meth)
      typed_mdef.each do |typed_mdef|
        typed_mdef.do_match_iseq_mdef(mdef, recv, mid, env, ep, self)
      end
    else
      if ep.ctx.cref.singleton
        meth = add_singleton_iseq_method(cref.klass, mid, iseq, cref, outer_ep, true)
      else
        meth = add_iseq_method(cref.klass, mid, iseq, cref, outer_ep, env.static_env.pub_meth)
        if env.static_env.mod_func
          add_singleton_iseq_method(cref.klass, mid, iseq, cref, outer_ep, true)
        end
      end
    end

    pend_method_execution(iseq, meth, recv, mid, ep.ctx.cref, outer_ep)
  else
    # XXX: what to do?
  end
end
            
do_invoke_block(blk, aargs, ep, env, replace_recv_ty: nil, &ctn) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/analyzer.rb, line 2094
def do_invoke_block(blk, aargs, ep, env, replace_recv_ty: nil, &ctn)
  blk.each_child do |blk|
    if blk.is_a?(Type::Proc)
      blk.block_body.do_call(aargs, ep, env, self, replace_recv_ty: replace_recv_ty, &ctn)
    else
      warn(ep, "non-proc is passed as a block")
      ctn[Type.any, ep, env]
    end
  end
end
            
do_send(recv, mid, aargs, ep, env, &ctn) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/analyzer.rb, line 2065
def do_send(recv, mid, aargs, ep, env, &ctn)
  case recv
  when Type::Void
    error(ep, "void's method is called: #{ globalize_type(recv, env, ep).screen_name(self) }##{ mid }")
    ctn[Type.any, ep, env]
  when Type::Any
    ctn[Type.any, ep, env]
  else
    klass, singleton = recv.method_dispatch_info
    meths = get_method(klass, singleton, mid) if klass
    if meths
      meths.each do |meth|
        meth.do_send(recv, mid, aargs, ep, env, self, &ctn)
      end
    else
      meths = get_method(klass, singleton, :method_missing) if klass
      if meths
        aargs = aargs.for_method_missing(Type::Symbol.new(mid, Type::Instance.new(Type::Builtin[:sym])))
        meths.each do |meth|
          meth.do_send(recv, :method_missing, aargs, ep, env, self, &ctn)
        end
      else
        error(ep, "undefined method: #{ globalize_type(recv, env, ep).screen_name(self) }##{ mid }")
        ctn[Type.any, ep, env]
      end
    end
  end
end
            
f(a, b, c) click to toggle source
 
               # File typeprof-0.12.0/smoke/array14.rb, line 1
def f(a, b, c)
  ary = [nil]
  foo, bar, ary[0] = a, b, c
  ary[0]
end
            
f1() click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 1
def f1
end
            
f10(&blk) click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 37
def f10(&blk)
  blk.call(1)
end
            
f2(x, y, z) click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 5
def f2(x, y, z)
end
            
f3(x = "str", y = "str") click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 9
def f3(x = "str", y = "str")
end
            
f4(*r) click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 13
def f4(*r)
end
            
f5(x, y = "str", z) click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 17
def f5(x, y = "str", z)
end
            
f6(k:) click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 21
def f6(k))
end
            
f7(k: 42) click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 25
def f7(k: 42)
end
            
f8(k: "str") click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 29
def f8(k: "str")
end
            
f9(**kw) click to toggle source
 
               # File typeprof-0.12.0/smoke/arguments2.rb, line 33
def f9(**kw)
end
            
fib(x) click to toggle source

recursive method

 
               # File typeprof-0.12.0/smoke/demo.rb, line 30
def fib(x)
  if x <= 1
    x
  else
    fib(x - 1) + fib(x - 2)
  end
end
            
foo(x) click to toggle source
 
               # File typeprof-0.12.0/smoke/alias.rb, line 1
def foo(x)
  x
end
            
Also aliased as: bar
fuga() click to toggle source
 
               # File typeprof-0.12.0/smoke/enumerator.rb, line 4
def fuga
  1.then
end
            
gen_foobar() click to toggle source
 
               # File typeprof-0.12.0/smoke/struct2.rb, line 7
def gen_foobar
  FooBar.new(1)
end
            
generate_substitution() click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 152
def generate_substitution
  {}
end
            
get_interface() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-interface.rb, line 9
def get_interface
  C.new.get_interface
end
            
get_interface_foo() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-interface.rb, line 13
def get_interface_foo
  C.new.get_interface.foo
end
            
get_module() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-interface.rb, line 1
def get_module
  C.new.get_module
end
            
get_module_foo() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-interface.rb, line 5
def get_module_foo
  C.new.get_module.foo
end
            
grault(a, o=1, *r, z) click to toggle source
 
               # File typeprof-0.12.0/smoke/rest3.rb, line 23
def grault(a, o=1, *r, z)
end
            
gvar_test() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-vars.rb, line 1
def gvar_test
  $gvar
end
            
hoge() click to toggle source
 
               # File typeprof-0.12.0/smoke/enumerator.rb, line 1
def hoge
  [1, 2, 3].map
end
            
identity(x) click to toggle source

overrided method

 
               # File typeprof-0.12.0/smoke/demo.rb, line 16
def identity(x)
  x
end
            
include_untyped?(_scratch) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 165
def include_untyped?(_scratch)
  false
end
            
log(x) click to toggle source
 
               # File typeprof-0.12.0/smoke/array-each.rb, line 1
def log(x)
end
            
log1(x) click to toggle source
 
               # File typeprof-0.12.0/smoke/block-ambiguous.rb, line 4
def log1(x); end
            
log2(x) click to toggle source
 
               # File typeprof-0.12.0/smoke/block-ambiguous.rb, line 10
def log2(x); end
            
log3(x) click to toggle source
 
               # File typeprof-0.12.0/smoke/block-ambiguous.rb, line 16
def log3(x); end
            
log4(x) click to toggle source
 
               # File typeprof-0.12.0/smoke/block-ambiguous.rb, line 22
def log4(x); end
            
log5(a, o, c) click to toggle source
 
               # File typeprof-0.12.0/smoke/block-args1-rest.rb, line 43
def log5(a, o, c); end
            
log6(a, o, r, c) click to toggle source
 
               # File typeprof-0.12.0/smoke/block-args3-rest.rb, line 52
def log6(a, o, r, c); end
            
map_bang_test(a) click to toggle source
 
               # File typeprof-0.12.0/smoke/array-map3.rb, line 4
def map_bang_test(a)
  a.map! {|n| n.to_s }
  a
end
            
map_bang_test_known_bug(a) click to toggle source
 
               # File typeprof-0.12.0/smoke/array-map3.rb, line 8
def map_bang_test_known_bug(a)
  a.map! {|n| n.to_s }
end
            
map_test(a) click to toggle source
 
               # File typeprof-0.12.0/smoke/array-map3.rb, line 1
def map_test(a)
  a.map {|n| n.to_s }
end
            
my_to_s(x) click to toggle source

override

 
               # File typeprof-0.12.0/smoke/demo2.rb, line 2
def my_to_s(x)
  x.to_s
end
            
no_argument() click to toggle source
 
               # File typeprof-0.12.0/smoke/function.rb, line 1
def no_argument
  "str"
end
            
number?(ty) click to toggle source
 
               # File typeprof-0.12.0/smoke/type_var.rb, line 1
def number?(ty)
  %w[integer float].include?(ty).then { puts 1 }
end
            
one_argument(x) click to toggle source
 
               # File typeprof-0.12.0/smoke/function.rb, line 5
def one_argument(x)
end
            
otherBasis(n) click to toggle source
 
               # File typeprof-0.12.0/testbed/ao.rb, line 153
def otherBasis(n)
  zero = Vec.new(0.0, 0.0, 0.0)
  basis = [zero, zero, zero]
  basis[2] = Vec.new(n.x, n.y, n.z)
  basis[1] = Vec.new(0.0, 0.0, 0.0)

  if n.x < 0.6 and n.x > -0.6
    basis[1].x = 1.0
  elsif n.y < 0.6 and n.y > -0.6
    basis[1].y = 1.0
  elsif n.z < 0.6 and n.z > -0.6
    basis[1].z = 1.0
  else
    basis[1].x = 1.0
  end

  basis[0] = basis[1].vcross(basis[2])
  basis[0] = basis[0].vnormalize

  basis[1] = basis[2].vcross(basis[0])
  basis[1] = basis[1].vnormalize

  basis
end
            
quux(n) click to toggle source
 
               # File typeprof-0.12.0/smoke/array1.rb, line 7
def quux(n); end
            
qux(n) click to toggle source
 
               # File typeprof-0.12.0/smoke/array1.rb, line 6
def qux(n); end
            
read_test_1() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-attr.rb, line 1
def read_test_1
  Foo.new.reader_example
end
            
read_test_2() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-attr.rb, line 5
def read_test_2
  Foo.new.accessor_example
end
            
remove_type_vars() click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 161
def remove_type_vars
  substitute(DummySubstitution, Config.options[:type_depth_limit])
end
            
ret_int() click to toggle source
 
               # File typeprof-0.12.0/smoke/manual-rbs.rb, line 12
def ret_int
  foo(42)
end
            
ret_str() click to toggle source
 
               # File typeprof-0.12.0/smoke/manual-rbs.rb, line 16
def ret_str
  foo("str")
end
            
seq_get() click to toggle source
 
               # File typeprof-0.12.0/smoke/array13.rb, line 18
def seq_get
  ary = [:a, :b, :c] + []
  ary[-1]
end
            
seq_set() click to toggle source
 
               # File typeprof-0.12.0/smoke/array13.rb, line 12
def seq_set
  ary = [:a, :b, :c] + []
  ary[-1] = :z
  ary
end
            
show_block_signature(blks) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/analyzer.rb, line 2133
def show_block_signature(blks)
  bsig = nil
  ret_ty = Type.bot

  blks.each do |blk|
    blk.each_child_global do |blk|
      bsig0 = @block_signatures[blk.block_body]
      if bsig0
        if bsig
          bsig = bsig.merge(bsig0)
        else
          bsig = bsig0
        end
      end

      @block_to_ctx[blk.block_body]&.each do |blk_ctx|
        ret_ty = ret_ty.union(@return_values[blk_ctx]) if @return_values[blk_ctx]
      end
    end
  end

  bsig ||= BlockSignature.new([], [], nil, Type.nil)

  bsig = bsig.screen_name(nil, self)
  ret_ty = ret_ty.screen_name(self)
  ret_ty = (ret_ty.include?("|") ? "(#{ ret_ty })" : ret_ty) # XXX?

  bsig = bsig + " " if bsig != ""
  "{ #{ bsig }-> #{ ret_ty } }"
end
            
show_method_signature(ctx) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/analyzer.rb, line 2191
def show_method_signature(ctx)
  farg_tys = @method_signatures[ctx]
  ret_ty = @return_values[ctx] || Type.bot

  untyped = farg_tys.include_untyped?(self) || ret_ty.include_untyped?(self)

  farg_tys = farg_tys.screen_name(ctx.iseq, self)
  ret_ty = ret_ty.screen_name(self)
  ret_ty = (ret_ty.include?("|") ? "(#{ ret_ty })" : ret_ty) # XXX?

  ["#{ (farg_tys.empty? ? "" : "#{ farg_tys } ") }-> #{ ret_ty }", untyped]
end
            
show_proc_signature(blks) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/analyzer.rb, line 2164
def show_proc_signature(blks)
  farg_tys, ret_ty = nil, Type.bot

  blks.each do |blk|
    blk.each_child_global do |blk|
      next if blk.block_body.is_a?(TypedBlock) # XXX: Support TypedBlock
      next unless @block_to_ctx[blk.block_body] # this occurs when screen_name is called before type-profiling finished (e.g., error message)
      @block_to_ctx[blk.block_body].each do |blk_ctx|
        if farg_tys
          farg_tys = farg_tys.merge_as_block_arguments(@method_signatures[blk_ctx])
        else
          farg_tys = @method_signatures[blk_ctx]
        end

        ret_ty = ret_ty.union(@return_values[blk_ctx]) if @return_values[blk_ctx]
      end
    end
  end

  farg_tys = farg_tys ? farg_tys.screen_name(nil, self) : "(unknown)"
  ret_ty = ret_ty.screen_name(self)
  ret_ty = (ret_ty.include?("|") ? "(#{ ret_ty })" : ret_ty) # XXX?

  farg_tys = farg_tys + " " if farg_tys != ""
  "^#{ farg_tys }-> #{ ret_ty }"
end
            
substitute(_subst, _depth) click to toggle source
 
               # File typeprof-0.12.0/lib/typeprof/type.rb, line 148
def substitute(_subst, _depth)
  raise "cannot substitute abstract type: #{ self.class }"
end
            
swap(a) click to toggle source
 
               # File typeprof-0.12.0/smoke/demo11.rb, line 1
def swap(a)
  [a[1], a[0]]
end
            
test_bar() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-record.rb, line 6
def test_bar
  h = { }
  h[:a] = 42
  C.new.bar(h)
end
            
test_foo() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-record.rb, line 1
def test_foo
  h = C.new.foo
  return h[:aaa], h[:bbb]
end
            
test_yield() click to toggle source
 
               # File typeprof-0.12.0/smoke/array12.rb, line 4
def test_yield
  yield
end
            
top() click to toggle source
 
               # File typeprof-0.12.0/testbed/ao.rb, line 288
def top
  Scene.new.render(IMAGE_WIDTH, IMAGE_HEIGHT, NSUBSAMPLES)
end
            
tuple_get() click to toggle source
 
               # File typeprof-0.12.0/smoke/array13.rb, line 7
def tuple_get
  ary = [:a, :b, :c]
  ary[-1]
end
            
tuple_set() click to toggle source
 
               # File typeprof-0.12.0/smoke/array13.rb, line 1
def tuple_set
  ary = [:a, :b, :c]
  ary[-1] = :z
  ary
end
            
write_test() click to toggle source
 
               # File typeprof-0.12.0/smoke/rbs-attr.rb, line 9
def write_test
  Foo.new.writer_example = 1
  Foo.new.writer_example = "str"
  Foo.new.accessor_example = 1
  Foo.new.accessor_example = "str"
end