Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible space savings in subroutine calls #151

Open
shattered opened this issue Jun 6, 2024 · 1 comment
Open

Possible space savings in subroutine calls #151

shattered opened this issue Jun 6, 2024 · 1 comment

Comments

@shattered
Copy link
Contributor

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();
@davidgiven
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants