cowgol
cowgol copied to clipboard
Possible space savings in subroutine calls
cowfe/parser.y allocates temporary storage for return values of function calls like these:
# expression(E) ::= startsubcall inputargs(INA).
a := a + sub();
I think it shouldn't do that for plain subroutine calls, but there's no matching rule for that:
a := sub();
Yes, that could be improved. What it's doing is routing the a := sub() case through the function-call codepath rather than the statement-call codepath; a temporary is needed for function calls to hold the return value in the event of a subsequent call to the same function.
This should be fixed in the new parser which I'm working on (in https://github.com/davidgiven/cowgol/blob/newparser/src/cowfe/parser.coh), but it's not ready yet.