Apply the Apache 2.0 license.

Change-Id: I4a7aeefedcd2d891093520d5a10ebefadcddb5be
Reviewed-on: https://swiftshader-review.googlesource.com/5320
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/ParseHelper.cpp b/src/OpenGL/compiler/ParseHelper.cpp
index 87f1e2d..9d8d6a2 100644
--- a/src/OpenGL/compiler/ParseHelper.cpp
+++ b/src/OpenGL/compiler/ParseHelper.cpp
@@ -1,8 +1,16 @@
+// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
 //
-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
 //
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include "ParseHelper.h"
 
@@ -26,89 +34,89 @@
 //
 bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TVectorFields& fields, const TSourceLoc &line)
 {
-    fields.num = (int) compString.size();
-    if (fields.num > 4) {
-        error(line, "illegal vector field selection", compString.c_str());
-        return false;
-    }
+	fields.num = (int) compString.size();
+	if (fields.num > 4) {
+		error(line, "illegal vector field selection", compString.c_str());
+		return false;
+	}
 
-    enum {
-        exyzw,
-        ergba,
-        estpq
-    } fieldSet[4];
+	enum {
+		exyzw,
+		ergba,
+		estpq
+	} fieldSet[4];
 
-    for (int i = 0; i < fields.num; ++i) {
-        switch (compString[i])  {
-        case 'x':
-            fields.offsets[i] = 0;
-            fieldSet[i] = exyzw;
-            break;
-        case 'r':
-            fields.offsets[i] = 0;
-            fieldSet[i] = ergba;
-            break;
-        case 's':
-            fields.offsets[i] = 0;
-            fieldSet[i] = estpq;
-            break;
-        case 'y':
-            fields.offsets[i] = 1;
-            fieldSet[i] = exyzw;
-            break;
-        case 'g':
-            fields.offsets[i] = 1;
-            fieldSet[i] = ergba;
-            break;
-        case 't':
-            fields.offsets[i] = 1;
-            fieldSet[i] = estpq;
-            break;
-        case 'z':
-            fields.offsets[i] = 2;
-            fieldSet[i] = exyzw;
-            break;
-        case 'b':
-            fields.offsets[i] = 2;
-            fieldSet[i] = ergba;
-            break;
-        case 'p':
-            fields.offsets[i] = 2;
-            fieldSet[i] = estpq;
-            break;
-        case 'w':
-            fields.offsets[i] = 3;
-            fieldSet[i] = exyzw;
-            break;
-        case 'a':
-            fields.offsets[i] = 3;
-            fieldSet[i] = ergba;
-            break;
-        case 'q':
-            fields.offsets[i] = 3;
-            fieldSet[i] = estpq;
-            break;
-        default:
-            error(line, "illegal vector field selection", compString.c_str());
-            return false;
-        }
-    }
+	for (int i = 0; i < fields.num; ++i) {
+		switch (compString[i])  {
+		case 'x':
+			fields.offsets[i] = 0;
+			fieldSet[i] = exyzw;
+			break;
+		case 'r':
+			fields.offsets[i] = 0;
+			fieldSet[i] = ergba;
+			break;
+		case 's':
+			fields.offsets[i] = 0;
+			fieldSet[i] = estpq;
+			break;
+		case 'y':
+			fields.offsets[i] = 1;
+			fieldSet[i] = exyzw;
+			break;
+		case 'g':
+			fields.offsets[i] = 1;
+			fieldSet[i] = ergba;
+			break;
+		case 't':
+			fields.offsets[i] = 1;
+			fieldSet[i] = estpq;
+			break;
+		case 'z':
+			fields.offsets[i] = 2;
+			fieldSet[i] = exyzw;
+			break;
+		case 'b':
+			fields.offsets[i] = 2;
+			fieldSet[i] = ergba;
+			break;
+		case 'p':
+			fields.offsets[i] = 2;
+			fieldSet[i] = estpq;
+			break;
+		case 'w':
+			fields.offsets[i] = 3;
+			fieldSet[i] = exyzw;
+			break;
+		case 'a':
+			fields.offsets[i] = 3;
+			fieldSet[i] = ergba;
+			break;
+		case 'q':
+			fields.offsets[i] = 3;
+			fieldSet[i] = estpq;
+			break;
+		default:
+			error(line, "illegal vector field selection", compString.c_str());
+			return false;
+		}
+	}
 
-    for (int i = 0; i < fields.num; ++i) {
-        if (fields.offsets[i] >= vecSize) {
-            error(line, "vector field selection out of range",  compString.c_str());
-            return false;
-        }
+	for (int i = 0; i < fields.num; ++i) {
+		if (fields.offsets[i] >= vecSize) {
+			error(line, "vector field selection out of range",  compString.c_str());
+			return false;
+		}
 
-        if (i > 0) {
-            if (fieldSet[i] != fieldSet[i-1]) {
-                error(line, "illegal - vector component fields not from the same set", compString.c_str());
-                return false;
-            }
-        }
-    }
+		if (i > 0) {
+			if (fieldSet[i] != fieldSet[i-1]) {
+				error(line, "illegal - vector component fields not from the same set", compString.c_str());
+				return false;
+			}
+		}
+	}
 
-    return true;
+	return true;
 }
 
 
@@ -118,46 +126,46 @@
 //
 bool TParseContext::parseMatrixFields(const TString& compString, int matCols, int matRows, TMatrixFields& fields, const TSourceLoc &line)
 {
-    fields.wholeRow = false;
-    fields.wholeCol = false;
-    fields.row = -1;
-    fields.col = -1;
+	fields.wholeRow = false;
+	fields.wholeCol = false;
+	fields.row = -1;
+	fields.col = -1;
 
-    if (compString.size() != 2) {
-        error(line, "illegal length of matrix field selection", compString.c_str());
-        return false;
-    }
+	if (compString.size() != 2) {
+		error(line, "illegal length of matrix field selection", compString.c_str());
+		return false;
+	}
 
-    if (compString[0] == '_') {
-        if (compString[1] < '0' || compString[1] > '3') {
-            error(line, "illegal matrix field selection", compString.c_str());
-            return false;
-        }
-        fields.wholeCol = true;
-        fields.col = compString[1] - '0';
-    } else if (compString[1] == '_') {
-        if (compString[0] < '0' || compString[0] > '3') {
-            error(line, "illegal matrix field selection", compString.c_str());
-            return false;
-        }
-        fields.wholeRow = true;
-        fields.row = compString[0] - '0';
-    } else {
-        if (compString[0] < '0' || compString[0] > '3' ||
-            compString[1] < '0' || compString[1] > '3') {
-            error(line, "illegal matrix field selection", compString.c_str());
-            return false;
-        }
-        fields.row = compString[0] - '0';
-        fields.col = compString[1] - '0';
-    }
+	if (compString[0] == '_') {
+		if (compString[1] < '0' || compString[1] > '3') {
+			error(line, "illegal matrix field selection", compString.c_str());
+			return false;
+		}
+		fields.wholeCol = true;
+		fields.col = compString[1] - '0';
+	} else if (compString[1] == '_') {
+		if (compString[0] < '0' || compString[0] > '3') {
+			error(line, "illegal matrix field selection", compString.c_str());
+			return false;
+		}
+		fields.wholeRow = true;
+		fields.row = compString[0] - '0';
+	} else {
+		if (compString[0] < '0' || compString[0] > '3' ||
+			compString[1] < '0' || compString[1] > '3') {
+			error(line, "illegal matrix field selection", compString.c_str());
+			return false;
+		}
+		fields.row = compString[0] - '0';
+		fields.col = compString[1] - '0';
+	}
 
-    if (fields.row >= matRows || fields.col >= matCols) {
-        error(line, "matrix field selection out of range", compString.c_str());
-        return false;
-    }
+	if (fields.row >= matRows || fields.col >= matCols) {
+		error(line, "matrix field selection out of range", compString.c_str());
+		return false;
+	}
 
-    return true;
+	return true;
 }
 
 ///////////////////////////////////////////////////////////////////////
