Skip to content

Commit 2da528e

Browse files
committed
Start working on HLSL initialization lists
This one is a bit gnarly because it involves a lot of depth-first traversing of declarations, types, and initialization expresssions. Questions and suggestions on how to clarify are greatly appreciated!
1 parent 6aff17f commit 2da528e

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

specs/language/declarations.tex

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,65 @@
4646

4747
\Sec{Declarators}{Decl.Decl}
4848
\Sec{Initializers}{Decl.Init}
49+
50+
\p The process of initialization described in this section applies to all
51+
initializers regardless of the context.
52+
53+
\begin{grammar}
54+
\define{initializer}\br
55+
brace-or-equal-initializer\br
56+
\terminal{(} expression-list \terminal{)}\br
57+
58+
\define{brace-or-equal-initializer}\br
59+
\terminal{=} initializer-clause\br
60+
braced-init-list\br
61+
62+
\define{initializer-clause}\br
63+
assignment-expression\br
64+
braced-init-list\br
65+
66+
\define{braced-init-list}\br
67+
\terminal{\{} initializer-list \opt{\terminal{,}} \terminal{\}}\br
68+
\terminal{\{} \terminal{\}}\br
69+
70+
\define{initializer-list}\br
71+
initializer-clause\br
72+
initializer-list \terminal{,} initializer-clause\br
73+
\end{grammar}
74+
75+
\Sub{Aggregate Initialization}{Decl.Init.Agg}
76+
77+
\p An \textit{aggregate} is a vector, matrix, array, or class.
78+
79+
\p The subobjects of an aggregate have a defined order. For vectors and arrays
80+
the order is increasing subscript order. For matrices it is increasing subscript
81+
order with the with the subscript nesting such that in the notation
82+
\texttt{Mat[M][N]}, the ordering is \(Mat[0][0]...Mat[0][N]...
83+
Mat[M][0]...Mat[M][N]\). For classes the order is base class, followed by member
84+
subobjects in declaration order.
85+
86+
\p A \textit{flattened ordering} of subobjects can be produced by performing a
87+
depth-first traversal of the subobjects of an object following the defined
88+
subobject ordering.
89+
90+
\p Each \textit{initializer-list} is comprised of zero or more
91+
\textit{initializer-clause} expressions, which in turn may be another
92+
initializer-list or an \textit{assignment-expression}. Each
93+
assignment-expression is an object, which may be a scalar or aggregate type. A
94+
\textit{flattened initializer sequence} is constructed by a depth-first
95+
traversal over each assignment-expression in an initializer-list and performing
96+
a depth-first traversal accessing each subobject of the assignment-expression.
97+
98+
\p An initializer-list is a valid initializer if for each element \(E_n\) in the
99+
target object's flattened ordering there is a corresponding initializer \(I_n\)
100+
in the flattened initializer sequence which can be implicitly converted to the
101+
element's type.
102+
103+
\p An initializer-list is invalid if the flattened initializer sequence contains
104+
less elements than the target object's flattened ordering, or if any initializer
105+
\(I_n\) cannot be implicitly converted to the corresponding element \(E_n\)'s
106+
type.
107+
49108
\Sec{Function Definitions}{Decl.Function}
50109
\Sec{Attributes}{Decl.Attr}
51110
\Sub{Semantic Annotations}{Decl.Attr.Semantic}

0 commit comments

Comments
 (0)