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

Added translator support for Modulus token #136

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crosstl/src/translator/codegen/directx_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,14 @@ def map_operator(self, op):
"MINUS": "-",
"MULTIPLY": "*",
"DIVIDE": "/",
"MOD": "%",
"LESS_THAN": "<",
"GREATER_THAN": ">",
"ASSIGN_ADD": "+=",
"ASSIGN_SUB": "-=",
"ASSIGN_MUL": "*=",
"ASSIGN_DIV": "/=",
"ASSIGN_MOD": "%=",
"LESS_EQUAL": "<=",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have working on MOD operator so only add changes for MOD don't add Assign_MOD here someone else might working on this task . or you can assign this task also to yourself and mention in PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll make the changes and only include the modifications for the MOD operator in the PR

"GREATER_EQUAL": ">=",
"EQUAL": "==",
Expand Down
4 changes: 3 additions & 1 deletion crosstl/src/translator/codegen/metal_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,13 @@ def map_operator(self, op):
"MINUS": "-",
"MULTIPLY": "*",
"DIVIDE": "/",
"LESS_THAN": "<",
"MOD": "%",
"ASSIGN_ADD": "+=",
"ASSIGN_SUB": "-=",
"ASSIGN_MUL": "*=",
"ASSIGN_DIV": "/=",
"ASSIGN_MOD": "%=",
"LESS_THAN": "<",
"GREATER_THAN": ">",
"LESS_EQUAL": "<=",
"GREATER_EQUAL": ">=",
Expand Down
4 changes: 3 additions & 1 deletion crosstl/src/translator/codegen/opengl_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,13 @@ def map_operator(self, op):
"MINUS": "-",
"MULTIPLY": "*",
"DIVIDE": "/",
"LESS_THAN": "<",
"MOD": "%",
"ASSIGN_ADD": "+=",
"ASSIGN_SUB": "-=",
"ASSIGN_MUL": "*=",
"ASSIGN_DIV": "/=",
"ASSIGN_MOD": "%=",
"LESS_THAN": "<",
"GREATER_THAN": ">",
"LESS_EQUAL": "<=",
"GREATER_EQUAL": ">=",
Expand Down
2 changes: 2 additions & 0 deletions crosstl/src/translator/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ def parse_assignment_or_function_call(self, update_condition=False):
"ASSIGN_SUB",
"ASSIGN_MUL",
"ASSIGN_DIV",
"ASSIGN_MOD",
"LESS_THAN",
"GREATER_THAN",
"LESS_EQUAL",
Expand Down Expand Up @@ -950,6 +951,7 @@ def parse_expression(self):
"MULTIPLY",
"DIVIDE",
"EQUALS",
"MOD",
"ASSIGN_ADD",
"ASSIGN_SUB",
"ASSIGN_MUL",
Expand Down
3 changes: 3 additions & 0 deletions examples/PerlinNoise.cgl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ shader PerlinNoise {
float height = noise * 10.0;
vec3 color = vec3(height / 10.0, 1.0 - height / 10.0, 0.0);
fragColor = vec4(color, 1.0);

int color2 = 1200 % 10; //MOD test
color2 %= 10; //ASSIGN_MOD test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a demo shader file do not change anything here . write tests only at tests/test_translator/test_codegen/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! I won't make any changes to the demo shader file.
Thanks for the clarification.

}
}
}