@@ -177,26 +185,26 @@
 // Used by flex/bison to output all syntax and parsing errors.
 //
 void TParseContext::error(const TSourceLoc& loc,
-                          const char* reason, const char* token,
-                          const char* extraInfo)
+						  const char* reason, const char* token,
+						  const char* extraInfo)
 {
-    pp::SourceLocation srcLoc(loc.first_file, loc.first_line);
-    mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
-                           srcLoc, reason, token, extraInfo);
+	pp::SourceLocation srcLoc(loc.first_file, loc.first_line);
+	mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
+						   srcLoc, reason, token, extraInfo);
 
 }
 
 void TParseContext::warning(const TSourceLoc& loc,
-                            const char* reason, const char* token,
-                            const char* extraInfo) {
-    pp::SourceLocation srcLoc(loc.first_file, loc.first_line);
-    mDiagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
-                           srcLoc, reason, token, extraInfo);
+							const char* reason, const char* token,
+							const char* extraInfo) {
+	pp::SourceLocation srcLoc(loc.first_file, loc.first_line);
+	mDiagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
+						   srcLoc, reason, token, extraInfo);
 }
 
 void TParseContext::trace(const char* str)
 {
-    mDiagnostics.writeDebug(str);
+	mDiagnostics.writeDebug(str);
 }
 
 //
@@ -204,10 +212,10 @@
 //
 void TParseContext::assignError(const TSourceLoc &line, const char* op, TString left, TString right)
 {
-    std::stringstream extraInfoStream;
-    extraInfoStream << "cannot convert from '" << right << "' to '" << left << "'";
-    std::string extraInfo = extraInfoStream.str();
-    error(line, "", op, extraInfo.c_str());
+	std::stringstream extraInfoStream;
+	extraInfoStream << "cannot convert from '" << right << "' to '" << left << "'";
+	std::string extraInfo = extraInfoStream.str();
+	error(line, "", op, extraInfo.c_str());
 }
 
 //
@@ -215,11 +223,11 @@
 //
 void TParseContext::unaryOpError(const TSourceLoc &line, const char* op, TString operand)
 {
-    std::stringstream extraInfoStream;
-    extraInfoStream << "no operation '" << op << "' exists that takes an operand of type " << operand
-                    << " (or there is no acceptable conversion)";
-    std::string extraInfo = extraInfoStream.str();
-    error(line, " wrong operand type", op, extraInfo.c_str());
+	std::stringstream extraInfoStream;
+	extraInfoStream << "no operation '" << op << "' exists that takes an operand of type " << operand
+					<< " (or there is no acceptable conversion)";
+	std::string extraInfo = extraInfoStream.str();
+	error(line, " wrong operand type", op, extraInfo.c_str());
 }
 
 //
@@ -227,33 +235,33 @@
 //
 void TParseContext::binaryOpError(const TSourceLoc &line, const char* op, TString left, TString right)
 {
-    std::stringstream extraInfoStream;
-    extraInfoStream << "no operation '" << op << "' exists that takes a left-hand operand of type '" << left
-                    << "' and a right operand of type '" << right << "' (or there is no acceptable conversion)";
-    std::string extraInfo = extraInfoStream.str();
-    error(line, " wrong operand types ", op, extraInfo.c_str());
+	std::stringstream extraInfoStream;
+	extraInfoStream << "no operation '" << op << "' exists that takes a left-hand operand of type '" << left
+					<< "' and a right operand of type '" << right << "' (or there is no acceptable conversion)";
+	std::string extraInfo = extraInfoStream.str();
+	error(line, " wrong operand types ", op, extraInfo.c_str());
 }
 
 bool TParseContext::precisionErrorCheck(const TSourceLoc &line, TPrecision precision, TBasicType type){
-    if (!mChecksPrecisionErrors)
-        return false;
-    switch( type ){
-    case EbtFloat:
-        if( precision == EbpUndefined ){
-            error( line, "No precision specified for (float)", "" );
-            return true;
-        }
-        break;
-    case EbtInt:
-        if( precision == EbpUndefined ){
-            error( line, "No precision specified (int)", "" );
-            return true;
-        }
-        break;
-    default:
-        return false;
-    }
-    return false;
+	if (!mChecksPrecisionErrors)
+		return false;
+	switch( type ){
+	case EbtFloat:
+		if( precision == EbpUndefined ){
+			error( line, "No precision specified for (float)", "" );
+			return true;
+		}
+		break;
+	case EbtInt:
+		if( precision == EbpUndefined ){
+			error( line, "No precision specified (int)", "" );
+			return true;
+		}
+		break;
+	default:
+		return false;
+	}
+	return false;
 }
 
 //
@@ -264,113 +272,113 @@
 //
 bool TParseContext::lValueErrorCheck(const TSourceLoc &line, const char* op, TIntermTyped* node)
 {
-    TIntermSymbol* symNode = node->getAsSymbolNode();
-    TIntermBinary* binaryNode = node->getAsBinaryNode();
+	TIntermSymbol* symNode = node->getAsSymbolNode();
+	TIntermBinary* binaryNode = node->getAsBinaryNode();
 
-    if (binaryNode) {
-        bool errorReturn;
+	if (binaryNode) {
+		bool errorReturn;
 
-        switch(binaryNode->getOp()) {
-        case EOpIndexDirect:
-        case EOpIndexIndirect:
-        case EOpIndexDirectStruct:
-            return lValueErrorCheck(line, op, binaryNode->getLeft());
-        case EOpVectorSwizzle:
-            errorReturn = lValueErrorCheck(line, op, binaryNode->getLeft());
-            if (!errorReturn) {
-                int offset[4] = {0,0,0,0};
+		switch(binaryNode->getOp()) {
+		case EOpIndexDirect:
+		case EOpIndexIndirect:
+		case EOpIndexDirectStruct:
+			return lValueErrorCheck(line, op, binaryNode->getLeft());
+		case EOpVectorSwizzle:
+			errorReturn = lValueErrorCheck(line, op, binaryNode->getLeft());
+			if (!errorReturn) {
+				int offset[4] = {0,0,0,0};
 
-                TIntermTyped* rightNode = binaryNode->getRight();
-                TIntermAggregate *aggrNode = rightNode->getAsAggregate();
+				TIntermTyped* rightNode = binaryNode->getRight();
+				TIntermAggregate *aggrNode = rightNode->getAsAggregate();
 
-                for (TIntermSequence::iterator p = aggrNode->getSequence().begin();
-                                               p != aggrNode->getSequence().end(); p++) {
-                    int value = (*p)->getAsTyped()->getAsConstantUnion()->getIConst(0);
-                    offset[value]++;
-                    if (offset[value] > 1) {
-                        error(line, " l-value of swizzle cannot have duplicate components", op);
+				for (TIntermSequence::iterator p = aggrNode->getSequence().begin();
+											   p != aggrNode->getSequence().end(); p++) {
+					int value = (*p)->getAsTyped()->getAsConstantUnion()->getIConst(0);
+					offset[value]++;
+					if (offset[value] > 1) {
+						error(line, " l-value of swizzle cannot have duplicate components", op);
 
-                        return true;
-                    }
-                }
-            }
+						return true;
+					}
+				}
+			}
 
-            return errorReturn;
-        default:
-            break;
-        }
-        error(line, " l-value required", op);
+			return errorReturn;
+		default:
+			break;
+		}
+		error(line, " l-value required", op);
 
-        return true;
-    }
+		return true;
+	}
 
 
-    const char* symbol = 0;
-    if (symNode != 0)
-        symbol = symNode->getSymbol().c_str();
+	const char* symbol = 0;
+	if (symNode != 0)
+		symbol = symNode->getSymbol().c_str();
 
-    const char* message = 0;
-    switch (node->getQualifier()) {
-    case EvqConstExpr:      message = "can't modify a const";        break;
-    case EvqConstReadOnly:  message = "can't modify a const";        break;
-    case EvqAttribute:      message = "can't modify an attribute";   break;
-    case EvqFragmentIn:     message = "can't modify an input";       break;
-    case EvqVertexIn:       message = "can't modify an input";       break;
-    case EvqUniform:        message = "can't modify a uniform";      break;
-    case EvqSmoothIn:
-    case EvqFlatIn:
-    case EvqCentroidIn:
-    case EvqVaryingIn:      message = "can't modify a varying";      break;
-    case EvqInput:          message = "can't modify an input";       break;
-    case EvqFragCoord:      message = "can't modify gl_FragCoord";   break;
-    case EvqFrontFacing:    message = "can't modify gl_FrontFacing"; break;
-    case EvqPointCoord:     message = "can't modify gl_PointCoord";  break;
-    case EvqInstanceID:     message = "can't modify gl_InstanceID";  break;
-    default:
+	const char* message = 0;
+	switch (node->getQualifier()) {
+	case EvqConstExpr:      message = "can't modify a const";        break;
+	case EvqConstReadOnly:  message = "can't modify a const";        break;
+	case EvqAttribute:      message = "can't modify an attribute";   break;
+	case EvqFragmentIn:     message = "can't modify an input";       break;
+	case EvqVertexIn:       message = "can't modify an input";       break;
+	case EvqUniform:        message = "can't modify a uniform";      break;
+	case EvqSmoothIn:
+	case EvqFlatIn:
+	case EvqCentroidIn:
+	case EvqVaryingIn:      message = "can't modify a varying";      break;
+	case EvqInput:          message = "can't modify an input";       break;
+	case EvqFragCoord:      message = "can't modify gl_FragCoord";   break;
+	case EvqFrontFacing:    message = "can't modify gl_FrontFacing"; break;
+	case EvqPointCoord:     message = "can't modify gl_PointCoord";  break;
+	case EvqInstanceID:     message = "can't modify gl_InstanceID";  break;
+	default:
 
-        //
-        // Type that can't be written to?
-        //
-        if(IsSampler(node->getBasicType()))
-        {
-            message = "can't modify a sampler";
-        }
-        else if(node->getBasicType() == EbtVoid)
-        {
-            message = "can't modify void";
-        }
-    }
+		//
+		// Type that can't be written to?
+		//
+		if(IsSampler(node->getBasicType()))
+		{
+			message = "can't modify a sampler";
+		}
+		else if(node->getBasicType() == EbtVoid)
+		{
+			message = "can't modify void";
+		}
+	}
 
-    if (message == 0 && binaryNode == 0 && symNode == 0) {
-        error(line, " l-value required", op);
+	if (message == 0 && binaryNode == 0 && symNode == 0) {
+		error(line, " l-value required", op);
 
-        return true;
-    }
+		return true;
+	}
 
 
-    //
-    // Everything else is okay, no error.
-    //
-    if (message == 0)
-        return false;
+	//
+	// Everything else is okay, no error.
+	//
+	if (message == 0)
+		return false;
 
-    //
-    // If we get here, we have an error and a message.
-    //
-    if (symNode) {
-        std::stringstream extraInfoStream;
-        extraInfoStream << "\"" << symbol << "\" (" << message << ")";
-        std::string extraInfo = extraInfoStream.str();
-        error(line, " l-value required", op, extraInfo.c_str());
-    }
-    else {
-        std::stringstream extraInfoStream;
-        extraInfoStream << "(" << message << ")";
-        std::string extraInfo = extraInfoStream.str();
-        error(line, " l-value required", op, extraInfo.c_str());
-    }
+	//
+	// If we get here, we have an error and a message.
+	//
+	if (symNode) {
+		std::stringstream extraInfoStream;
+		extraInfoStream << "\"" << symbol << "\" (" << message << ")";
+		std::string extraInfo = extraInfoStream.str();
+		error(line, " l-value required", op, extraInfo.c_str());
+	}
+	else {
+		std::stringstream extraInfoStream;
+		extraInfoStream << "(" << message << ")";
+		std::string extraInfo = extraInfoStream.str();
+		error(line, " l-value required", op, extraInfo.c_str());
+	}
 
-    return true;
+	return true;
 }
 
 //
