Which looping construct is more popular? (an example of source code mining)

55 views
Skip to first unread message

Hridesh Rajan

unread,
Nov 25, 2014, 4:28:18 PM11/25/14
to boa-...@googlegroups.com
# Which looping construct is more popular?
p: Project = input;
do_count: output sum of int;
for_count: output sum of int;
while_count: output sum of int;

analyze_while := function(ws: Statement) {
    
    switch(ws.condition.kind) {
        case ExpressionKind.ANNOTATION: break;
        default:
            break;
    }
    
}; 

visit(p, visitor {

# only look at the latest snapshot
before n: CodeRepository -> {
snapshot := getsnapshot(n);
foreach (i: int; def(snapshot[i]))
visit(snapshot[i]);
stop;
}

before node: Statement -> {
   switch (node.kind) {
      case StatementKind.ASSERT: break;
      case StatementKind.BLOCK:  break;
      case StatementKind.BREAK:  break;
      case StatementKind.CASE:   break;
      case StatementKind.CATCH:  break;
      case StatementKind.CONTINUE: break;
      case StatementKind.DO: do_count << 1; break;
      case StatementKind.EMPTY:  break;
      case StatementKind.EXPRESSION: break;
      case StatementKind.FOR: for_count << 1; break;
      case StatementKind.IF:  break;
      case StatementKind.LABEL:  break;
      case StatementKind.OTHER:  break;
      case StatementKind.RETURN: break;
      case StatementKind.SWITCH: break;
      case StatementKind.SYNCHRONIZED: break;
      case StatementKind.THROW: break;
      case StatementKind.TRY:   break;
      case StatementKind.TYPEDECL: break;
      case StatementKind.WHILE: while_count <<1; analyze_while(node); break;
      default:
    break;
   }
}
});
Reply all
Reply to author
Forward
0 new messages