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(GlobalPoolAllocator)
26 :
27 0 : TIntermediate(TInfoSink& i) : infoSink(i) { }
28 : TIntermSymbol* addSymbol(int Id, const TString&, const TType&, TSourceLoc);
29 : TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
30 : TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TSymbolTable&);
31 : TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
32 : TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
33 : TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, TSourceLoc, TSymbolTable&);
34 : TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc);
35 : TIntermAggregate* makeAggregate(TIntermNode* node, TSourceLoc);
36 : TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);
37 : TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
38 : TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
39 : TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
40 : TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, TSourceLoc);
41 : TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
42 : bool parseConstTree(TSourceLoc, TIntermNode*, ConstantUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
43 : TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, TSourceLoc);
44 : TIntermBranch* addBranch(TOperator, TSourceLoc);
45 : TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
46 : TIntermTyped* addSwizzle(TVectorFields&, TSourceLoc);
47 : bool postProcess(TIntermNode*);
48 : void remove(TIntermNode*);
49 : void outputTree(TIntermNode*);
50 :
51 : protected:
52 : TInfoSink& infoSink;
53 :
54 : private:
55 : void operator=(TIntermediate&); // prevent assignments
56 : };
57 :
58 : #endif // _LOCAL_INTERMEDIATE_INCLUDED_
|