@@ -381,12 +389,12 @@
 //
 bool TParseContext::constErrorCheck(TIntermTyped* node)
 {
-    if (node->getQualifier() == EvqConstExpr)
-        return false;
+	if (node->getQualifier() == EvqConstExpr)
+		return false;
 
-    error(node->getLine(), "constant expression required", "");
+	error(node->getLine(), "constant expression required", "");
 
-    return true;
+	return true;
 }
 
 //
@@ -397,12 +405,12 @@
 //
 bool TParseContext::integerErrorCheck(TIntermTyped* node, const char* token)
 {
-    if (node->isScalarInt())
-        return false;
+	if (node->isScalarInt())
+		return false;
 
-    error(node->getLine(), "integer expression required", token);
+	error(node->getLine(), "integer expression required", token);
 
-    return true;
+	return true;
 }
 
 //
@@ -413,12 +421,12 @@
 //
 bool TParseContext::globalErrorCheck(const TSourceLoc &line, bool global, const char* token)
 {
-    if (global)
-        return false;
+	if (global)
+		return false;
 
-    error(line, "only allowed at global scope", token);
+	error(line, "only allowed at global scope", token);
 
-    return true;
+	return true;
 }
 
 //
@@ -432,19 +440,19 @@
 //
 bool TParseContext::reservedErrorCheck(const TSourceLoc &line, const TString& identifier)
 {
-    static const char* reservedErrMsg = "reserved built-in name";
-    if (!symbolTable.atBuiltInLevel()) {
-        if (identifier.compare(0, 3, "gl_") == 0) {
-            error(line, reservedErrMsg, "gl_");
-            return true;
-        }
-        if (identifier.find("__") != TString::npos) {
-            error(line, "identifiers containing two consecutive underscores (__) are reserved as possible future keywords", identifier.c_str());
-            return true;
-        }
-    }
+	static const char* reservedErrMsg = "reserved built-in name";
+	if (!symbolTable.atBuiltInLevel()) {
+		if (identifier.compare(0, 3, "gl_") == 0) {
+			error(line, reservedErrMsg, "gl_");
+			return true;
+		}
+		if (identifier.find("__") != TString::npos) {
+			error(line, "identifiers containing two consecutive underscores (__) are reserved as possible future keywords", identifier.c_str());
+			return true;
+		}
+	}
 
-    return false;
+	return false;
 }
 
 //
@@ -456,104 +464,104 @@
 //
 bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* node, TFunction& function, TOperator op, TType* type)
 {
-    *type = function.getReturnType();
+	*type = function.getReturnType();
 
-    bool constructingMatrix = false;
-    switch(op) {
-    case EOpConstructMat2:
-    case EOpConstructMat2x3:
-    case EOpConstructMat2x4:
-    case EOpConstructMat3x2:
-    case EOpConstructMat3:
-    case EOpConstructMat3x4:
-    case EOpConstructMat4x2:
-    case EOpConstructMat4x3:
-    case EOpConstructMat4:
-        constructingMatrix = true;
-        break;
-    default:
-        break;
-    }
+	bool constructingMatrix = false;
+	switch(op) {
+	case EOpConstructMat2:
+	case EOpConstructMat2x3:
+	case EOpConstructMat2x4:
+	case EOpConstructMat3x2:
+	case EOpConstructMat3:
+	case EOpConstructMat3x4:
+	case EOpConstructMat4x2:
+	case EOpConstructMat4x3:
+	case EOpConstructMat4:
+		constructingMatrix = true;
+		break;
+	default:
+		break;
+	}
 
-    //
-    // Note: It's okay to have too many components available, but not okay to have unused
-    // arguments.  'full' will go to true when enough args have been seen.  If we loop
-    // again, there is an extra argument, so 'overfull' will become true.
-    //
+	//
+	// Note: It's okay to have too many components available, but not okay to have unused
+	// arguments.  'full' will go to true when enough args have been seen.  If we loop
+	// again, there is an extra argument, so 'overfull' will become true.
+	//
 
-    size_t size = 0;
-    bool full = false;
-    bool overFull = false;
-    bool matrixInMatrix = false;
-    bool arrayArg = false;
-    for (size_t i = 0; i < function.getParamCount(); ++i) {
-        const TParameter& param = function.getParam(i);
-        size += param.type->getObjectSize();
+	size_t size = 0;
+	bool full = false;
+	bool overFull = false;
+	bool matrixInMatrix = false;
+	bool arrayArg = false;
+	for (size_t i = 0; i < function.getParamCount(); ++i) {
+		const TParameter& param = function.getParam(i);
+		size += param.type->getObjectSize();
 
-        if (constructingMatrix && param.type->isMatrix())
-            matrixInMatrix = true;
-        if (full)
-            overFull = true;
-        if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize())
-            full = true;
-        if (param.type->isArray())
-            arrayArg = true;
-    }
+		if (constructingMatrix && param.type->isMatrix())
+			matrixInMatrix = true;
+		if (full)
+			overFull = true;
+		if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize())
+			full = true;
+		if (param.type->isArray())
+			arrayArg = true;
+	}
 
-    if(type->isArray()) {
-        if(type->getArraySize() == 0) {
-            type->setArraySize(function.getParamCount());
-        } else if(type->getArraySize() != (int)function.getParamCount()) {
-            error(line, "array constructor needs one argument per array element", "constructor");
-            return true;
-        }
-    }
+	if(type->isArray()) {
+		if(type->getArraySize() == 0) {
+			type->setArraySize(function.getParamCount());
+		} else if(type->getArraySize() != (int)function.getParamCount()) {
+			error(line, "array constructor needs one argument per array element", "constructor");
+			return true;
+		}
+	}
 
