More fixes to access and buffer compilation.
This commit is contained in:
4
test/arithmetic_parens.ink
Normal file
4
test/arithmetic_parens.ink
Normal file
@@ -0,0 +1,4 @@
|
||||
vertex main :: () {
|
||||
v : float2;
|
||||
v.x = (2.0 + ((4.0 - 2.0) * 1.5)) * 3.0;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
vertex main :: () -> float4 @position {
|
||||
arr : [16].float4;
|
||||
// arr[0] = float4(1,1,1);
|
||||
return arr[0];
|
||||
arr[0] = float4(1, 1, 1, 1);
|
||||
pos := arr[1];
|
||||
return pos;
|
||||
}
|
||||
|
||||
5
test/assign_temporary.ink
Normal file
5
test/assign_temporary.ink
Normal file
@@ -0,0 +1,5 @@
|
||||
vertex main :: () {
|
||||
a : float2;
|
||||
b : float2;
|
||||
(a + b).x = 2.0;
|
||||
}
|
||||
10
test/bad_double_access.ink
Normal file
10
test/bad_double_access.ink
Normal file
@@ -0,0 +1,10 @@
|
||||
P :: struct {
|
||||
v : float2;
|
||||
}
|
||||
|
||||
vertex main :: () {
|
||||
p : P;
|
||||
p.v.x.y = 2.0;
|
||||
// v : float2;
|
||||
// v.x.y.z = 2.0;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ property_buffer :: buffer {
|
||||
color : float4;
|
||||
}
|
||||
|
||||
cbuffer :: constant_buffer {
|
||||
const_buffer :: constant_buffer {
|
||||
color : float4;
|
||||
}
|
||||
|
||||
|
||||
6
test/check/arithmetic_parens.golden
Normal file
6
test/check/arithmetic_parens.golden
Normal file
@@ -0,0 +1,6 @@
|
||||
scope (global) [
|
||||
[vertex__vs_main] : ()
|
||||
scope (vertex__vs_main) [
|
||||
[v] : float2
|
||||
]
|
||||
]
|
||||
7
test/check/arrays.golden
Normal file
7
test/check/arrays.golden
Normal file
@@ -0,0 +1,7 @@
|
||||
scope (global) [
|
||||
[vertex__vs_main] : () -> float4
|
||||
scope (vertex__vs_main) [
|
||||
[pos] : float4
|
||||
[arr] : [16].float4
|
||||
]
|
||||
]
|
||||
6
test/check/bad_double_access.golden
Normal file
6
test/check/bad_double_access.golden
Normal file
@@ -0,0 +1,6 @@
|
||||
[1;37mtest/bad_double_access.ink:7,4: [31merror: [37mAttempting to access a field on a primitive type 'float'.
|
||||
[96mp.v.x.
|
||||
^
|
||||
declaration:
|
||||
x: float
|
||||
[36m[37m
|
||||
10
test/check/double_access.golden
Normal file
10
test/check/double_access.golden
Normal file
@@ -0,0 +1,10 @@
|
||||
scope (global) [
|
||||
[vertex__vs_main] : ()
|
||||
[p] : {v : float2}
|
||||
scope (p) [
|
||||
[v] : float2
|
||||
]
|
||||
scope (vertex__vs_main) [
|
||||
[x] : float
|
||||
]
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
[1;37mtest/struct_access_primitive_type.ink:3,0: [31merror: [37mAttempting to access a field on a primitive type 'int'.
|
||||
[96mx.d = 4;
|
||||
^
|
||||
^
|
||||
declaration:
|
||||
x : int = 5
|
||||
[36m[37m
|
||||
@@ -1,8 +1,11 @@
|
||||
test/assign_arithmetic_expression.ink check
|
||||
test/arithmetic_parens.ink check
|
||||
test/basic_property_and_return_value.ink check
|
||||
test/builtin_types.ink check
|
||||
test/complicated_computation.ink check
|
||||
test/constant_buffer.ink check
|
||||
test/bad_double_access.ink check
|
||||
test/double_access.ink check
|
||||
test/empty_struct.ink check
|
||||
test/empty_vertex_main.ink check
|
||||
test/empty_vertex_main_with_position_parameter.ink check
|
||||
|
||||
6
test/codegen/arithmetic_parens.golden
Normal file
6
test/codegen/arithmetic_parens.golden
Normal file
@@ -0,0 +1,6 @@
|
||||
void vs_main()
|
||||
{
|
||||
float2 v;
|
||||
v.x = (2.0f + ((4.0f - 2.0f) * 1.5f)) * 3.0f;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
void vs_main()
|
||||
{
|
||||
float x = (2.0f + 5.0f);
|
||||
float x = 2.0f + 5.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ void vs_main()
|
||||
v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
|
||||
v2.x = 2.0f;
|
||||
v2.y = 2.0f;
|
||||
float p = (v2.x + v3.z);
|
||||
float q = (v4.w + v2.x);
|
||||
float p = v2.x + v3.z;
|
||||
float q = v4.w + v2.x;
|
||||
float4x4 m;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@ void vs_main()
|
||||
{
|
||||
float x = 5.0f;
|
||||
float y = 3000.0f;
|
||||
float z = ((y * y) + x);
|
||||
float z = (y * y) + x;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ int foo()
|
||||
|
||||
float bar()
|
||||
{
|
||||
return (1235.0f * 500);
|
||||
return 1235.0f * 500;
|
||||
}
|
||||
|
||||
void vs_main()
|
||||
|
||||
@@ -7,7 +7,7 @@ struct Foo
|
||||
|
||||
float foo(Foo f)
|
||||
{
|
||||
return (f.some_data * 2.0f);
|
||||
return f.some_data * 2.0f;
|
||||
}
|
||||
|
||||
void vs_main()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
test/assign_arithmetic_expression.ink codegen
|
||||
test/arithmetic_parens.ink codegen
|
||||
test/basic_property_and_return_value.ink codegen
|
||||
test/builtin_types.ink codegen
|
||||
test/complicated_computation.ink codegen
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
test/assign_arithmetic_expression.ink compile
|
||||
test/arithmetic_parens.ink compile
|
||||
test/basic_property_and_return_value.ink compile
|
||||
test/builtin_types.ink compile
|
||||
test/complicated_computation.ink compile
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
p :: properties {
|
||||
p :: constant_buffer {
|
||||
v : float2;
|
||||
}
|
||||
|
||||
|
||||
32
test/lex/arithmetic_parens.golden
Normal file
32
test/lex/arithmetic_parens.golden
Normal file
@@ -0,0 +1,32 @@
|
||||
{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_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 1 line = 2 ; column = 0 ; value ='v'; }
|
||||
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 26 ; length = 6 line = 2 ; column = 4 ; value ='float2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 32 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 1 line = 3 ; column = 0 ; value ='v'; }
|
||||
{kind = TOKEN_DOT; ; index = 37 ; length = 1 line = 3 ; column = 1 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 38 ; length = 1 line = 3 ; column = 2 ; value ='x'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 40 ; length = 1 line = 3 ; column = 4 ; value ='='; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 42 ; length = 1 line = 3 ; column = 6 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 43 ; length = 3 line = 3 ; column = 7 ; value ='2'; }
|
||||
{kind = TOKEN_PLUS; ; index = 47 ; length = 1 line = 3 ; column = 11 ; value ='+'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 49 ; length = 1 line = 3 ; column = 13 ; value ='('; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 50 ; length = 1 line = 3 ; column = 14 ; value ='('; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 51 ; length = 3 line = 3 ; column = 15 ; value ='4'; }
|
||||
{kind = TOKEN_MINUS; ; index = 55 ; length = 1 line = 3 ; column = 19 ; value ='-'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 57 ; length = 3 line = 3 ; column = 21 ; value ='2'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 60 ; length = 1 line = 3 ; column = 24 ; value =')'; }
|
||||
{kind = TOKEN_STAR; ; index = 62 ; length = 1 line = 3 ; column = 26 ; value ='*'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 64 ; length = 3 line = 3 ; column = 28 ; value ='1.5'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 67 ; length = 1 line = 3 ; column = 31 ; value =')'; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 68 ; length = 1 line = 3 ; column = 32 ; value =')'; }
|
||||
{kind = TOKEN_STAR; ; index = 70 ; length = 1 line = 3 ; column = 34 ; value ='*'; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 72 ; length = 3 line = 3 ; column = 36 ; value ='3'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 75 ; length = 1 line = 3 ; column = 39 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 78 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 81 ; length = 0 line = 5 ; column = 0 ; value =''; }
|
||||
31
test/lex/bad_double_access.golden
Normal file
31
test/lex/bad_double_access.golden
Normal file
@@ -0,0 +1,31 @@
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 1 line = 1 ; column = 0 ; value ='P'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 2 ; length = 2 line = 1 ; column = 2 ; value ='::'; }
|
||||
{kind = TOKEN_STRUCT; ; index = 5 ; length = 6 line = 1 ; column = 5 ; value ='struct'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 12 ; length = 1 line = 1 ; column = 12 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 16 ; length = 1 line = 2 ; column = 0 ; value ='v'; }
|
||||
{kind = TOKEN_COLON; ; index = 18 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 20 ; length = 6 line = 2 ; column = 4 ; value ='float2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 26 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 29 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 34 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 41 ; length = 4 line = 5 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 46 ; length = 2 line = 5 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 49 ; length = 1 line = 5 ; column = 15 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 50 ; length = 1 line = 5 ; column = 16 ; value =')'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 52 ; length = 1 line = 5 ; column = 18 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 56 ; length = 1 line = 6 ; column = 0 ; value ='p'; }
|
||||
{kind = TOKEN_COLON; ; index = 58 ; length = 1 line = 6 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 60 ; length = 1 line = 6 ; column = 4 ; value ='P'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 61 ; length = 1 line = 6 ; column = 5 ; value =';'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 65 ; length = 1 line = 7 ; column = 0 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 66 ; length = 1 line = 7 ; column = 1 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 67 ; length = 1 line = 7 ; column = 2 ; value ='v'; }
|
||||
{kind = TOKEN_DOT; ; index = 68 ; length = 1 line = 7 ; column = 3 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 69 ; length = 1 line = 7 ; column = 4 ; value ='x'; }
|
||||
{kind = TOKEN_DOT; ; index = 70 ; length = 1 line = 7 ; column = 5 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 71 ; length = 1 line = 7 ; column = 6 ; value ='y'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 73 ; length = 1 line = 7 ; column = 8 ; value ='='; }
|
||||
{kind = TOKEN_FLOATLITERAL; ; index = 75 ; length = 3 line = 7 ; column = 10 ; value ='2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 78 ; length = 1 line = 7 ; column = 13 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 118 ; length = 1 line = 10 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 121 ; length = 0 line = 11 ; column = 0 ; value =''; }
|
||||
33
test/lex/double_access.golden
Normal file
33
test/lex/double_access.golden
Normal file
@@ -0,0 +1,33 @@
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 1 line = 1 ; column = 0 ; value ='p'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 2 ; length = 2 line = 1 ; column = 2 ; value ='::'; }
|
||||
{kind = TOKEN_CONSTANT_BUFFER; ; index = 5 ; length = 15 line = 1 ; column = 5 ; value ='constant_buffer'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 21 ; length = 1 line = 1 ; column = 21 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 25 ; length = 1 line = 2 ; column = 0 ; value ='v'; }
|
||||
{kind = TOKEN_COLON; ; index = 27 ; length = 1 line = 2 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 29 ; length = 6 line = 2 ; column = 4 ; value ='float2'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 35 ; length = 1 line = 2 ; column = 10 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 38 ; length = 1 line = 3 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_VERTEX; ; index = 43 ; length = 6 line = 5 ; column = 0 ; value ='vertex'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 50 ; length = 4 line = 5 ; column = 7 ; value ='main'; }
|
||||
{kind = TOKEN_DOUBLECOLON; ; index = 55 ; length = 2 line = 5 ; column = 12 ; value ='::'; }
|
||||
{kind = TOKEN_LEFTPAREN; ; index = 57 ; length = 1 line = 5 ; column = 14 ; value ='('; }
|
||||
{kind = TOKEN_RIGHTPAREN; ; index = 58 ; length = 1 line = 5 ; column = 15 ; value =')'; }
|
||||
{kind = TOKEN_LEFTBRACE; ; index = 60 ; length = 1 line = 5 ; column = 17 ; value ='{'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 64 ; length = 1 line = 6 ; column = 0 ; value ='x'; }
|
||||
{kind = TOKEN_COLON; ; index = 66 ; length = 1 line = 6 ; column = 2 ; value =':'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 68 ; length = 5 line = 6 ; column = 4 ; value ='float'; }
|
||||
{kind = TOKEN_ASSIGN; ; index = 74 ; length = 1 line = 6 ; column = 10 ; value ='='; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 76 ; length = 1 line = 6 ; column = 12 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 77 ; length = 1 line = 6 ; column = 13 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 78 ; length = 1 line = 6 ; column = 14 ; value ='v'; }
|
||||
{kind = TOKEN_DOT; ; index = 79 ; length = 1 line = 6 ; column = 15 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 80 ; length = 1 line = 6 ; column = 16 ; value ='x'; }
|
||||
{kind = TOKEN_SLASH; ; index = 82 ; length = 1 line = 6 ; column = 18 ; value ='/'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 84 ; length = 1 line = 6 ; column = 20 ; value ='p'; }
|
||||
{kind = TOKEN_DOT; ; index = 85 ; length = 1 line = 6 ; column = 21 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 86 ; length = 1 line = 6 ; column = 22 ; value ='v'; }
|
||||
{kind = TOKEN_DOT; ; index = 87 ; length = 1 line = 6 ; column = 23 ; value ='.'; }
|
||||
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 1 line = 6 ; column = 24 ; value ='y'; }
|
||||
{kind = TOKEN_SEMICOLON; ; index = 89 ; length = 1 line = 6 ; column = 25 ; value =';'; }
|
||||
{kind = TOKEN_RIGHTBRACE; ; index = 92 ; length = 1 line = 7 ; column = 0 ; value ='}'; }
|
||||
{kind = TOKEN_EOF; ; index = 95 ; length = 0 line = 8 ; column = 0 ; value =''; }
|
||||
@@ -1,8 +1,11 @@
|
||||
test/assign_arithmetic_expression.ink lex
|
||||
test/arithmetic_parens.ink lex
|
||||
test/bad_double_access.ink lex
|
||||
test/basic_property_and_return_value.ink lex
|
||||
test/builtin_types.ink lex
|
||||
test/complicated_computation.ink lex
|
||||
test/constant_buffer.ink lex
|
||||
test/double_access.ink lex
|
||||
test/else_if_after_else.ink lex
|
||||
test/empty_struct.ink lex
|
||||
test/empty_vertex_main.ink lex
|
||||
|
||||
5
test/parse/arithmetic_parens.golden
Normal file
5
test/parse/arithmetic_parens.golden
Normal file
@@ -0,0 +1,5 @@
|
||||
(program
|
||||
(fun vertex vs_main
|
||||
[]
|
||||
(:= v float2)
|
||||
(= v.x (* (+ 2 (* (- 4 2) 1.5)) 3))))
|
||||
8
test/parse/bad_double_access.golden
Normal file
8
test/parse/bad_double_access.golden
Normal file
@@ -0,0 +1,8 @@
|
||||
(program
|
||||
(struct P
|
||||
[(:= v float2)])
|
||||
|
||||
(fun vertex vs_main
|
||||
[]
|
||||
(:= p P)
|
||||
(= p.v.x.y 2)))
|
||||
10
test/parse/buffers.golden
Normal file
10
test/parse/buffers.golden
Normal file
@@ -0,0 +1,10 @@
|
||||
(program
|
||||
(buffer property_buffer
|
||||
[(:= color float4)])
|
||||
|
||||
(constant_buffer cbuffer
|
||||
[(:= color float4)])
|
||||
|
||||
(fun pixel ps_main
|
||||
[(:= index int)]
|
||||
(return property_buffer[index].color)))
|
||||
7
test/parse/double_access.golden
Normal file
7
test/parse/double_access.golden
Normal file
@@ -0,0 +1,7 @@
|
||||
(program
|
||||
(constant_buffer p
|
||||
[(:= v float2)])
|
||||
|
||||
(fun vertex vs_main
|
||||
[]
|
||||
(:= x float (/ p.v.x p.v.y))))
|
||||
@@ -1,8 +1,11 @@
|
||||
test/assign_arithmetic_expression.ink parse
|
||||
test/arithmetic_parens.ink parse
|
||||
test/bad_double_access.ink parse
|
||||
test/basic_property_and_return_value.ink parse
|
||||
test/builtin_types.ink parse
|
||||
test/complicated_computation.ink parse
|
||||
test/constant_buffer.ink parse
|
||||
test/double_access.ink parse
|
||||
test/else_if_after_else.ink parse
|
||||
test/empty_struct.ink parse
|
||||
test/empty_vertex_main.ink parse
|
||||
|
||||
Reference in New Issue
Block a user