Sha256: ec5041d5f5438a6508a3a59bc8ed42809f3c1dae49f9ac0d444839e2052994b8
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
/* Author: Lourens Naudé */ #include "ruby.h" #include "node.h" #include "env.h" static int strhash(register const char *string) { register int c; register int val = 0; while ((c = *string++) != '\0') { val = val*997 + c; } return val + (val>>5); } static VALUE rb_f_callsite(VALUE obj) { struct FRAME *frame = ruby_frame; NODE *n; int csite = 0; if (frame->last_func == ID_ALLOCATOR) frame = frame->prev; ruby_set_current_source(); if (ruby_sourcefile) csite += strhash(ruby_sourcefile); csite += frame->last_func + ruby_sourceline; for (; frame && (n = frame->node); frame = frame->prev) { if (frame->prev && frame->prev->last_func) { if (frame->prev->node == n) { if (frame->prev->last_func == frame->last_func) continue; } csite += frame->prev->last_func; } if (n->nd_file) csite += strhash(n->nd_file); csite += nd_line(n); } return INT2FIX(csite); } void Init_callsite_hash() { rb_define_global_function("callsite_hash", rb_f_callsite, 0); }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
slim_scrooge-1.0.12 | ext/callsite_hash.c |
slim_scrooge-1.0.11 | ext/callsite_hash.c |
slim_scrooge-1.0.10 | ext/callsite_hash.c |