-    if (arrayArg && op != EOpConstructStruct) {
-        error(line, "constructing from a non-dereferenced array", "constructor");
-        return true;
-    }
+	if (arrayArg && op != EOpConstructStruct) {
+		error(line, "constructing from a non-dereferenced array", "constructor");
+		return true;
+	}
 
-    if (matrixInMatrix && !type->isArray()) {
-        if (function.getParamCount() != 1) {
-          error(line, "constructing matrix from matrix can only take one argument", "constructor");
-          return true;
-        }
-    }
+	if (matrixInMatrix && !type->isArray()) {
+		if (function.getParamCount() != 1) {
+		  error(line, "constructing matrix from matrix can only take one argument", "constructor");
+		  return true;
+		}
+	}
 
-    if (overFull) {
-        error(line, "too many arguments", "constructor");
-        return true;
-    }
+	if (overFull) {
+		error(line, "too many arguments", "constructor");
+		return true;
+	}
 
-    if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->fields().size() != function.getParamCount()) {
-        error(line, "Number of constructor parameters does not match the number of structure fields", "constructor");
-        return true;
-    }
+	if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->fields().size() != function.getParamCount()) {
+		error(line, "Number of constructor parameters does not match the number of structure fields", "constructor");
+		return true;
+	}
 
-    if (!type->isMatrix() || !matrixInMatrix) {
-        if ((op != EOpConstructStruct && size != 1 && size < type->getObjectSize()) ||
-            (op == EOpConstructStruct && size < type->getObjectSize())) {
-            error(line, "not enough data provided for construction", "constructor");
-            return true;
-        }
-    }
+	if (!type->isMatrix() || !matrixInMatrix) {
+		if ((op != EOpConstructStruct && size != 1 && size < type->getObjectSize()) ||
+			(op == EOpConstructStruct && size < type->getObjectSize())) {
+			error(line, "not enough data provided for construction", "constructor");
+			return true;
+		}
+	}
 
