Repository: CrossGL/crosstl

Issue:
SHIFT_RIGHT : >>

Discussion:
@anshikavashistha: @samthakur587 Please assign me @amMistic: @anshikavashistha if you don't mind, I'd like to work on this one?

@amMistic: @NripeshN could you assign this to me?  @NripeshN: Hi @amMistic @anshikavashistha 

Feel free to starting working on this issue and create a PR(even if not completely completed) and mention in the description that is closes the issues related to the PR(eg. Closes #xyz #abc ...)@amMistic: Hi @NripeshN, @anshikavashistha,

I'm having trouble creating test cases for this issue, as I'm not familiar with the process. Could you please provide guidance or point me in the right direction so I can learn and contribute effectively? 


Solution patch:
diff --git a/crosstl/src/backend/DirectX/DirectxLexer.py b/crosstl/src/backend/DirectX/DirectxLexer.py
index b8a23b25..a2c6084f 100644
--- a/crosstl/src/backend/DirectX/DirectxLexer.py
+++ b/crosstl/src/backend/DirectX/DirectxLexer.py
@@ -35,6 +35,7 @@
     ("COLON", r":"),
     ("QUESTION", r"\?"),
     ("SHIFT_LEFT", r"<<"),
+    ("SHIFT_RIGHT", r">>"),
     ("LESS_EQUAL", r"<="),
     ("GREATER_EQUAL", r">="),
     ("LESS_THAN", r"<"),
diff --git a/crosstl/src/backend/DirectX/DirectxParser.py b/crosstl/src/backend/DirectX/DirectxParser.py
index 201a4103..c3cd409d 100644
--- a/crosstl/src/backend/DirectX/DirectxParser.py
+++ b/crosstl/src/backend/DirectX/DirectxParser.py
@@ -239,6 +239,7 @@ def parse_variable_declaration_or_assignment(self):
                     "ASSIGN_OR",
                     "ASSIGN_AND",
                     "SHIFT_LEFT",
+                    "SHIFT_RIGHT",
                     "BITWISE_OR",
                     "BITWISE_XOR",
                 ]:
@@ -259,6 +260,7 @@ def parse_variable_declaration_or_assignment(self):
                 "ASSIGN_OR",
                 "ASSIGN_AND",
                 "SHIFT_LEFT",
+                "SHIFT_RIGHT",
                 "BITWISE_OR",
                 "BITWISE_XOR",
             ]:
@@ -282,6 +284,7 @@ def parse_variable_declaration_or_assignment(self):
                     "ASSIGN_OR",
                     "ASSIGN_AND",
                     "SHIFT_LEFT",
+                    "SHIFT_RIGHT",
                     "BITWISE_OR",
                     "BITWISE_XOR",
                 ]:
@@ -413,6 +416,7 @@ def parse_assignment(self):
             "ASSIGN_OR",
             "ASSIGN_AND",
             "SHIFT_LEFT",
+            "SHIFT_RIGHT",
             "BITWISE_OR",
             "BITWISE_XOR",
         ]:
@@ -454,6 +458,7 @@ def parse_relational(self):
         while self.current_token[0] in [
             "LESS_THAN",
             "SHIFT_LEFT",
+            "SHIFT_RIGHT",
             "GREATER_THAN",
             "LESS_EQUAL",
             "GREATER_EQUAL",


Test patch:
diff --git a/tests/test_backend/test_directx/test_codegen.py b/tests/test_backend/test_directx/test_codegen.py
index 59294a9e..07ae81b6 100644
--- a/tests/test_backend/test_directx/test_codegen.py
+++ b/tests/test_backend/test_directx/test_codegen.py
@@ -437,7 +437,19 @@ def test_assignment_ops_codegen():
             output.redValue << 1; // Shift left by 1
             output.redValue &= 0x3;
         }
+        
+        // Testing SHIFT_RIGHT (>>) operator on some condition
+        if (input.in_position.r == 0.25) {
+            uint redValue = asuint(output.out_color.r);
+            output.redValue ^= 0x1;
+            output.out_color.r = asfloat(redValue);
 
+            output.redValue |= 0x2;
+            // Applying shift left operation
+            output.redValue >> 1; // Shift left by 1
+            output.redValue &= 0x3;
+        } 
+        
         // Testing BITWISE_XOR (^) operator on some condition
         if (input.in_position.r == 0.5) {
             uint redValue = asuint(output.out_color.r);
diff --git a/tests/test_backend/test_directx/test_lexer.py b/tests/test_backend/test_directx/test_lexer.py
index 296866fb..cb5ea7fb 100644
--- a/tests/test_backend/test_directx/test_lexer.py
+++ b/tests/test_backend/test_directx/test_lexer.py
@@ -146,6 +146,20 @@ def test_assignment_ops_tokenization():
 
             redValue &= 0x3;
         }
+        
+        // Testing SHIFT RIGHT (>>) operator on some condition
+        if (input.in_position.r == 0.25) {
+            uint redValue = asuint(output.out_color.r);
+            output.redValue ^= 0x1;
+            output.out_color.r = asfloat(redValue);
+            output.redValue |= 0x2;
+
+            // Applying shift left operation
+            output.redValue >> 1; // Shift left by 1
+            redValue |= 0x2;
+
+            redValue &= 0x3;
+        }
 
 
         return output;
diff --git a/tests/test_backend/test_directx/test_parser.py b/tests/test_backend/test_directx/test_parser.py
index c4bbc89c..809a1825 100644
--- a/tests/test_backend/test_directx/test_parser.py
+++ b/tests/test_backend/test_directx/test_parser.py
@@ -201,6 +201,18 @@ def test_assignment_ops_parsing():
             output.redValue << 1; // Shift left by 1
             output.redValue &= 0x3;
         }
+        
+        // Testing SHIFT_RIGHT (>>) operator on some condition
+        if (input.in_position.r == 0.25) {
+            uint redValue = asuint(output.out_color.r);
+            output.redValue ^= 0x1;
+            output.out_color.r = asfloat(redValue);
+
+            output.redValue |= 0x2;
+            // Applying shift left operation
+            output.redValue >> 1; // Shift left by 1
+            output.redValue &= 0x3;
+        }
 
         // Testing BITWISE_XOR (^) operator on some condition
         if (input.in_position.r == 0.5) {
diff --git a/tests/test_translator/test_codegen/test_directx_codegen.py b/tests/test_translator/test_codegen/test_directx_codegen.py
index ca816a23..6779c1c7 100644
--- a/tests/test_translator/test_codegen/test_directx_codegen.py
+++ b/tests/test_translator/test_codegen/test_directx_codegen.py
@@ -596,5 +596,38 @@ def test_bitwise_and_operator():
         pytest.fail("Bitwise AND codegen not implemented")
 
 
+def test_double_data_type():
+    code = """
+    shader DoubleShader {
+        vertex {
+            input double position;
+            output double vDouble;
+
+            void main() {
+                vDouble = position * 2.0;
+                gl_Position = vec4(vDouble, 1.0);
+            }
+        }
+
+        fragment {
+            input double vDouble;
+            output vec4 fragColor;
+
+            void main() {
+                fragColor = vec4(vDouble, vDouble, vDouble, 1.0);
+            }
+        }
+    }
+    """
+    try:
+        tokens = tokenize_code(code)
+        ast = parse_code(tokens)
+        generated_code = generate_code(ast)
+        print(generated_code)
+        assert "double" in generated_code
+    except SyntaxError:
+        pytest.fail("Double data type not supported.")
+
+
 if __name__ == "__main__":
     pytest.main()