if else if else if if else if else
This commit is contained in:
18
test/codegen/nested_if.golden
Normal file
18
test/codegen/nested_if.golden
Normal file
@@ -0,0 +1,18 @@
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
if (pos.x > 100)
|
||||
{
|
||||
if (pos.x > 50)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return float4(1.0f);
|
||||
}
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
|
||||
return float4(0.0f);
|
||||
}
|
||||
|
||||
17
test/codegen/simple_else_if.golden
Normal file
17
test/codegen/simple_else_if.golden
Normal file
@@ -0,0 +1,17 @@
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
if (pos.x > 100)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
else if (pos.x > 50)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return float4(1.0f);
|
||||
}
|
||||
return float4(0.0f);
|
||||
}
|
||||
|
||||
10
test/codegen/simple_if.golden
Normal file
10
test/codegen/simple_if.golden
Normal file
@@ -0,0 +1,10 @@
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
if (0 > 100)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
|
||||
return float4(0.0f);
|
||||
}
|
||||
|
||||
13
test/codegen/simple_if_else.golden
Normal file
13
test/codegen/simple_if_else.golden
Normal file
@@ -0,0 +1,13 @@
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
if (0 > 100)
|
||||
{
|
||||
return float4(pos, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return float4(1.0f);
|
||||
}
|
||||
return float4(0.0f);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ test/inferred_types.ink codegen
|
||||
test/meta_block.ink codegen
|
||||
test/multiple_functions.ink codegen
|
||||
test/multiple_semicolons_everywhere.ink codegen
|
||||
test/nested_if.ink codegen
|
||||
test/pass_and_access_struct_fields_in_functions.ink codegen
|
||||
test/passthrough.ink codegen
|
||||
test/property_rename.ink codegen
|
||||
|
||||
64
test/lex/nested_if.golden
Normal file
64
test/lex/nested_if.golden
Normal file
@@ -0,0 +1,64 @@
|
||||
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 3 line = 1 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 20 ; length = 1 line = 1 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 6 line = 1 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 29 ; length = 1 line = 1 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 30 ; length = 8 line = 1 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 38 ; length = 1 line = 1 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 40 ; length = 2 line = 1 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 43 ; length = 6 line = 1 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 50 ; length = 1 line = 1 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 8 line = 1 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 1 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 64 ; length = 2 line = 2 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 3 line = 2 ; column = 3 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 70 ; length = 1 line = 2 ; column = 6 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 1 line = 2 ; column = 7 ; value ='x'; }
|
||||
{kind = TOKEN_GREATER; ; index = 73 ; length = 1 line = 2 ; column = 9 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 75 ; length = 3 line = 2 ; column = 11 ; value ='100'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 79 ; length = 1 line = 2 ; column = 15 ; value ='{'; }
|
||||
{kind = TOKEN_IF; ; index = 84 ; length = 2 line = 3 ; column = 0 ; value ='if'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 87 ; length = 3 line = 3 ; column = 3 ; value ='pos'; }
|
||||
{kind = TOKEN_DOT; ; index = 90 ; length = 1 line = 3 ; column = 6 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 91 ; length = 1 line = 3 ; column = 7 ; value ='x'; }
|
||||
{kind = TOKEN_GREATER; ; index = 93 ; length = 1 line = 3 ; column = 9 ; value ='>'; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 95 ; length = 2 line = 3 ; column = 11 ; value ='50'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 98 ; length = 1 line = 3 ; column = 14 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 104 ; length = 6 line = 4 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 111 ; length = 6 line = 4 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 117 ; length = 1 line = 4 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 118 ; length = 3 line = 4 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 121 ; length = 1 line = 4 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 123 ; length = 3 line = 4 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 126 ; length = 1 line = 4 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 127 ; length = 1 line = 4 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 132 ; length = 1 line = 5 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_ELSE; ; index = 134 ; length = 4 line = 5 ; column = 2 ; value ='else'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 139 ; length = 1 line = 5 ; column = 7 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 145 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 152 ; length = 6 line = 6 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 158 ; length = 1 line = 6 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 159 ; length = 3 line = 6 ; column = 14 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 162 ; length = 1 line = 6 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 163 ; length = 1 line = 6 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 168 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 173 ; length = 6 line = 8 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 180 ; length = 6 line = 8 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 186 ; length = 1 line = 8 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 187 ; length = 3 line = 8 ; column = 14 ; value ='pos'; }
|
||||
{kind = TOKEN_COMMA; ; index = 190 ; length = 1 line = 8 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 192 ; length = 3 line = 8 ; column = 19 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 195 ; length = 1 line = 8 ; column = 22 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 196 ; length = 1 line = 8 ; column = 23 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 200 ; length = 1 line = 9 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_RETURN; ; index = 205 ; length = 6 line = 10 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 212 ; length = 6 line = 10 ; column = 7 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 218 ; length = 1 line = 10 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 219 ; length = 3 line = 10 ; column = 14 ; value ='0'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 222 ; length = 1 line = 10 ; column = 17 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 223 ; length = 1 line = 10 ; column = 18 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 226 ; length = 1 line = 11 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 229 ; length = 0 line = 12 ; column = 0 ; value =''; }
|
||||
@@ -21,6 +21,7 @@ test/inferred_types.ink lex
|
||||
test/meta_block.ink lex
|
||||
test/multiple_functions.ink lex
|
||||
test/multiple_semicolons_everywhere.ink lex
|
||||
test/nested_if.ink lex
|
||||
test/non_bool_cond.ink lex
|
||||
test/pass_and_access_struct_fields_in_functions.ink lex
|
||||
test/passthrough.ink lex
|
||||
|
||||
11
test/nested_if.ink
Normal file
11
test/nested_if.ink
Normal file
@@ -0,0 +1,11 @@
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
if pos.x > 100 {
|
||||
if pos.x > 50 {
|
||||
return float4(pos, 1.0);
|
||||
} else {
|
||||
return float4(1.0);
|
||||
}
|
||||
return float4(pos, 1.0);
|
||||
}
|
||||
return float4(0.0);
|
||||
}
|
||||
9
test/parse/nested_if.golden
Normal file
9
test/parse/nested_if.golden
Normal file
@@ -0,0 +1,9 @@
|
||||
(program
|
||||
(fun vertex vs_main -> float4 (@position)
|
||||
[(:= pos float3 (@position))]
|
||||
(if (> pos.x 100)
|
||||
(if (> pos.x 50)
|
||||
(return (float4 pos 1))
|
||||
(return (float4 1)))
|
||||
(return (float4 pos 1)))
|
||||
(return (float4 0))))
|
||||
@@ -21,6 +21,7 @@ test/inferred_types.ink parse
|
||||
test/meta_block.ink parse
|
||||
test/multiple_functions.ink parse
|
||||
test/multiple_semicolons_everywhere.ink parse
|
||||
test/nested_if.ink parse
|
||||
test/non_bool_cond.ink parse
|
||||
test/pass_and_access_struct_fields_in_functions.ink parse
|
||||
test/passthrough.ink parse
|
||||
|
||||
6
test/semant/nested_if.golden
Normal file
6
test/semant/nested_if.golden
Normal file
@@ -0,0 +1,6 @@
|
||||
scope (global) [
|
||||
[vertex__vs_main] : (pos : float3) -> float4
|
||||
scope (vertex__vs_main) [
|
||||
[pos] : float3
|
||||
]
|
||||
]
|
||||
@@ -16,6 +16,7 @@ test/if_cond_assign.ink semant
|
||||
test/inferred_types.ink semant
|
||||
test/multiple_functions.ink semant
|
||||
test/multiple_semicolons_everywhere.ink semant
|
||||
test/nested_if.ink semant
|
||||
test/non_bool_cond.ink semant
|
||||
test/pass_and_access_struct_fields_in_functions.ink semant
|
||||
test/passthrough.ink semant
|
||||
|
||||
Reference in New Issue
Block a user