zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DependencyGraph.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2012 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 #pragma warning(disable: 4718)
8 
11 
13 {
14  TDependencyGraphBuilder::build(intermNode, this);
15 }
16 
18 {
19  for (TGraphNodeVector::const_iterator iter = mAllNodes.begin(); iter != mAllNodes.end(); ++iter)
20  {
21  TGraphNode* node = *iter;
22  delete node;
23  }
24 }
25 
27  int argumentNumber)
28 {
29  TGraphArgument* argument = new TGraphArgument(intermFunctionCall, argumentNumber);
30  mAllNodes.push_back(argument);
31  return argument;
32 }
33 
35 {
36  TGraphFunctionCall* functionCall = new TGraphFunctionCall(intermFunctionCall);
37  mAllNodes.push_back(functionCall);
38  if (functionCall->getIntermFunctionCall()->isUserDefined())
39  mUserDefinedFunctionCalls.push_back(functionCall);
40  return functionCall;
41 }
42 
44 {
45  TSymbolIdMap::const_iterator iter = mSymbolIdMap.find(intermSymbol->getId());
46 
47  TGraphSymbol* symbol = NULL;
48 
49  if (iter != mSymbolIdMap.end()) {
50  TSymbolIdPair pair = *iter;
51  symbol = pair.second;
52  } else {
53  symbol = new TGraphSymbol(intermSymbol);
54  mAllNodes.push_back(symbol);
55 
56  TSymbolIdPair pair(intermSymbol->getId(), symbol);
57  mSymbolIdMap.insert(pair);
58 
59  // We save all sampler symbols in a collection, so we can start graph traversals from them quickly.
60  if (IsSampler(intermSymbol->getBasicType()))
61  mSamplerSymbols.push_back(symbol);
62  }
63 
64  return symbol;
65 }
66 
68 {
69  TGraphSelection* selection = new TGraphSelection(intermSelection);
70  mAllNodes.push_back(selection);
71  return selection;
72 }
73 
75 {
76  TGraphLoop* loop = new TGraphLoop(intermLoop);
77  mAllNodes.push_back(loop);
78  return loop;
79 }
80 
82 {
83  TGraphLogicalOp* logicalOp = new TGraphLogicalOp(intermLogicalOp);
84  mAllNodes.push_back(logicalOp);
85  return logicalOp;
86 }
87 
88 const char* TGraphLogicalOp::getOpString() const
89 {
90  const char* opString = NULL;
91  switch (getIntermLogicalOp()->getOp()) {
92  case EOpLogicalAnd: opString = "and"; break;
93  case EOpLogicalOr: opString = "or"; break;
94  default: opString = "unknown"; break;
95  }
96  return opString;
97 }
bool isUserDefined() const
Definition: intermediate.h:475
int getId() const
Definition: intermediate.h:348
#define NULL
Definition: ftobjs.h:61
bool IsSampler(TBasicType type)
Definition: BaseTypes.h:70
TBasicType getBasicType() const
Definition: intermediate.h:254
TGraphSymbol * getOrCreateSymbol(TIntermSymbol *intermSymbol)
TGraphArgument * createArgument(TIntermAggregate *intermFunctionCall, int argumentNumber)
TDependencyGraph(TIntermNode *intermNode)
TGraphLoop * createLoop(TIntermLoop *intermLoop)
const TIntermBinary * getIntermLogicalOp() const
TGraphFunctionCall * createFunctionCall(TIntermAggregate *intermFunctionCall)
const TIntermAggregate * getIntermFunctionCall() const
TGraphSelection * createSelection(TIntermSelection *intermSelection)
static void build(TIntermNode *node, TDependencyGraph *graph)
const char * getOpString() const
TGraphLogicalOp * createLogicalOp(TIntermBinary *intermLogicalOp)