Break removeRandomJunk() into smaller steps, in preparation for reordering some of them.
Break removeRandomJunk() into smaller steps, in preparation for reordering some
of them.

Moved removeUnusedFunctions() and removeUnusedTypes() after
insertRuntimeTypeTemps().

Factored removeRandomJunk into four functions:
  removeUnusedGlobals();
  removeRandomCalls();
  removeActualNames();
  removeTypeBlocks();

In each of the four smaller functions, replaced the memory-expensive idiom
  Vec<BaseAST*> asts;
  collect_asts_postorder(rootModule, asts);
  forv_Vec(BaseAST, ast, asts) {
    if (<foo>Expr* foo = to<foo>Expr(ast)) {
with a traversal over the subclass of Expr which the kernel of that function
wants to visit.  So, in addition to clarifying the code, we might pick up a
slight performance improvement:  Rather than copying and traversing all of the
ASTs in the tree, we just iterate the lists we're interested in.

Converted the if ... else if ... construct involving the various primitive
types into a switch, and moved this part of removeRandomCalls() out to its own
routine.

[tested on / (std)]
[reviewed by noakes]


git-svn-id: 88467cb1fb04b8a755be7e1ee1026be4190196ef@23476 3a8e244f-b0f2-452b-bcba-4c88e055c3ca

CoryMcCartan/chapel,sungeunchoi/chapel,hildeth/chapel,sungeunchoi/chapel,hildeth/chapel,chizarlicious/chapel,hildeth/chapel,CoryMcCartan/chapel,sungeunchoi/chapel,sungeunchoi/chapel,sungeunchoi/chapel,chizarlicious/chapel,hildeth/chapel,CoryMcCartan/chapel,CoryMcCartan/chapel,chizarlicious/chapel,hildeth/chapel,chizarlicious/chapel,chizarlicious/chapel,CoryMcCartan/chapel,CoryMcCartan/chapel,sungeunchoi/chapel,hildeth/chapel,sungeunchoi/chapel,chizarlicious/chapel,hildeth/chapel,chizarlicious/chapel,sungeunchoi/chapel,CoryMcCartan/chapel