-    TIntermTyped *typed = node ? node->getAsTyped() : 0;
-    if (typed == 0) {
-        error(line, "constructor argument does not have a type", "constructor");
-        return true;
-    }
-    if (op != EOpConstructStruct && IsSampler(typed->getBasicType())) {
-        error(line, "cannot convert a sampler", "constructor");
-        return true;
-    }
-    if (typed->getBasicType() == EbtVoid) {
-        error(line, "cannot convert a void", "constructor");
-        return true;
-    }
+	TIntermTyped *typed = node ? node->getAsTyped() : 0;
+	if (typed == 0) {
+		error(line, "constructor argument does not have a type", "constructor");
+		return true;
+	}
+	if (op != EOpConstructStruct && IsSampler(typed->getBasicType())) {
+		error(line, "cannot convert a sampler", "constructor");
+		return true;
+	}
+	if (typed->getBasicType() == EbtVoid) {
+		error(line, "cannot convert a void", "constructor");
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 // This function checks to see if a void variable has been declared and raise an error message for such a case
@@ -562,12 +570,12 @@
 //
 bool TParseContext::voidErrorCheck(const TSourceLoc &line, const TString& identifier, const TBasicType& type)
 {
-    if(type == EbtVoid) {
-        error(line, "illegal use of type 'void'", identifier.c_str());
-        return true;
-    }
+	if(type == EbtVoid) {
+		error(line, "illegal use of type 'void'", identifier.c_str());
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 // This function checks to see if the node (for the expression) contains a scalar boolean expression or not
@@ -576,12 +584,12 @@
 //
 bool TParseContext::boolErrorCheck(const TSourceLoc &line, const TIntermTyped* type)
 {
-    if (type->getBasicType() != EbtBool || type->isArray() || type->isMatrix() || type->isVector()) {
-        error(line, "boolean expression expected", "");
-        return true;
-    }
+	if (type->getBasicType() != EbtBool || type->isArray() || type->isMatrix() || type->isVector()) {
+		error(line, "boolean expression expected", "");
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 // This function checks to see if the node (for the expression) contains a scalar boolean expression or not
@@ -590,31 +598,31 @@
 //
 bool TParseContext::boolErrorCheck(const TSourceLoc &line, const TPublicType& pType)
 {
-    if (pType.type != EbtBool || pType.array || (pType.primarySize > 1) || (pType.secondarySize > 1)) {
-        error(line, "boolean expression expected", "");
-        return true;
-    }
+	if (pType.type != EbtBool || pType.array || (pType.primarySize > 1) || (pType.secondarySize > 1)) {
+		error(line, "boolean expression expected", "");
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 bool TParseContext::samplerErrorCheck(const TSourceLoc &line, const TPublicType& pType, const char* reason)
 {
-    if (pType.type == EbtStruct) {
-        if (containsSampler(*pType.userDef)) {
-            error(line, reason, getBasicString(pType.type), "(structure contains a sampler)");
+	if (pType.type == EbtStruct) {
+		if (containsSampler(*pType.userDef)) {
+			error(line, reason, getBasicString(pType.type), "(structure contains a sampler)");
 
-            return true;
-        }
+			return true;
+		}
 
-        return false;
-    } else if (IsSampler(pType.type)) {
-        error(line, reason, getBasicString(pType.type));
+		return false;
+	} else if (IsSampler(pType.type)) {
+		error(line, reason, getBasicString(pType.type));
 
-        return true;
-    }
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 bool TParseContext::structQualifierErrorCheck(const TSourceLoc &line, const TPublicType& pType)
@@ -643,19 +651,19 @@
 		break;
 	}
 
-    if (pType.qualifier != EvqUniform && samplerErrorCheck(line, pType, "samplers must be uniform"))
-        return true;
+	if (pType.qualifier != EvqUniform && samplerErrorCheck(line, pType, "samplers must be uniform"))
+		return true;
 
 	// check for layout qualifier issues
 	const TLayoutQualifier layoutQualifier = pType.layoutQualifier;
 
 	if (pType.qualifier != EvqVertexIn && pType.qualifier != EvqFragmentOut &&
-	    layoutLocationErrorCheck(line, pType.layoutQualifier))
+		layoutLocationErrorCheck(line, pType.layoutQualifier))
 	{
 		return true;
 	}
 
-    return false;
+	return false;
 }
 
 // These checks are common for all declarations starting a declarator list, and declarators that follow an empty
@@ -736,29 +744,29 @@
 
 bool TParseContext::parameterSamplerErrorCheck(const TSourceLoc &line, TQualifier qualifier, const TType& type)
 {
-    if ((qualifier == EvqOut || qualifier == EvqInOut) &&
-             type.getBasicType() != EbtStruct && IsSampler(type.getBasicType())) {
-        error(line, "samplers cannot be output parameters", type.getBasicString());
-        return true;
-    }
+	if ((qualifier == EvqOut || qualifier == EvqInOut) &&
+			 type.getBasicType() != EbtStruct && IsSampler(type.getBasicType())) {
+		error(line, "samplers cannot be output parameters", type.getBasicString());
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 bool TParseContext::containsSampler(TType& type)
 {
-    if (IsSampler(type.getBasicType()))
-        return true;
+	if (IsSampler(type.getBasicType()))
+		return true;
 
-    if (type.getBasicType() == EbtStruct) {
-        const TFieldList& fields = type.getStruct()->fields();
-        for(unsigned int i = 0; i < fields.size(); ++i) {
-            if (containsSampler(*fields[i]->type()))
-                return true;
-        }
-    }
+	if (type.getBasicType() == EbtStruct) {
+		const TFieldList& fields = type.getStruct()->fields();
+		for(unsigned int i = 0; i < fields.size(); ++i) {
+			if (containsSampler(*fields[i]->type()))
+				return true;
+		}
+	}
 
-    return false;
+	return false;
 }
 
 //
@@ -768,39 +776,39 @@
 //
 bool TParseContext::arraySizeErrorCheck(const TSourceLoc &line, TIntermTyped* expr, int& size)
 {
-    TIntermConstantUnion* constant = expr->getAsConstantUnion();
+	TIntermConstantUnion* constant = expr->getAsConstantUnion();
 
-    if (constant == 0 || !constant->isScalarInt())
-    {
-        error(line, "array size must be a constant integer expression", "");
-        return true;
-    }
+	if (constant == 0 || !constant->isScalarInt())
+	{
+		error(line, "array size must be a constant integer expression", "");
+		return true;
+	}
 
-    if (constant->getBasicType() == EbtUInt)
-    {
-        unsigned int uintSize = constant->getUConst(0);
-        if (uintSize > static_cast<unsigned int>(std::numeric_limits<int>::max()))
-        {
-            error(line, "array size too large", "");
-            size = 1;
-            return true;
-        }
+	if (constant->getBasicType() == EbtUInt)
+	{
+		unsigned int uintSize = constant->getUConst(0);
+		if (uintSize > static_cast<unsigned int>(std::numeric_limits<int>::max()))
+		{
+			error(line, "array size too large", "");
+			size = 1;
+			return true;
+		}
 
-        size = static_cast<int>(uintSize);
-    }
-    else
-    {
-        size = constant->getIConst(0);
+		size = static_cast<int>(uintSize);
+	}
+	else
+	{
+		size = constant->getIConst(0);
 
-        if (size <= 0)
-        {
-            error(line, "array size must be a positive integer", "");
-            size = 1;
-            return true;
-        }
-    }
+		if (size <= 0)
+		{
+			error(line, "array size must be a positive integer", "");
+			size = 1;
+			return true;
+		}
+	}
 
-    return false;
+	return false;
 }
 
 //
@@ -810,12 +818,12 @@
 //
 bool TParseContext::arrayQualifierErrorCheck(const TSourceLoc &line, TPublicType type)
 {
-    if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqVertexIn) || (type.qualifier == EvqConstExpr)) {
-        error(line, "cannot declare arrays of this qualifier", TType(type).getCompleteString().c_str());
-        return true;
-    }
+	if ((type.qualifier == EvqAttribute) || (type.qualifier == EvqVertexIn) || (type.qualifier == EvqConstExpr)) {
+		error(line, "cannot declare arrays of this qualifier", TType(type).getCompleteString().c_str());
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 //
@@ -825,59 +833,59 @@
 //
 bool TParseContext::arrayTypeErrorCheck(const TSourceLoc &line, TPublicType type)
 {
-    //
-    // Can the type be an array?
-    //
-    if (type.array) {
-        error(line, "cannot declare arrays of arrays", TType(type).getCompleteString().c_str());
-        return true;
-    }
+	//
+	// Can the type be an array?
+	//
+	if (type.array) {
+		error(line, "cannot declare arrays of arrays", TType(type).getCompleteString().c_str());
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size, bool updateFlag, const TSourceLoc &line)
 {
-    bool builtIn = false;
-    TSymbol* symbol = symbolTable.find(node->getSymbol(), mShaderVersion, &builtIn);
-    if (symbol == 0) {
-        error(line, " undeclared identifier", node->getSymbol().c_str());
-        return true;
-    }
-    TVariable* variable = static_cast<TVariable*>(symbol);
+	bool builtIn = false;
+	TSymbol* symbol = symbolTable.find(node->getSymbol(), mShaderVersion, &builtIn);
+	if (symbol == 0) {
+		error(line, " undeclared identifier", node->getSymbol().c_str());
+		return true;
+	}
+	TVariable* variable = static_cast<TVariable*>(symbol);
 
-    type->setArrayInformationType(variable->getArrayInformationType());
-    variable->updateArrayInformationType(type);
+	type->setArrayInformationType(variable->getArrayInformationType());
+	variable->updateArrayInformationType(type);
 
-    // special casing to test index value of gl_FragData. If the accessed index is >= gl_MaxDrawBuffers
-    // its an error
-    if (node->getSymbol() == "gl_FragData") {
-        TSymbol* fragData = symbolTable.find("gl_MaxDrawBuffers", mShaderVersion, &builtIn);
-        ASSERT(fragData);
+	// special casing to test index value of gl_FragData. If the accessed index is >= gl_MaxDrawBuffers
+	// its an error
+	if (node->getSymbol() == "gl_FragData") {
+		TSymbol* fragData = symbolTable.find("gl_MaxDrawBuffers", mShaderVersion, &builtIn);
+		ASSERT(fragData);
 
-        int fragDataValue = static_cast<TVariable*>(fragData)->getConstPointer()[0].getIConst();
-        if (fragDataValue <= size) {
-            error(line, "", "[", "gl_FragData can only have a max array size of up to gl_MaxDrawBuffers");
-            return true;
-        }
-    }
+		int fragDataValue = static_cast<TVariable*>(fragData)->getConstPointer()[0].getIConst();
+		if (fragDataValue <= size) {
+			error(line, "", "[", "gl_FragData can only have a max array size of up to gl_MaxDrawBuffers");
+			return true;
+		}
+	}
 
-    // we dont want to update the maxArraySize when this flag is not set, we just want to include this
-    // node type in the chain of node types so that its updated when a higher maxArraySize comes in.
-    if (!updateFlag)
-        return false;
+	// we dont want to update the maxArraySize when this flag is not set, we just want to include this
+	// node type in the chain of node types so that its updated when a higher maxArraySize comes in.
+	if (!updateFlag)
+		return false;
 
-    size++;
-    variable->getType().setMaxArraySize(size);
-    type->setMaxArraySize(size);
-    TType* tt = type;
+	size++;
+	variable->getType().setMaxArraySize(size);
+	type->setMaxArraySize(size);
+	TType* tt = type;
 
-    while(tt->getArrayInformationType() != 0) {
-        tt = tt->getArrayInformationType();
-        tt->setMaxArraySize(size);
-    }
+	while(tt->getArrayInformationType() != 0) {
+		tt = tt->getArrayInformationType();
+		tt->setMaxArraySize(size);
+	}
 
-    return false;
+	return false;
 }
 
 //
@@ -887,28 +895,28 @@
 //
 bool TParseContext::nonInitConstErrorCheck(const TSourceLoc &line, TString& identifier, TPublicType& type, bool array)
 {
-    if (type.qualifier == EvqConstExpr)
-    {
-        // Make the qualifier make sense.
-        type.qualifier = EvqTemporary;
+	if (type.qualifier == EvqConstExpr)
+	{
+		// Make the qualifier make sense.
+		type.qualifier = EvqTemporary;
 
-        if (array)
-        {
-            error(line, "arrays may not be declared constant since they cannot be initialized", identifier.c_str());
-        }
-        else if (type.isStructureContainingArrays())
-        {
-            error(line, "structures containing arrays may not be declared constant since they cannot be initialized", identifier.c_str());
-        }
-        else
-        {
-            error(line, "variables with qualifier 'const' must be initialized", identifier.c_str());
-        }
+		if (array)
+		{
+			error(line, "arrays may not be declared constant since they cannot be initialized", identifier.c_str());
+		}
+		else if (type.isStructureContainingArrays())
+		{
+			error(line, "structures containing arrays may not be declared constant since they cannot be initialized", identifier.c_str());
+		}
+		else
+		{
+			error(line, "variables with qualifier 'const' must be initialized", identifier.c_str());
+		}
 
-        return true;
-    }
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 //
@@ -989,42 +997,42 @@
 
 bool TParseContext::paramErrorCheck(const TSourceLoc &line, TQualifier qualifier, TQualifier paramQualifier, TType* type)
 {
-    if (qualifier != EvqConstReadOnly && qualifier != EvqTemporary) {
-        error(line, "qualifier not allowed on function parameter", getQualifierString(qualifier));
-        return true;
-    }
-    if (qualifier == EvqConstReadOnly && paramQualifier != EvqIn) {
-        error(line, "qualifier not allowed with ", getQualifierString(qualifier), getQualifierString(paramQualifier));
-        return true;
-    }
+	if (qualifier != EvqConstReadOnly && qualifier != EvqTemporary) {
+		error(line, "qualifier not allowed on function parameter", getQualifierString(qualifier));
+		return true;
+	}
+	if (qualifier == EvqConstReadOnly && paramQualifier != EvqIn) {
+		error(line, "qualifier not allowed with ", getQualifierString(qualifier), getQualifierString(paramQualifier));
+		return true;
+	}
 
-    if (qualifier == EvqConstReadOnly)
-        type->setQualifier(EvqConstReadOnly);
-    else
-        type->setQualifier(paramQualifier);
+	if (qualifier == EvqConstReadOnly)
+		type->setQualifier(EvqConstReadOnly);
+	else
+		type->setQualifier(paramQualifier);
 
-    return false;
+	return false;
 }
 
 bool TParseContext::extensionErrorCheck(const TSourceLoc &line, const TString& extension)
 {
-    const TExtensionBehavior& extBehavior = extensionBehavior();
-    TExtensionBehavior::const_iterator iter = extBehavior.find(extension.c_str());
-    if (iter == extBehavior.end()) {
-        error(line, "extension", extension.c_str(), "is not supported");
-        return true;
-    }
-    // In GLSL ES, an extension's default behavior is "disable".
-    if (iter->second == EBhDisable || iter->second == EBhUndefined) {
-        error(line, "extension", extension.c_str(), "is disabled");
-        return true;
-    }
-    if (iter->second == EBhWarn) {
-        warning(line, "extension", extension.c_str(), "is being used");
-        return false;
-    }
+	const TExtensionBehavior& extBehavior = extensionBehavior();
+	TExtensionBehavior::const_iterator iter = extBehavior.find(extension.c_str());
+	if (iter == extBehavior.end()) {
+		error(line, "extension", extension.c_str(), "is not supported");
+		return true;
+	}
+	// In GLSL ES, an extension's default behavior is "disable".
+	if (iter->second == EBhDisable || iter->second == EBhUndefined) {
+		error(line, "extension", extension.c_str(), "is disabled");
+		return true;
+	}
+	if (iter->second == EBhWarn) {
+		warning(line, "extension", extension.c_str(), "is being used");
+		return false;
+	}
 
-    return false;
+	return false;
 }
 
 bool TParseContext::functionCallLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *aggregate)
@@ -1067,21 +1075,21 @@
 
 bool TParseContext::supportsExtension(const char* extension)
 {
-    const TExtensionBehavior& extbehavior = extensionBehavior();
-    TExtensionBehavior::const_iterator iter = extbehavior.find(extension);
-    return (iter != extbehavior.end());
+	const TExtensionBehavior& extbehavior = extensionBehavior();
+	TExtensionBehavior::const_iterator iter = extbehavior.find(extension);
+	return (iter != extbehavior.end());
 }
 
 void TParseContext::handleExtensionDirective(const TSourceLoc &line, const char* extName, const char* behavior)
 {
-    pp::SourceLocation loc(line.first_file, line.first_line);
-    mDirectiveHandler.handleExtension(loc, extName, behavior);
+	pp::SourceLocation loc(line.first_file, line.first_line);
+	mDirectiveHandler.handleExtension(loc, extName, behavior);
 }
 
 void TParseContext::handlePragmaDirective(const TSourceLoc &line, const char* name, const char* value)
 {
-    pp::SourceLocation loc(line.first_file, line.first_line);
-    mDirectiveHandler.handlePragma(loc, name, value);
+	pp::SourceLocation loc(line.first_file, line.first_line);
+	mDirectiveHandler.handlePragma(loc, name, value);
 }
 
 /////////////////////////////////////////////////////////////////////////////////
@@ -1094,7 +1102,7 @@
 	const TString *name,
 	const TSymbol *symbol)
 {
-	const TVariable *variable = NULL;
+	const TVariable *variable = nullptr;
 
 	if(!symbol)
 	{
@@ -1155,24 +1163,24 @@
 //
 const TFunction* TParseContext::findFunction(const TSourceLoc &line, TFunction* call, bool *builtIn)
 {
-    // First find by unmangled name to check whether the function name has been
-    // hidden by a variable name or struct typename.
-    const TSymbol* symbol = symbolTable.find(call->getName(), mShaderVersion, builtIn);
-    if (symbol == 0) {
-        symbol = symbolTable.find(call->getMangledName(), mShaderVersion, builtIn);
-    }
+	// First find by unmangled name to check whether the function name has been
+	// hidden by a variable name or struct typename.
+	const TSymbol* symbol = symbolTable.find(call->getName(), mShaderVersion, builtIn);
+	if (symbol == 0) {
+		symbol = symbolTable.find(call->getMangledName(), mShaderVersion, builtIn);
+	}
 
-    if (symbol == 0) {
-        error(line, "no matching overloaded function found", call->getName().c_str());
-        return 0;
-    }
+	if (symbol == 0) {
+		error(line, "no matching overloaded function found", call->getName().c_str());
+		return 0;
+	}
 
-    if (!symbol->isFunction()) {
-        error(line, "function name expected", call->getName().c_str());
-        return 0;
-    }
+	if (!symbol->isFunction()) {
+		error(line, "function name expected", call->getName().c_str());
+		return 0;
+	}
 
-    return static_cast<const TFunction*>(symbol);
+	return static_cast<const TFunction*>(symbol);
 }
 
 //
@@ -1180,7 +1188,7 @@
 // code to handle them here.
 //
 bool TParseContext::executeInitializer(const TSourceLoc& line, const TString& identifier, const TPublicType& pType,
-                                       TIntermTyped *initializer, TIntermNode **intermNode)
+									   TIntermTyped *initializer, TIntermNode **intermNode)
 {
 	ASSERT(intermNode != nullptr);
 	TType type = TType(pType);
@@ -1208,59 +1216,59 @@
 	{
 		warning(line, "global variable initializers should be constant expressions "
 			"(uniforms and globals are allowed in global initializers for legacy compatibility)", "=");
-    }
+	}
 
-    //
-    // identifier must be of type constant, a global, or a temporary
-    //
-    TQualifier qualifier = type.getQualifier();
-    if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal) && (qualifier != EvqConstExpr)) {
-        error(line, " cannot initialize this type of qualifier ", variable->getType().getQualifierString());
-        return true;
-    }
-    //
-    // test for and propagate constant
-    //
+	//
+	// identifier must be of type constant, a global, or a temporary
+	//
+	TQualifier qualifier = type.getQualifier();
+	if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal) && (qualifier != EvqConstExpr)) {
+		error(line, " cannot initialize this type of qualifier ", variable->getType().getQualifierString());
+		return true;
+	}
+	//
+	// test for and propagate constant
+	//
 
-    if (qualifier == EvqConstExpr) {
-        if (qualifier != initializer->getQualifier()) {
-            std::stringstream extraInfoStream;
-            extraInfoStream << "'" << variable->getType().getCompleteString() << "'";
-            std::string extraInfo = extraInfoStream.str();
-            error(line, " assigning non-constant to", "=", extraInfo.c_str());
-            variable->getType().setQualifier(EvqTemporary);
-            return true;
-        }
+	if (qualifier == EvqConstExpr) {
+		if (qualifier != initializer->getQualifier()) {
+			std::stringstream extraInfoStream;
+			extraInfoStream << "'" << variable->getType().getCompleteString() << "'";
+			std::string extraInfo = extraInfoStream.str();
+			error(line, " assigning non-constant to", "=", extraInfo.c_str());
+			variable->getType().setQualifier(EvqTemporary);
+			return true;
+		}
 
-        if (type != initializer->getType()) {
-            error(line, " non-matching types for const initializer ",
-                variable->getType().getQualifierString());
-            variable->getType().setQualifier(EvqTemporary);
-            return true;
-        }
+		if (type != initializer->getType()) {
+			error(line, " non-matching types for const initializer ",
+				variable->getType().getQualifierString());
+			variable->getType().setQualifier(EvqTemporary);
+			return true;
+		}
 
-        if (initializer->getAsConstantUnion()) {
-            variable->shareConstPointer(initializer->getAsConstantUnion()->getUnionArrayPointer());
-        } else if (initializer->getAsSymbolNode()) {
-            const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol(), 0);
-            const TVariable* tVar = static_cast<const TVariable*>(symbol);
+		if (initializer->getAsConstantUnion()) {
+			variable->shareConstPointer(initializer->getAsConstantUnion()->getUnionArrayPointer());
+		} else if (initializer->getAsSymbolNode()) {
+			const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol(), 0);
+			const TVariable* tVar = static_cast<const TVariable*>(symbol);
 
-            ConstantUnion* constArray = tVar->getConstPointer();
-            variable->shareConstPointer(constArray);
-        }
-    }
+			ConstantUnion* constArray = tVar->getConstPointer();
+			variable->shareConstPointer(constArray);
+		}
+	}
 
-    if (!variable->isConstant()) {
-        TIntermSymbol* intermSymbol = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), line);
-        *intermNode = createAssign(EOpInitialize, intermSymbol, initializer, line);
-        if(*intermNode == nullptr) {
-            assignError(line, "=", intermSymbol->getCompleteString(), initializer->getCompleteString());
-            return true;
-        }
-    } else
-        *intermNode = nullptr;
+	if (!variable->isConstant()) {
+		TIntermSymbol* intermSymbol = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), line);
+		*intermNode = createAssign(EOpInitialize, intermSymbol, initializer, line);
+		if(*intermNode == nullptr) {
+			assignError(line, "=", intermSymbol->getCompleteString(), initializer->getCompleteString());
+			return true;
+		}
+	} else
+		*intermNode = nullptr;
 
