Added inferred types and missing length function.
This commit is contained in:
24
test/codegen/inferred_types.golden
Normal file
24
test/codegen/inferred_types.golden
Normal file
@@ -0,0 +1,24 @@
|
||||
float bar();
|
||||
float foo();
|
||||
|
||||
float bar()
|
||||
{
|
||||
return 5.0f;
|
||||
}
|
||||
|
||||
float foo()
|
||||
{
|
||||
return bar();
|
||||
}
|
||||
|
||||
float4 vs_main(float3 pos : POSITION) : SV_POSITION
|
||||
{
|
||||
float f = 2.0f;
|
||||
int i = 10;
|
||||
f = foo();
|
||||
float2 v2 = float2(2, 2);
|
||||
float3 v3 = float3(2, 2, 3);
|
||||
float4 v4 = float4(4, 5, 6, 7);
|
||||
return float4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ test/field_assignment.ink codegen
|
||||
test/function_call.ink codegen
|
||||
test/function_call_out_of_order_declaration.ink codegen
|
||||
test/function_call_return.ink codegen
|
||||
test/inferred_types.ink codegen
|
||||
test/meta_block.ink codegen
|
||||
test/multiple_functions.ink codegen
|
||||
test/multiple_semicolons_everywhere.ink codegen
|
||||
|
||||
@@ -10,6 +10,7 @@ test/function_call.ink compile
|
||||
test/function_call_out_of_order_declaration.ink compile
|
||||
test/function_call_return.ink compile
|
||||
test/functions_with_same_name.ink compile
|
||||
test/inferred_types.ink compile
|
||||
test/meta_block.ink compile
|
||||
test/multiple_functions.ink compile
|
||||
test/multiple_semicolons_everywhere.ink compile
|
||||
|
||||
17
test/inferred_types.ink
Normal file
17
test/inferred_types.ink
Normal file
@@ -0,0 +1,17 @@
|
||||
bar :: () -> float {
|
||||
return 5.0;
|
||||
}
|
||||
|
||||
foo :: () -> float {
|
||||
return bar();
|
||||
}
|
||||
|
||||
vertex main :: (pos : float3 @position) -> float4 @position {
|
||||
f := 2.0;
|
||||
i := 10;
|
||||
f = foo();
|
||||
v2 := float2(2, 2);
|
||||
v3 := float3(2, 2, 3);
|
||||
v4 := float4(4, 5, 6, 7);
|
||||
return float4(1, 1, 1, 1);
|
||||
}
|
||||
105
test/lex/inferred_types.golden
Normal file
105
test/lex/inferred_types.golden
Normal file
@@ -0,0 +1,105 @@
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 3 line = 1 ; column = 0 ; value ='bar'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 4 ; length = 2 line = 1 ; column = 4 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 7 ; length = 1 line = 1 ; column = 7 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 8 ; length = 1 line = 1 ; column = 8 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 10 ; length = 2 line = 1 ; column = 10 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 13 ; length = 5 line = 1 ; column = 13 ; value ='float'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 19 ; length = 1 line = 1 ; column = 19 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 23 ; length = 6 line = 2 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 30 ; length = 3 line = 2 ; column = 7 ; value ='5'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 33 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 36 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 41 ; length = 3 line = 5 ; column = 0 ; value ='foo'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 45 ; length = 2 line = 5 ; column = 4 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 48 ; length = 1 line = 5 ; column = 7 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 49 ; length = 1 line = 5 ; column = 8 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 51 ; length = 2 line = 5 ; column = 10 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 54 ; length = 5 line = 5 ; column = 13 ; value ='float'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 5 ; column = 19 ; value ='{'; }
|
||||
{kind = TOKEN_RETURN; ; index = 64 ; length = 6 line = 6 ; column = 0 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 3 line = 6 ; column = 7 ; value ='bar'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 74 ; length = 1 line = 6 ; column = 10 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 75 ; length = 1 line = 6 ; column = 11 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 76 ; length = 1 line = 6 ; column = 12 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 79 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 84 ; length = 6 line = 9 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 91 ; length = 4 line = 9 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 96 ; length = 2 line = 9 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 99 ; length = 1 line = 9 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 100 ; length = 3 line = 9 ; column = 16 ; value ='pos'; }
|
||||
{kind = TOKEN_COLON; ; index = 104 ; length = 1 line = 9 ; column = 20 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 106 ; length = 6 line = 9 ; column = 22 ; value ='float3'; }
|
||||
{kind = TOKEN_AT; ; index = 113 ; length = 1 line = 9 ; column = 29 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 114 ; length = 8 line = 9 ; column = 30 ; value ='position'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 122 ; length = 1 line = 9 ; column = 38 ; value =')'; }
|
||||
{kind = TOKEN_ARROW; ; index = 124 ; length = 2 line = 9 ; column = 40 ; value ='->'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 127 ; length = 6 line = 9 ; column = 43 ; value ='float4'; }
|
||||
{kind = TOKEN_AT; ; index = 134 ; length = 1 line = 9 ; column = 50 ; value ='@'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 135 ; length = 8 line = 9 ; column = 51 ; value ='position'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 144 ; length = 1 line = 9 ; column = 60 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 151 ; length = 1 line = 10 ; column = 3 ; value ='f'; }
|
||||
{kind = TOKEN_COLON; ; index = 153 ; length = 1 line = 10 ; column = 5 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 154 ; length = 1 line = 10 ; column = 6 ; value ='='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 156 ; length = 3 line = 10 ; column = 8 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 159 ; length = 1 line = 10 ; column = 11 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 166 ; length = 1 line = 11 ; column = 3 ; value ='i'; }
|
||||
{kind = TOKEN_COLON; ; index = 168 ; length = 1 line = 11 ; column = 5 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 169 ; length = 1 line = 11 ; column = 6 ; value ='='; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 171 ; length = 2 line = 11 ; column = 8 ; value ='10'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 173 ; length = 1 line = 11 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 180 ; length = 1 line = 12 ; column = 3 ; value ='f'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 182 ; length = 1 line = 12 ; column = 5 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 184 ; length = 3 line = 12 ; column = 7 ; value ='foo'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 187 ; length = 1 line = 12 ; column = 10 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 188 ; length = 1 line = 12 ; column = 11 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 189 ; length = 1 line = 12 ; column = 12 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 196 ; length = 2 line = 13 ; column = 3 ; value ='v2'; }
|
||||
{kind = TOKEN_COLON; ; index = 199 ; length = 1 line = 13 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 200 ; length = 1 line = 13 ; column = 7 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 202 ; length = 6 line = 13 ; column = 9 ; value ='float2'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 208 ; length = 1 line = 13 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 209 ; length = 1 line = 13 ; column = 16 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 210 ; length = 1 line = 13 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 212 ; length = 1 line = 13 ; column = 19 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 213 ; length = 1 line = 13 ; column = 20 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 214 ; length = 1 line = 13 ; column = 21 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 221 ; length = 2 line = 14 ; column = 3 ; value ='v3'; }
|
||||
{kind = TOKEN_COLON; ; index = 224 ; length = 1 line = 14 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 225 ; length = 1 line = 14 ; column = 7 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 227 ; length = 6 line = 14 ; column = 9 ; value ='float3'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 233 ; length = 1 line = 14 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 234 ; length = 1 line = 14 ; column = 16 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 235 ; length = 1 line = 14 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 237 ; length = 1 line = 14 ; column = 19 ; value ='2'; }
|
||||
{kind = TOKEN_COMMA; ; index = 238 ; length = 1 line = 14 ; column = 20 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 240 ; length = 1 line = 14 ; column = 22 ; value ='3'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 241 ; length = 1 line = 14 ; column = 23 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 242 ; length = 1 line = 14 ; column = 24 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 249 ; length = 2 line = 15 ; column = 3 ; value ='v4'; }
|
||||
{kind = TOKEN_COLON; ; index = 252 ; length = 1 line = 15 ; column = 6 ; value =':'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 253 ; length = 1 line = 15 ; column = 7 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 255 ; length = 6 line = 15 ; column = 9 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 261 ; length = 1 line = 15 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 262 ; length = 1 line = 15 ; column = 16 ; value ='4'; }
|
||||
{kind = TOKEN_COMMA; ; index = 263 ; length = 1 line = 15 ; column = 17 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 265 ; length = 1 line = 15 ; column = 19 ; value ='5'; }
|
||||
{kind = TOKEN_COMMA; ; index = 266 ; length = 1 line = 15 ; column = 20 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 268 ; length = 1 line = 15 ; column = 22 ; value ='6'; }
|
||||
{kind = TOKEN_COMMA; ; index = 269 ; length = 1 line = 15 ; column = 23 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 271 ; length = 1 line = 15 ; column = 25 ; value ='7'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 272 ; length = 1 line = 15 ; column = 26 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 273 ; length = 1 line = 15 ; column = 27 ; value =';'; }
|
||||
{kind = TOKEN_RETURN; ; index = 280 ; length = 6 line = 16 ; column = 3 ; value ='return'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 287 ; length = 6 line = 16 ; column = 10 ; value ='float4'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 293 ; length = 1 line = 16 ; column = 16 ; value ='('; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 294 ; length = 1 line = 16 ; column = 17 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 295 ; length = 1 line = 16 ; column = 18 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 297 ; length = 1 line = 16 ; column = 20 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 298 ; length = 1 line = 16 ; column = 21 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 300 ; length = 1 line = 16 ; column = 23 ; value ='1'; }
|
||||
{kind = TOKEN_COMMA; ; index = 301 ; length = 1 line = 16 ; column = 24 ; value =','; }
|
||||
{kind = TOKEN_INTLITERAL; ; index = 303 ; length = 1 line = 16 ; column = 26 ; value ='1'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 304 ; length = 1 line = 16 ; column = 27 ; value =')'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 305 ; length = 1 line = 16 ; column = 28 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 308 ; length = 1 line = 17 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 309 ; length = 0 line = 17 ; column = 1 ; value =''; }
|
||||
@@ -13,6 +13,7 @@ test/function_call_out_of_order_declaration.ink lex
|
||||
test/function_call_return.ink lex
|
||||
test/functions_with_same_name.ink lex
|
||||
test/function_with_int_return.ink lex
|
||||
test/inferred_types.ink lex
|
||||
test/meta_block.ink lex
|
||||
test/multiple_functions.ink lex
|
||||
test/multiple_semicolons_everywhere.ink lex
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[1;37mtest/field_without_type_specifier.ink:2,0: [31merror: [37mExpected type specifier after field name.
|
||||
[96mx := 5.0;
|
||||
^
|
||||
[36m[37m
|
||||
(program
|
||||
(fun vertex vs_main
|
||||
[]
|
||||
(:= x 5)))
|
||||
18
test/parse/inferred_types.golden
Normal file
18
test/parse/inferred_types.golden
Normal file
@@ -0,0 +1,18 @@
|
||||
(program
|
||||
(fun bar -> float
|
||||
[]
|
||||
(return 5))
|
||||
|
||||
(fun foo -> float
|
||||
[]
|
||||
(return (bar)))
|
||||
|
||||
(fun vertex vs_main -> float4 (@position)
|
||||
[(:= pos float3 (@position))]
|
||||
(:= f 2)
|
||||
(:= i 10)
|
||||
(= f (foo))
|
||||
(:= v2 (float2 2 2))
|
||||
(:= v3 (float3 2 2 3))
|
||||
(:= v4 (float4 4 5 6 7))
|
||||
(return (float4 1 1 1 1))))
|
||||
@@ -13,6 +13,7 @@ test/function_call_out_of_order_declaration.ink parse
|
||||
test/function_call_return.ink parse
|
||||
test/functions_with_same_name.ink parse
|
||||
test/function_with_int_return.ink parse
|
||||
test/inferred_types.ink parse
|
||||
test/meta_block.ink parse
|
||||
test/multiple_functions.ink parse
|
||||
test/multiple_semicolons_everywhere.ink parse
|
||||
|
||||
15
test/semant/inferred_types.golden
Normal file
15
test/semant/inferred_types.golden
Normal file
@@ -0,0 +1,15 @@
|
||||
scope (global) [
|
||||
[foo] : () -> float
|
||||
[vertex__vs_main] : (pos : float3) -> float4
|
||||
[bar] : () -> float
|
||||
scope (bar) []
|
||||
scope (foo) []
|
||||
scope (vertex__vs_main) [
|
||||
[v2] : float2
|
||||
[i] : int
|
||||
[v4] : float4
|
||||
[pos] : float3
|
||||
[v3] : float3
|
||||
[f] : float
|
||||
]
|
||||
]
|
||||
@@ -11,6 +11,7 @@ test/function_call_out_of_order_declaration.ink semant
|
||||
test/function_call_return.ink semant
|
||||
test/functions_with_same_name.ink semant
|
||||
test/function_with_int_return.ink semant
|
||||
test/inferred_types.ink semant
|
||||
test/multiple_functions.ink semant
|
||||
test/multiple_semicolons_everywhere.ink semant
|
||||
test/pass_and_access_struct_fields_in_functions.ink semant
|
||||
|
||||
Reference in New Issue
Block a user