Yes, all four variables in your example are local variables of f. And the number of variables here is 4, but their combined size is 6, since two of them are doubles. In the inner block the outer varables are shadowed, bu you cannot share space in the local variables array, since the outer variables will come into scope again when you leave the inner block.
It is not possible to say from your incomplete example what the maximal size of the stack is.
Your example is incomplete, since there is no return statement, and I assume you just show the variable declarations. Your compiler must keep track of stack sizes at runtime. You must keep in your state an integer variable representing "current stack size when the code I emit is executed". This variable must be updated whenever you emit an instruction that changes the stack size. Another variable in the state will hold "maximal stack size so far". Whenever you update current stack size, you will have to check if the max size needs to be updated.
Best regards
Björn