-    return false;
+	return false;
 }
 
 TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, bool invariant, TLayoutQualifier layoutQualifier, const TPublicType &typeSpecifier)
@@ -2062,61 +2070,61 @@
 //
 TIntermTyped* TParseContext::addConstructor(TIntermNode* arguments, const TType* type, TOperator op, TFunction* fnCall, const TSourceLoc &line)
 {
-    TIntermAggregate *aggregateArguments = arguments->getAsAggregate();
+	TIntermAggregate *aggregateArguments = arguments->getAsAggregate();
 
-    if(!aggregateArguments)
-    {
-        aggregateArguments = new TIntermAggregate;
-        aggregateArguments->getSequence().push_back(arguments);
-    }
+	if(!aggregateArguments)
+	{
+		aggregateArguments = new TIntermAggregate;
+		aggregateArguments->getSequence().push_back(arguments);
+	}
 
-    if(op == EOpConstructStruct)
-    {
-        const TFieldList &fields = type->getStruct()->fields();
-        TIntermSequence &args = aggregateArguments->getSequence();
+	if(op == EOpConstructStruct)
+	{
+		const TFieldList &fields = type->getStruct()->fields();
+		TIntermSequence &args = aggregateArguments->getSequence();
 
-        for(size_t i = 0; i < fields.size(); i++)
-        {
-            if(args[i]->getAsTyped()->getType() != *fields[i]->type())
-            {
-                error(line, "Structure constructor arguments do not match structure fields", "Error");
-                recover();
+		for(size_t i = 0; i < fields.size(); i++)
+		{
+			if(args[i]->getAsTyped()->getType() != *fields[i]->type())
+			{
+				error(line, "Structure constructor arguments do not match structure fields", "Error");
+				recover();
 
-                return 0;
-            }
-        }
-    }
+				return 0;
+			}
+		}
+	}
 
-    // Turn the argument list itself into a constructor
-    TIntermAggregate *constructor = intermediate.setAggregateOperator(aggregateArguments, op, line);
-    TIntermTyped *constConstructor = foldConstConstructor(constructor, *type);
-    if(constConstructor)
-    {
-        return constConstructor;
-    }
+	// Turn the argument list itself into a constructor
+	TIntermAggregate *constructor = intermediate.setAggregateOperator(aggregateArguments, op, line);
+	TIntermTyped *constConstructor = foldConstConstructor(constructor, *type);
+	if(constConstructor)
+	{
+		return constConstructor;
+	}
 
-    return constructor;
+	return constructor;
 }
 
 TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, const TType& type)
 {
-    aggrNode->setType(type);
-    if (aggrNode->isConstantFoldable()) {
-        bool returnVal = false;
-        ConstantUnion* unionArray = new ConstantUnion[type.getObjectSize()];
-        if (aggrNode->getSequence().size() == 1)  {
-            returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), type, true);
-        }
-        else {
-            returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), type);
-        }
-        if (returnVal)
-            return 0;
+	aggrNode->setType(type);
+	if (aggrNode->isConstantFoldable()) {
+		bool returnVal = false;
+		ConstantUnion* unionArray = new ConstantUnion[type.getObjectSize()];
+		if (aggrNode->getSequence().size() == 1)  {
+			returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), type, true);
+		}
+		else {
+			returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), type);
+		}
+		if (returnVal)
+			return 0;
 
