1a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block//
2a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Use of this source code is governed by a BSD-style license that can be
4a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// found in the LICENSE file.
5a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block//
6ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch// UnfoldSelect is an AST traverser to output the select operator ?: as if-else statements
7ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch//
8a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
9a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#ifndef COMPILER_UNFOLDSELECT_H_
10a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#define COMPILER_UNFOLDSELECT_H_
11a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
12a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include "compiler/intermediate.h"
13a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include "compiler/ParseHelper.h"
14a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
15a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocknamespace sh
16a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{
17a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass OutputHLSL;
18a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
19a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass UnfoldSelect : public TIntermTraverser
20a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{
21a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block  public:
22a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block    UnfoldSelect(TParseContext &context, OutputHLSL *outputHLSL);
23a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
24a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block    void traverse(TIntermNode *node);
25a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block    bool visitSelection(Visit visit, TIntermSelection *node);
26a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
27a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block    int getTemporaryIndex();
28a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
29a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block  protected:
30a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block    TParseContext &mContext;
31a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block    OutputHLSL *const mOutputHLSL;
32a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
33a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block    int mTemporaryIndex;
34a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block};
35a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block}
36a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block
37a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#endif   // COMPILER_UNFOLDSELECT_H_
38