OLD | NEW |
1 // | 1 // |
2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. | 2 // Copyright (c) 2002-2013 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/ParseHelper.h" | 7 #include "compiler/ParseHelper.h" |
8 | 8 |
9 #include <stdarg.h> | 9 #include <stdarg.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } | 652 } |
653 | 653 |
654 bool TParseContext::containsSampler(TType& type) | 654 bool TParseContext::containsSampler(TType& type) |
655 { | 655 { |
656 if (IsSampler(type.getBasicType())) | 656 if (IsSampler(type.getBasicType())) |
657 return true; | 657 return true; |
658 | 658 |
659 if (type.getBasicType() == EbtStruct) { | 659 if (type.getBasicType() == EbtStruct) { |
660 TTypeList& structure = *type.getStruct(); | 660 TTypeList& structure = *type.getStruct(); |
661 for (unsigned int i = 0; i < structure.size(); ++i) { | 661 for (unsigned int i = 0; i < structure.size(); ++i) { |
662 if (containsSampler(*structure[i].type)) | 662 if (containsSampler(*structure[i])) |
663 return true; | 663 return true; |
664 } | 664 } |
665 } | 665 } |
666 | 666 |
667 return false; | 667 return false; |
668 } | 668 } |
669 | 669 |
670 // | 670 // |
671 // Do size checking for an array type's size. | 671 // Do size checking for an array type's size. |
672 // | 672 // |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 } else | 1132 } else |
1133 singleArg = true; | 1133 singleArg = true; |
1134 | 1134 |
1135 TIntermTyped *newNode; | 1135 TIntermTyped *newNode; |
1136 if (singleArg) { | 1136 if (singleArg) { |
1137 // If structure constructor or array constructor is being called· | 1137 // If structure constructor or array constructor is being called· |
1138 // for only one parameter inside the structure, we need to call construc
tStruct function once. | 1138 // for only one parameter inside the structure, we need to call construc
tStruct function once. |
1139 if (type->isArray()) | 1139 if (type->isArray()) |
1140 newNode = constructStruct(node, &elementType, 1, node->getLine(), fa
lse); | 1140 newNode = constructStruct(node, &elementType, 1, node->getLine(), fa
lse); |
1141 else if (op == EOpConstructStruct) | 1141 else if (op == EOpConstructStruct) |
1142 newNode = constructStruct(node, (*memberTypes).type, 1, node->getLin
e(), false); | 1142 newNode = constructStruct(node, *memberTypes, 1, node->getLine(), fa
lse); |
1143 else | 1143 else |
1144 newNode = constructBuiltIn(type, op, node, node->getLine(), false); | 1144 newNode = constructBuiltIn(type, op, node, node->getLine(), false); |
1145 | 1145 |
1146 if (newNode && newNode->getAsAggregate()) { | 1146 if (newNode && newNode->getAsAggregate()) { |
1147 TIntermTyped* constConstructor = foldConstConstructor(newNode->getAs
Aggregate(), *type); | 1147 TIntermTyped* constConstructor = foldConstConstructor(newNode->getAs
Aggregate(), *type); |
1148 if (constConstructor) | 1148 if (constConstructor) |
1149 return constConstructor; | 1149 return constConstructor; |
1150 } | 1150 } |
1151 | 1151 |
1152 return newNode; | 1152 return newNode; |
(...skipping 10 matching lines...) Expand all Loading... |
1163 ···· | 1163 ···· |
1164 // for each parameter to the constructor call, check to see if the right typ
e is passed or convert them· | 1164 // for each parameter to the constructor call, check to see if the right typ
e is passed or convert them· |
1165 // to the right type if possible (and allowed). | 1165 // to the right type if possible (and allowed). |
1166 // for structure constructors, just check if the right type is passed, no co
nversion is allowed. | 1166 // for structure constructors, just check if the right type is passed, no co
nversion is allowed. |
1167 ···· | 1167 ···· |
1168 for (TIntermSequence::iterator p = sequenceVector.begin();· | 1168 for (TIntermSequence::iterator p = sequenceVector.begin();· |
1169 p != sequenceVector.end(); p++, paramCount++)
{ | 1169 p != sequenceVector.end(); p++, paramCount++)
{ |
1170 if (type->isArray()) | 1170 if (type->isArray()) |
1171 newNode = constructStruct(*p, &elementType, paramCount+1, node->getL
ine(), true); | 1171 newNode = constructStruct(*p, &elementType, paramCount+1, node->getL
ine(), true); |
1172 else if (op == EOpConstructStruct) | 1172 else if (op == EOpConstructStruct) |
1173 newNode = constructStruct(*p, (memberTypes[paramCount]).type, paramC
ount+1, node->getLine(), true); | 1173 newNode = constructStruct(*p, memberTypes[paramCount], paramCount+1,
node->getLine(), true); |
1174 else | 1174 else |
1175 newNode = constructBuiltIn(type, op, *p, node->getLine(), true); | 1175 newNode = constructBuiltIn(type, op, *p, node->getLine(), true); |
1176 ········ | 1176 ········ |
1177 if (newNode) { | 1177 if (newNode) { |
1178 *p = newNode; | 1178 *p = newNode; |
1179 } | 1179 } |
1180 } | 1180 } |
1181 | 1181 |
1182 TIntermTyped* constructor = intermediate.setAggregateOperator(aggrNode, op,
line); | 1182 TIntermTyped* constructor = intermediate.setAggregateOperator(aggrNode, op,
line); |
1183 TIntermTyped* constConstructor = foldConstConstructor(constructor->getAsAggr
egate(), *type); | 1183 TIntermTyped* constConstructor = foldConstConstructor(constructor->getAsAggr
egate(), *type); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 // | 1423 // |
1424 TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
ode, TSourceLoc line) | 1424 TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
ode, TSourceLoc line) |
1425 { | 1425 { |
1426 const TTypeList* fields = node->getType().getStruct(); | 1426 const TTypeList* fields = node->getType().getStruct(); |
1427 TIntermTyped *typedNode; | 1427 TIntermTyped *typedNode; |
1428 int instanceSize = 0; | 1428 int instanceSize = 0; |
1429 unsigned int index = 0; | 1429 unsigned int index = 0; |
1430 TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion(); | 1430 TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion(); |
1431 | 1431 |
1432 for ( index = 0; index < fields->size(); ++index) { | 1432 for ( index = 0; index < fields->size(); ++index) { |
1433 if ((*fields)[index].type->getFieldName() == identifier) { | 1433 if ((*fields)[index]->getFieldName() == identifier) { |
1434 break; | 1434 break; |
1435 } else { | 1435 } else { |
1436 instanceSize += (*fields)[index].type->getObjectSize(); | 1436 instanceSize += (*fields)[index]->getObjectSize(); |
1437 } | 1437 } |
1438 } | 1438 } |
1439 | 1439 |
1440 if (tempConstantNode) { | 1440 if (tempConstantNode) { |
1441 ConstantUnion* constArray = tempConstantNode->getUnionArrayPointer(); | 1441 ConstantUnion* constArray = tempConstantNode->getUnionArrayPointer(); |
1442 | 1442 |
1443 typedNode = intermediate.addConstantUnion(constArray+instanceSize, temp
ConstantNode->getType(), line); // type will be changed in the calling function | 1443 typedNode = intermediate.addConstantUnion(constArray+instanceSize, temp
ConstantNode->getType(), line); // type will be changed in the calling function |
1444 } else { | 1444 } else { |
1445 error(line, "Cannot offset into the structure", "Error"); | 1445 error(line, "Cannot offset into the structure", "Error"); |
1446 recover(); | 1446 recover(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 if (!error) | 1518 if (!error) |
1519 error = glslang_parse(context); | 1519 error = glslang_parse(context); |
1520 | 1520 |
1521 glslang_finalize(context); | 1521 glslang_finalize(context); |
1522 | 1522 |
1523 return (error == 0) && (context->numErrors() == 0) ? 0 : 1; | 1523 return (error == 0) && (context->numErrors() == 0) ? 0 : 1; |
1524 } | 1524 } |
1525 | 1525 |
1526 | 1526 |
1527 | 1527 |
OLD | NEW |