Adding validation code for OpAccessChain.
authorEhsan Nasiri <ehsann@google.com>
Wed, 30 Nov 2016 18:29:12 +0000 (13:29 -0500)
committerDavid Neto <dneto@google.com>
Fri, 2 Dec 2016 18:50:41 +0000 (13:50 -0500)
commitbab1aad8563d30ebd90a5a5d8cea10c0158e1825
treef9dfbaf7abb278b6dc88efbc74a3e8f5ce466443
parente6e7bd7d301d0ccbeeeb6a4f7cbe53d76552df1e
Adding validation code for OpAccessChain.

* Result Type must be an OpTypePointer. Its Type operand must be the
type reached by walking the Base’s type hierarchy down to the last
provided index in Indexes, and its Storage Class operand must be the
same as the Storage Class of Base.

* Base must be a pointer, pointing to the base of a composite object.

* Indexes walk the type hierarchy to the desired depth, potentially down
to scalar granularity. The first index in Indexes will select the
top-level member/element/component/element of the base composite. All
composite constituents use zero-based numbering, as described by their
OpType... instruction. The second index will apply similarly to that
result, and so on. Once any non-composite type is reached, there must
be no remaining (unused) indexes. Each of the Indexes must:
- be a scalar integer type,
- be an OpConstant when indexing into a structure.

* Check for the case where no indexes are passed to OpAccessChain.

Minor improvements based on code review.
source/validate_id.cpp
test/val/val_id_test.cpp