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

How to identify lowerings for increment operations or find the source location correctly? #55691

Open
nshahan opened this issue May 10, 2024 · 1 comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-encodings Encoding related CFE issues.

Comments

@nshahan
Copy link
Contributor

nshahan commented May 10, 2024

In the kernel AST for the following code the various forms of incrementing a variable all result in a similar AST structure. If you inspect the .location of each VariableSet node, all point the the source location of the i.

void main() {
  var i = 0;
  i = i + 1;
//^
  i++;
//^
  i += 1;
//^
  ++i;
//  ^
  print(i);
}

This difficulty with this is that I can't tell when the VariableSet came from a lowering of ++i and map the location correctly when compiling the JavaScript in DDC. Is there a way to identify these lowerings? Would it make sense if the VariableSet node pointed to the beginning of the prefix instead?

cc @johnniwinther

@nshahan nshahan added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label May 10, 2024
@johnniwinther
Copy link
Member

I think, if not pointing to i, the VariableSet should point to the operators, i.e. =, ++, += and ++, respectively. Would that be better or worse for your case?

@johnniwinther johnniwinther added the cfe-encodings Encoding related CFE issues. label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-encodings Encoding related CFE issues.
Projects
None yet
Development

No branches or pull requests

2 participants