flow: handle function scope hooks better
This commit is messier than I would have liked. What happened is that at
first I thought maybe each function should have it's own scope. So I
introduced the parse_fn_statements() to make that easier. But then I
realized that actually the {} in the function create a function scope hook.
The issue is that function scope has to be handled specially because there
are a bunch of hooks we want to run at the end of the function and we want
the to do it before the scope hooks have completed. Or if you want it to
run after the scope hooks then use AFTER_FUNC_HOOK. The test for if a
scope was the function scope was badly done, so I have re-written that.
I think the code was not just ugly, but also buggy except I'm not sure what
I was thinking so maybe it was just ugly.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>