• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #ifndef _LOCAL_INTERMEDIATE_INCLUDED_
8 #define _LOCAL_INTERMEDIATE_INCLUDED_
9 
10 #include "GLSLANG/ShaderLang.h"
11 #include "compiler/intermediate.h"
12 #include "compiler/SymbolTable.h"
13 
14 struct TVectorFields {
15     int offsets[4];
16     int num;
17 };
18 
19 //
20 // Set of helper functions to help parse and build the tree.
21 //
22 class TInfoSink;
23 class TIntermediate {
24 public:
25     POOL_ALLOCATOR_NEW_DELETE();
TIntermediate(TInfoSink & i)26     TIntermediate(TInfoSink& i) : infoSink(i) { }
27 
28     TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&);
29     TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
30     TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&, TSymbolTable&);
31     TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
32     TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&);
33     TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, const TSourceLoc&, TSymbolTable&);
34     TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc&);
35     TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&);
36     TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, const TSourceLoc&);
37     TIntermNode*  addSelection(TIntermTyped* cond, TIntermNodePair code, const TSourceLoc&);
38     TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&);
39     TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
40     TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, const TSourceLoc&);
41     TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
42     bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
43     TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&);
44     TIntermBranch* addBranch(TOperator, const TSourceLoc&);
45     TIntermBranch* addBranch(TOperator, TIntermTyped*, const TSourceLoc&);
46     TIntermTyped* addSwizzle(TVectorFields&, const TSourceLoc&);
47     bool postProcess(TIntermNode*);
48     void remove(TIntermNode*);
49     void outputTree(TIntermNode*);
50 
51 private:
52     void operator=(TIntermediate&); // prevent assignments
53 
54     TInfoSink& infoSink;
55 };
56 
57 #endif // _LOCAL_INTERMEDIATE_INCLUDED_
58