-        return intermediate.addConstantUnion(unionArray, type, aggrNode->getLine());
-    }
+		return intermediate.addConstantUnion(unionArray, type, aggrNode->getLine());
+	}
 
-    return 0;
+	return 0;
 }
 
 //
@@ -2128,40 +2136,40 @@
 //
 TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTyped* node, const TSourceLoc &line)
 {
-    TIntermTyped* typedNode;
-    TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
+	TIntermTyped* typedNode;
+	TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
 
-    ConstantUnion *unionArray;
-    if (tempConstantNode) {
-        unionArray = tempConstantNode->getUnionArrayPointer();
+	ConstantUnion *unionArray;
+	if (tempConstantNode) {
+		unionArray = tempConstantNode->getUnionArrayPointer();
 
-        if (!unionArray) {
-            return node;
-        }
-    } else { // The node has to be either a symbol node or an aggregate node or a tempConstant node, else, its an error
-        error(line, "Cannot offset into the vector", "Error");
-        recover();
+		if (!unionArray) {
+			return node;
+		}
+	} else { // The node has to be either a symbol node or an aggregate node or a tempConstant node, else, its an error
+		error(line, "Cannot offset into the vector", "Error");
+		recover();
 
-        return 0;
-    }
+		return 0;
+	}
 
-    ConstantUnion* constArray = new ConstantUnion[fields.num];
+	ConstantUnion* constArray = new ConstantUnion[fields.num];
 
-    for (int i = 0; i < fields.num; i++) {
-        if (fields.offsets[i] >= node->getType().getObjectSize()) {
-            std::stringstream extraInfoStream;
-            extraInfoStream << "vector field selection out of range '" << fields.offsets[i] << "'";
-            std::string extraInfo = extraInfoStream.str();
-            error(line, "", "[", extraInfo.c_str());
-            recover();
-            fields.offsets[i] = 0;
-        }
+	for (int i = 0; i < fields.num; i++) {
+		if (fields.offsets[i] >= node->getType().getObjectSize()) {
+			std::stringstream extraInfoStream;
+			extraInfoStream << "vector field selection out of range '" << fields.offsets[i] << "'";
+			std::string extraInfo = extraInfoStream.str();
+			error(line, "", "[", extraInfo.c_str());
+			recover();
+			fields.offsets[i] = 0;
+		}
 
-        constArray[i] = unionArray[fields.offsets[i]];
+		constArray[i] = unionArray[fields.offsets[i]];
 
-    }
-    typedNode = intermediate.addConstantUnion(constArray, node->getType(), line);
-    return typedNode;
+	}
+	typedNode = intermediate.addConstantUnion(constArray, node->getType(), line);
+	return typedNode;
 }
 
 //
@@ -2172,30 +2180,30 @@
 //
 TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, const TSourceLoc &line)
 {
-    TIntermTyped* typedNode;
-    TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
+	TIntermTyped* typedNode;
+	TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
 
-    if (index >= node->getType().getNominalSize()) {
-        std::stringstream extraInfoStream;
-        extraInfoStream << "matrix field selection out of range '" << index << "'";
-        std::string extraInfo = extraInfoStream.str();
-        error(line, "", "[", extraInfo.c_str());
-        recover();
-        index = 0;
-    }
+	if (index >= node->getType().getNominalSize()) {
+		std::stringstream extraInfoStream;
+		extraInfoStream << "matrix field selection out of range '" << index << "'";
+		std::string extraInfo = extraInfoStream.str();
+		error(line, "", "[", extraInfo.c_str());
+		recover();
+		index = 0;
+	}
 
-    if (tempConstantNode) {
-         ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
-         int size = tempConstantNode->getType().getNominalSize();
-         typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line);
-    } else {
-        error(line, "Cannot offset into the matrix", "Error");
-        recover();
+	if (tempConstantNode) {
+		 ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
+		 int size = tempConstantNode->getType().getNominalSize();
+		 typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line);
+	} else {
+		error(line, "Cannot offset into the matrix", "Error");
+		recover();
 
-        return 0;
-    }
+		return 0;
+	}
 
-    return typedNode;
+	return typedNode;
 }
 
 
@@ -2207,33 +2215,33 @@
 //
 TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc &line)
 {
-    TIntermTyped* typedNode;
-    TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
-    TType arrayElementType = node->getType();
-    arrayElementType.clearArrayness();
+	TIntermTyped* typedNode;
+	TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
+	TType arrayElementType = node->getType();
+	arrayElementType.clearArrayness();
 
-    if (index >= node->getType().getArraySize()) {
-        std::stringstream extraInfoStream;
-        extraInfoStream << "array field selection out of range '" << index << "'";
-        std::string extraInfo = extraInfoStream.str();
-        error(line, "", "[", extraInfo.c_str());
-        recover();
-        index = 0;
-    }
+	if (index >= node->getType().getArraySize()) {
+		std::stringstream extraInfoStream;
+		extraInfoStream << "array field selection out of range '" << index << "'";
+		std::string extraInfo = extraInfoStream.str();
+		error(line, "", "[", extraInfo.c_str());
+		recover();
+		index = 0;
+	}
 
-    size_t arrayElementSize = arrayElementType.getObjectSize();
+	size_t arrayElementSize = arrayElementType.getObjectSize();
 
-    if (tempConstantNode) {
-         ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
-         typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), line);
-    } else {
-        error(line, "Cannot offset into the array", "Error");
-        recover();
+	if (tempConstantNode) {
+		 ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
+		 typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), line);
+	} else {
+		error(line, "Cannot offset into the array", "Error");
+		recover();
 
-        return 0;
-    }
+		return 0;
+	}
 
