Recently, Sean Carley and I have been hacking on ParseTree as we play with some static analysis. Sean has started writing up some of our adventure.
Along the way, Sean’s become enamored with unit_diff, and I’ve played a lot more with gdb and grpof than I thought I’d have to when dealing with Ruby.
Hacking Ruby shouldn’t mean diving into stuff like this (though
RubyInline does
make it easier when you really have to).
case NODE_CASE:
add_to_parse_tree(current, node->nd_head, newlines, locals); /* expr */
node = node->nd_body;
while (node) {
if (nd_type(node) == NODE_WHEN) { /* when */
new_ary = rb_ary_new();
rb_ary_push(current, new_ary);
rb_ary_push(new_ary, rb_ary_entry(node_names, nd_type(node)));
add_to_parse_tree(new_ary, node->nd_head, newlines, locals); /* args */
if (node->nd_body) {
add_to_parse_tree(new_ary, node->nd_body, newlines, locals); /* body */
} else {
rb_ary_push(new_ary, Qnil); /* no body */
}
node = node->nd_next;
} else {
add_to_parse_tree(current, node, newlines, locals);
break; /* else */
}
if (! node) {
rb_ary_push(current, Qnil); /* no else */
}
}
break;
Wouldn’t it be nice to do this kind of crufty work in nice clean Ruby,
and let the system optimize for you when necessary? MetaRuby
is zenspider and Eric Hodel’s project to reqrite Ruby in ruby. It can’t happen
soon enough for me. Metaruby, take me away

