gfx/angle/src/compiler/IntermTraverse.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 //
michael@0 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
michael@0 3 // Use of this source code is governed by a BSD-style license that can be
michael@0 4 // found in the LICENSE file.
michael@0 5 //
michael@0 6
michael@0 7 #include "compiler/intermediate.h"
michael@0 8
michael@0 9 //
michael@0 10 // Traverse the intermediate representation tree, and
michael@0 11 // call a node type specific function for each node.
michael@0 12 // Done recursively through the member function Traverse().
michael@0 13 // Node types can be skipped if their function to call is 0,
michael@0 14 // but their subtree will still be traversed.
michael@0 15 // Nodes with children can have their whole subtree skipped
michael@0 16 // if preVisit is turned on and the type specific function
michael@0 17 // returns false.
michael@0 18 //
michael@0 19 // preVisit, postVisit, and rightToLeft control what order
michael@0 20 // nodes are visited in.
michael@0 21 //
michael@0 22
michael@0 23 //
michael@0 24 // Traversal functions for terminals are straighforward....
michael@0 25 //
michael@0 26 void TIntermSymbol::traverse(TIntermTraverser* it)
michael@0 27 {
michael@0 28 it->visitSymbol(this);
michael@0 29 }
michael@0 30
michael@0 31 void TIntermConstantUnion::traverse(TIntermTraverser* it)
michael@0 32 {
michael@0 33 it->visitConstantUnion(this);
michael@0 34 }
michael@0 35
michael@0 36 //
michael@0 37 // Traverse a binary node.
michael@0 38 //
michael@0 39 void TIntermBinary::traverse(TIntermTraverser* it)
michael@0 40 {
michael@0 41 bool visit = true;
michael@0 42
michael@0 43 //
michael@0 44 // visit the node before children if pre-visiting.
michael@0 45 //
michael@0 46 if(it->preVisit)
michael@0 47 {
michael@0 48 visit = it->visitBinary(PreVisit, this);
michael@0 49 }
michael@0 50
michael@0 51 //
michael@0 52 // Visit the children, in the right order.
michael@0 53 //
michael@0 54 if(visit)
michael@0 55 {
michael@0 56 it->incrementDepth();
michael@0 57
michael@0 58 if(it->rightToLeft)
michael@0 59 {
michael@0 60 if(right)
michael@0 61 {
michael@0 62 right->traverse(it);
michael@0 63 }
michael@0 64
michael@0 65 if(it->inVisit)
michael@0 66 {
michael@0 67 visit = it->visitBinary(InVisit, this);
michael@0 68 }
michael@0 69
michael@0 70 if(visit && left)
michael@0 71 {
michael@0 72 left->traverse(it);
michael@0 73 }
michael@0 74 }
michael@0 75 else
michael@0 76 {
michael@0 77 if(left)
michael@0 78 {
michael@0 79 left->traverse(it);
michael@0 80 }
michael@0 81
michael@0 82 if(it->inVisit)
michael@0 83 {
michael@0 84 visit = it->visitBinary(InVisit, this);
michael@0 85 }
michael@0 86
michael@0 87 if(visit && right)
michael@0 88 {
michael@0 89 right->traverse(it);
michael@0 90 }
michael@0 91 }
michael@0 92
michael@0 93 it->decrementDepth();
michael@0 94 }
michael@0 95
michael@0 96 //
michael@0 97 // Visit the node after the children, if requested and the traversal
michael@0 98 // hasn't been cancelled yet.
michael@0 99 //
michael@0 100 if(visit && it->postVisit)
michael@0 101 {
michael@0 102 it->visitBinary(PostVisit, this);
michael@0 103 }
michael@0 104 }
michael@0 105
michael@0 106 //
michael@0 107 // Traverse a unary node. Same comments in binary node apply here.
michael@0 108 //
michael@0 109 void TIntermUnary::traverse(TIntermTraverser* it)
michael@0 110 {
michael@0 111 bool visit = true;
michael@0 112
michael@0 113 if (it->preVisit)
michael@0 114 visit = it->visitUnary(PreVisit, this);
michael@0 115
michael@0 116 if (visit) {
michael@0 117 it->incrementDepth();
michael@0 118 operand->traverse(it);
michael@0 119 it->decrementDepth();
michael@0 120 }
michael@0 121
michael@0 122 if (visit && it->postVisit)
michael@0 123 it->visitUnary(PostVisit, this);
michael@0 124 }
michael@0 125
michael@0 126 //
michael@0 127 // Traverse an aggregate node. Same comments in binary node apply here.
michael@0 128 //
michael@0 129 void TIntermAggregate::traverse(TIntermTraverser* it)
michael@0 130 {
michael@0 131 bool visit = true;
michael@0 132
michael@0 133 if(it->preVisit)
michael@0 134 {
michael@0 135 visit = it->visitAggregate(PreVisit, this);
michael@0 136 }
michael@0 137
michael@0 138 if(visit)
michael@0 139 {
michael@0 140 it->incrementDepth();
michael@0 141
michael@0 142 if(it->rightToLeft)
michael@0 143 {
michael@0 144 for(TIntermSequence::reverse_iterator sit = sequence.rbegin(); sit != sequence.rend(); sit++)
michael@0 145 {
michael@0 146 (*sit)->traverse(it);
michael@0 147
michael@0 148 if(visit && it->inVisit)
michael@0 149 {
michael@0 150 if(*sit != sequence.front())
michael@0 151 {
michael@0 152 visit = it->visitAggregate(InVisit, this);
michael@0 153 }
michael@0 154 }
michael@0 155 }
michael@0 156 }
michael@0 157 else
michael@0 158 {
michael@0 159 for(TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
michael@0 160 {
michael@0 161 (*sit)->traverse(it);
michael@0 162
michael@0 163 if(visit && it->inVisit)
michael@0 164 {
michael@0 165 if(*sit != sequence.back())
michael@0 166 {
michael@0 167 visit = it->visitAggregate(InVisit, this);
michael@0 168 }
michael@0 169 }
michael@0 170 }
michael@0 171 }
michael@0 172
michael@0 173 it->decrementDepth();
michael@0 174 }
michael@0 175
michael@0 176 if(visit && it->postVisit)
michael@0 177 {
michael@0 178 it->visitAggregate(PostVisit, this);
michael@0 179 }
michael@0 180 }
michael@0 181
michael@0 182 //
michael@0 183 // Traverse a selection node. Same comments in binary node apply here.
michael@0 184 //
michael@0 185 void TIntermSelection::traverse(TIntermTraverser* it)
michael@0 186 {
michael@0 187 bool visit = true;
michael@0 188
michael@0 189 if (it->preVisit)
michael@0 190 visit = it->visitSelection(PreVisit, this);
michael@0 191
michael@0 192 if (visit) {
michael@0 193 it->incrementDepth();
michael@0 194 if (it->rightToLeft) {
michael@0 195 if (falseBlock)
michael@0 196 falseBlock->traverse(it);
michael@0 197 if (trueBlock)
michael@0 198 trueBlock->traverse(it);
michael@0 199 condition->traverse(it);
michael@0 200 } else {
michael@0 201 condition->traverse(it);
michael@0 202 if (trueBlock)
michael@0 203 trueBlock->traverse(it);
michael@0 204 if (falseBlock)
michael@0 205 falseBlock->traverse(it);
michael@0 206 }
michael@0 207 it->decrementDepth();
michael@0 208 }
michael@0 209
michael@0 210 if (visit && it->postVisit)
michael@0 211 it->visitSelection(PostVisit, this);
michael@0 212 }
michael@0 213
michael@0 214 //
michael@0 215 // Traverse a loop node. Same comments in binary node apply here.
michael@0 216 //
michael@0 217 void TIntermLoop::traverse(TIntermTraverser* it)
michael@0 218 {
michael@0 219 bool visit = true;
michael@0 220
michael@0 221 if(it->preVisit)
michael@0 222 {
michael@0 223 visit = it->visitLoop(PreVisit, this);
michael@0 224 }
michael@0 225
michael@0 226 if(visit)
michael@0 227 {
michael@0 228 it->incrementDepth();
michael@0 229
michael@0 230 if(it->rightToLeft)
michael@0 231 {
michael@0 232 if(expr)
michael@0 233 {
michael@0 234 expr->traverse(it);
michael@0 235 }
michael@0 236
michael@0 237 if(body)
michael@0 238 {
michael@0 239 body->traverse(it);
michael@0 240 }
michael@0 241
michael@0 242 if(cond)
michael@0 243 {
michael@0 244 cond->traverse(it);
michael@0 245 }
michael@0 246 }
michael@0 247 else
michael@0 248 {
michael@0 249 if(cond)
michael@0 250 {
michael@0 251 cond->traverse(it);
michael@0 252 }
michael@0 253
michael@0 254 if(body)
michael@0 255 {
michael@0 256 body->traverse(it);
michael@0 257 }
michael@0 258
michael@0 259 if(expr)
michael@0 260 {
michael@0 261 expr->traverse(it);
michael@0 262 }
michael@0 263 }
michael@0 264
michael@0 265 it->decrementDepth();
michael@0 266 }
michael@0 267
michael@0 268 if(visit && it->postVisit)
michael@0 269 {
michael@0 270 it->visitLoop(PostVisit, this);
michael@0 271 }
michael@0 272 }
michael@0 273
michael@0 274 //
michael@0 275 // Traverse a branch node. Same comments in binary node apply here.
michael@0 276 //
michael@0 277 void TIntermBranch::traverse(TIntermTraverser* it)
michael@0 278 {
michael@0 279 bool visit = true;
michael@0 280
michael@0 281 if (it->preVisit)
michael@0 282 visit = it->visitBranch(PreVisit, this);
michael@0 283
michael@0 284 if (visit && expression) {
michael@0 285 it->incrementDepth();
michael@0 286 expression->traverse(it);
michael@0 287 it->decrementDepth();
michael@0 288 }
michael@0 289
michael@0 290 if (visit && it->postVisit)
michael@0 291 it->visitBranch(PostVisit, this);
michael@0 292 }
michael@0 293

mercurial