LEFT | RIGHT |
1 // | 1 // |
2 // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. | 2 // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 // | 5 // |
6 | 6 |
7 #include "compiler/MapLongVariableNames.h" | 7 #include "compiler/MapLongVariableNames.h" |
8 | 8 |
9 MapLongVariableNames::MapLongVariableNames(TSymbolTable& symbolTable) | 9 namespace { |
10 : mSymbolTable(symbolTable) | 10 |
| 11 TString mapLongName(int id, const TString& name) |
11 { | 12 { |
| 13 ASSERT(name.size() > MAX_IDENTIFIER_NAME_SIZE); |
| 14 TStringStream stream; |
| 15 stream << "webgl_" << id << "_"; |
| 16 stream << name.substr(0, MAX_IDENTIFIER_NAME_SIZE - stream.str().size()); |
| 17 return stream.str(); |
12 } | 18 } |
13 | 19 |
14 // We are only interested in attribute and uniform variable declaration. | 20 } // anonymous namespace |
15 void MapLongVariableNames::visitSymbol(TIntermSymbol* symbolNode) | 21 |
| 22 void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol) |
16 { | 23 { |
17 ASSERT(symbolNode != NULL); | 24 ASSERT(symbol != NULL); |
18 if (symbolNode->getSymbol().size() > MAX_SYMBOL_NAME_SIZE) | 25 if (symbol->getSymbol().size() > MAX_IDENTIFIER_NAME_SIZE) |
19 { | 26 symbol->setSymbol(mapLongName(symbol->getId(), symbol->getSymbol())); |
20 TSymbol* symbol = mSymbolTable.find(symbolNode->getSymbol()); | |
21 if (symbol != NULL) | |
22 { | |
23 symbolNode->setSymbol(symbol->getMappedName()); | |
24 } | |
25 else // Local variables. | |
26 {·· | |
27 symbolNode->setSymbol(TSymbol::mapLongName( | |
28 symbolNode->getId(), symbolNode->getSymbol())); | |
29 } | |
30 } | |
31 } | 27 } |
32 | 28 |
33 void MapLongVariableNames::visitConstantUnion(TIntermConstantUnion*) | 29 void MapLongVariableNames::visitConstantUnion(TIntermConstantUnion*) |
34 { | 30 { |
35 } | 31 } |
36 | 32 |
37 bool MapLongVariableNames::visitBinary(Visit, TIntermBinary*) | 33 bool MapLongVariableNames::visitBinary(Visit, TIntermBinary*) |
38 { | 34 { |
39 return true; | 35 return true; |
40 } | 36 } |
(...skipping 15 matching lines...) Expand all Loading... |
56 | 52 |
57 bool MapLongVariableNames::visitLoop(Visit, TIntermLoop*) | 53 bool MapLongVariableNames::visitLoop(Visit, TIntermLoop*) |
58 { | 54 { |
59 return true; | 55 return true; |
60 } | 56 } |
61 | 57 |
62 bool MapLongVariableNames::visitBranch(Visit, TIntermBranch*) | 58 bool MapLongVariableNames::visitBranch(Visit, TIntermBranch*) |
63 { | 59 { |
64 return true; | 60 return true; |
65 } | 61 } |
LEFT | RIGHT |