-    return typedNode;
+	return typedNode;
 }
 
 
@@ -2244,38 +2252,38 @@
 //
 TIntermTyped* TParseContext::addConstStruct(const TString& identifier, TIntermTyped* node, const TSourceLoc &line)
 {
-    const TFieldList &fields = node->getType().getStruct()->fields();
-    TIntermTyped *typedNode;
-    size_t instanceSize = 0;
-    TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion();
+	const TFieldList &fields = node->getType().getStruct()->fields();
+	TIntermTyped *typedNode;
+	size_t instanceSize = 0;
+	TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion();
 
-    for(size_t index = 0; index < fields.size(); ++index) {
-        if (fields[index]->name() == identifier) {
-            break;
-        } else {
-            instanceSize += fields[index]->type()->getObjectSize();
-        }
-    }
+	for(size_t index = 0; index < fields.size(); ++index) {
+		if (fields[index]->name() == identifier) {
+			break;
+		} else {
+			instanceSize += fields[index]->type()->getObjectSize();
+		}
+	}
 
-    if (tempConstantNode) {
-         ConstantUnion* constArray = tempConstantNode->getUnionArrayPointer();
+	if (tempConstantNode) {
+		 ConstantUnion* constArray = tempConstantNode->getUnionArrayPointer();
 
-         typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), line); // type will be changed in the calling function
-    } else {
-        error(line, "Cannot offset into the structure", "Error");
-        recover();
+		 typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), line); // type will be changed in the calling function
+	} else {
+		error(line, "Cannot offset into the structure", "Error");
+		recover();
 
-        return 0;
-    }
+		return 0;
+	}
 
-    return typedNode;
+	return typedNode;
 }
 
 //
 // Interface/uniform blocks
 //
 TIntermAggregate* TParseContext::addInterfaceBlock(const TPublicType& typeQualifier, const TSourceLoc& nameLine, const TString& blockName, TFieldList* fieldList,
-                                                   const TString* instanceName, const TSourceLoc& instanceLine, TIntermTyped* arrayIndex, const TSourceLoc& arrayIndexLine)
+												   const TString* instanceName, const TSourceLoc& instanceLine, TIntermTyped* arrayIndex, const TSourceLoc& arrayIndexLine)
 {
 	if(reservedErrorCheck(nameLine, blockName))
 		recover();
@@ -2357,7 +2365,7 @@
 
 	// add array index
 	int arraySize = 0;
-	if(arrayIndex != NULL)
+	if(arrayIndex)
 	{
 		if(arraySizeErrorCheck(arrayIndexLine, arrayIndex, arraySize))
 			recover();
@@ -2416,7 +2424,7 @@
 //
 TIntermTyped *TParseContext::addIndexExpression(TIntermTyped *baseExpression, const TSourceLoc &location, TIntermTyped *indexExpression)
 {
-	TIntermTyped *indexedExpression = NULL;
+	TIntermTyped *indexedExpression = nullptr;
 
 	if(!baseExpression->isArray() && !baseExpression->isMatrix() && !baseExpression->isVector())
 	{
@@ -2576,7 +2584,7 @@
 TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpression, const TSourceLoc &dotLocation,
 	const TString &fieldString, const TSourceLoc &fieldLocation)
 {
-	TIntermTyped *indexedExpression = NULL;
+	TIntermTyped *indexedExpression = nullptr;
 
 	if(baseExpression->isArray())
 	{
@@ -2769,9 +2777,9 @@
 
 TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine)
 {
-    TLayoutQualifier qualifier;
+	TLayoutQualifier qualifier;
 
-    qualifier.location = -1;
+	qualifier.location = -1;
 	qualifier.matrixPacking = EmpUnspecified;
 	qualifier.blockStorage = EbsUnspecified;
 
@@ -2796,57 +2804,57 @@
 		qualifier.matrixPacking = EmpColumnMajor;
 	}
 	else if(qualifierType == "location")
-    {
-        error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str(), "location requires an argument");
-        recover();
-    }
-    else
-    {
-        error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str());
-        recover();
-    }
+	{
+		error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str(), "location requires an argument");
+		recover();
+	}
+	else
+	{
+		error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str());
+		recover();
+	}
 
-    return qualifier;
+	return qualifier;
 }
 
 TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine, const TString &intValueString, int intValue, const TSourceLoc& intValueLine)
 {
-    TLayoutQualifier qualifier;
+	TLayoutQualifier qualifier;
 
-    qualifier.location = -1;
-    qualifier.matrixPacking = EmpUnspecified;
-    qualifier.blockStorage = EbsUnspecified;
+	qualifier.location = -1;
+	qualifier.matrixPacking = EmpUnspecified;
+	qualifier.blockStorage = EbsUnspecified;
 
-    if (qualifierType != "location")
-    {
-        error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str(), "only location may have arguments");
-        recover();
-    }
-    else
-    {
-        // must check that location is non-negative
-        if (intValue < 0)
-        {
-            error(intValueLine, "out of range:", intValueString.c_str(), "location must be non-negative");
-            recover();
-        }
-        else
-        {
-            qualifier.location = intValue;
-        }
-    }
+	if (qualifierType != "location")
+	{
+		error(qualifierTypeLine, "invalid layout qualifier", qualifierType.c_str(), "only location may have arguments");
+		recover();
+	}
+	else
+	{
+		// must check that location is non-negative
+		if (intValue < 0)
+		{
+			error(intValueLine, "out of range:", intValueString.c_str(), "location must be non-negative");
+			recover();
+		}
+		else
+		{
+			qualifier.location = intValue;
+		}
+	}
 
-    return qualifier;
+	return qualifier;
 }
 
 TLayoutQualifier TParseContext::joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier)
 {
-    TLayoutQualifier joinedQualifier = leftQualifier;
+	TLayoutQualifier joinedQualifier = leftQualifier;
 
-    if (rightQualifier.location != -1)
-    {
-        joinedQualifier.location = rightQualifier.location;
-    }
+	if (rightQualifier.location != -1)
+	{
+		joinedQualifier.location = rightQualifier.location;
+	}
 	if(rightQualifier.matrixPacking != EmpUnspecified)
 	{
 		joinedQualifier.matrixPacking = rightQualifier.matrixPacking;
@@ -2856,7 +2864,7 @@
 		joinedQualifier.blockStorage = rightQualifier.blockStorage;
 	}
 
-    return joinedQualifier;
+	return joinedQualifier;
 }
 
 
@@ -2999,22 +3007,22 @@
 
 bool TParseContext::enterStructDeclaration(const TSourceLoc &line, const TString& identifier)
 {
-    ++mStructNestingLevel;
+	++mStructNestingLevel;
 
-    // Embedded structure definitions are not supported per GLSL ES spec.
-    // They aren't allowed in GLSL either, but we need to detect this here
-    // so we don't rely on the GLSL compiler to catch it.
-    if (mStructNestingLevel > 1) {
-        error(line, "", "Embedded struct definitions are not allowed");
-        return true;
-    }
+	// Embedded structure definitions are not supported per GLSL ES spec.
+	// They aren't allowed in GLSL either, but we need to detect this here
+	// so we don't rely on the GLSL compiler to catch it.
+	if (mStructNestingLevel > 1) {
+		error(line, "", "Embedded struct definitions are not allowed");
+		return true;
+	}
 
-    return false;
+	return false;
 }
 
 void TParseContext::exitStructDeclaration()
 {
-    --mStructNestingLevel;
+	--mStructNestingLevel;
 }
 
 bool TParseContext::structNestingErrorCheck(const TSourceLoc &line, const TField &field)
@@ -3663,20 +3671,20 @@
 // Returns 0 for success.
 //
 int PaParseStrings(int count, const char* const string[], const int length[],
-                   TParseContext* context) {
-    if ((count == 0) || (string == NULL))
-        return 1;
+				   TParseContext* context) {
+	if ((count == 0) || !string)
+		return 1;
 
-    if (glslang_initialize(context))
-        return 1;
+	if (glslang_initialize(context))
+		return 1;
 
-    int error = glslang_scan(count, string, length, context);
-    if (!error)
-        error = glslang_parse(context);
+	int error = glslang_scan(count, string, length, context);
+	if (!error)
+		error = glslang_parse(context);
 
-    glslang_finalize(context);
+	glslang_finalize(context);
 
-    return (error == 0) && (context->numErrors() == 0) ? 0 : 1;
+	return (error == 0) && (context->numErrors() == 0) ? 0 : 1;
 }