# 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;
}
}
});