Commit 3ec75686 by Olli Etuaho

Collect AST transform utilities to a separate file

Collect static functions that are used to create nodes in AST transformations into a single file. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I6f87422988fa088f2f4b48986e378a2909705cb7
parent 84db5733
...@@ -75,10 +75,10 @@ ...@@ -75,10 +75,10 @@
'compiler/translator/IntermNode.cpp', 'compiler/translator/IntermNode.cpp',
'compiler/translator/IntermNodePatternMatcher.cpp', 'compiler/translator/IntermNodePatternMatcher.cpp',
'compiler/translator/IntermNodePatternMatcher.h', 'compiler/translator/IntermNodePatternMatcher.h',
'compiler/translator/IntermNode_util.cpp',
'compiler/translator/IntermNode_util.h',
'compiler/translator/IntermTraverse.cpp', 'compiler/translator/IntermTraverse.cpp',
'compiler/translator/IntermTraverse.h', 'compiler/translator/IntermTraverse.h',
'compiler/translator/Intermediate.h',
'compiler/translator/Intermediate.cpp',
'compiler/translator/IsASTDepthBelowLimit.cpp', 'compiler/translator/IsASTDepthBelowLimit.cpp',
'compiler/translator/IsASTDepthBelowLimit.h', 'compiler/translator/IsASTDepthBelowLimit.h',
'compiler/translator/NodeSearch.h', 'compiler/translator/NodeSearch.h',
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "compiler/translator/AddDefaultReturnStatements.h" #include "compiler/translator/AddDefaultReturnStatements.h"
#include "compiler/translator/IntermNode.h" #include "compiler/translator/IntermNode.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/util.h" #include "compiler/translator/util.h"
namespace sh namespace sh
...@@ -46,8 +47,7 @@ void AddDefaultReturnStatements(TIntermBlock *root) ...@@ -46,8 +47,7 @@ void AddDefaultReturnStatements(TIntermBlock *root)
TIntermFunctionDefinition *definition = node->getAsFunctionDefinition(); TIntermFunctionDefinition *definition = node->getAsFunctionDefinition();
if (definition != nullptr && NeedsReturnStatement(definition, &returnType)) if (definition != nullptr && NeedsReturnStatement(definition, &returnType))
{ {
TIntermBranch *branch = TIntermBranch *branch = new TIntermBranch(EOpReturn, CreateZeroNode(returnType));
new TIntermBranch(EOpReturn, TIntermTyped::CreateZero(returnType));
TIntermBlock *bodyNode = definition->getBody(); TIntermBlock *bodyNode = definition->getBody();
bodyNode->getSequence()->push_back(branch); bodyNode->getSequence()->push_back(branch);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "BreakVariableAliasingInInnerLoops.h" #include "BreakVariableAliasingInInnerLoops.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
// A HLSL compiler developer gave us more details on the root cause and the workaround needed: // A HLSL compiler developer gave us more details on the root cause and the workaround needed:
...@@ -68,7 +69,7 @@ class AliasingBreaker : public TIntermTraverser ...@@ -68,7 +69,7 @@ class AliasingBreaker : public TIntermTraverser
// to // to
// A = (B + typeof<B>(0)); // A = (B + typeof<B>(0));
TIntermBinary *bPlusZero = new TIntermBinary(EOpAdd, B, TIntermTyped::CreateZero(type)); TIntermBinary *bPlusZero = new TIntermBinary(EOpAdd, B, CreateZeroNode(type));
bPlusZero->setLine(B->getLine()); bPlusZero->setLine(B->getLine());
binary->replaceChildNode(B, bPlusZero); binary->replaceChildNode(B, bPlusZero);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "compiler/translator/EmulateGLFragColorBroadcast.h" #include "compiler/translator/EmulateGLFragColorBroadcast.h"
#include "compiler/translator/FindMain.h" #include "compiler/translator/FindMain.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
namespace sh namespace sh
...@@ -53,7 +54,7 @@ TIntermBinary *GLFragColorBroadcastTraverser::constructGLFragDataNode(int index) ...@@ -53,7 +54,7 @@ TIntermBinary *GLFragColorBroadcastTraverser::constructGLFragDataNode(int index)
gl_FragDataType.setArraySize(mMaxDrawBuffers); gl_FragDataType.setArraySize(mMaxDrawBuffers);
TIntermSymbol *symbol = new TIntermSymbol(0, "gl_FragData", gl_FragDataType); TIntermSymbol *symbol = new TIntermSymbol(0, "gl_FragData", gl_FragDataType);
TIntermTyped *indexNode = TIntermTyped::CreateIndexNode(index); TIntermTyped *indexNode = CreateIndexNode(index);
TIntermBinary *binary = new TIntermBinary(EOpIndexDirect, symbol, indexNode); TIntermBinary *binary = new TIntermBinary(EOpIndexDirect, symbol, indexNode);
return binary; return binary;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "angle_gl.h" #include "angle_gl.h"
#include "common/debug.h" #include "common/debug.h"
#include "compiler/translator/FindMain.h" #include "compiler/translator/FindMain.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/translator/util.h" #include "compiler/translator/util.h"
...@@ -29,7 +30,7 @@ void AddArrayZeroInitSequence(const TIntermTyped *initializedNode, ...@@ -29,7 +30,7 @@ void AddArrayZeroInitSequence(const TIntermTyped *initializedNode,
TIntermBinary *CreateZeroInitAssignment(const TIntermTyped *initializedNode) TIntermBinary *CreateZeroInitAssignment(const TIntermTyped *initializedNode)
{ {
TIntermTyped *zero = TIntermTyped::CreateZero(initializedNode->getType()); TIntermTyped *zero = CreateZeroNode(initializedNode->getType());
return new TIntermBinary(EOpAssign, initializedNode->deepCopy(), zero); return new TIntermBinary(EOpAssign, initializedNode->deepCopy(), zero);
} }
...@@ -40,8 +41,8 @@ void AddStructZeroInitSequence(const TIntermTyped *initializedNode, ...@@ -40,8 +41,8 @@ void AddStructZeroInitSequence(const TIntermTyped *initializedNode,
TStructure *structType = initializedNode->getType().getStruct(); TStructure *structType = initializedNode->getType().getStruct();
for (int i = 0; i < static_cast<int>(structType->fields().size()); ++i) for (int i = 0; i < static_cast<int>(structType->fields().size()); ++i)
{ {
TIntermBinary *element = new TIntermBinary( TIntermBinary *element = new TIntermBinary(EOpIndexDirectStruct,
EOpIndexDirectStruct, initializedNode->deepCopy(), TIntermTyped::CreateIndexNode(i)); initializedNode->deepCopy(), CreateIndexNode(i));
if (element->isArray()) if (element->isArray())
{ {
AddArrayZeroInitSequence(element, initSequenceOut); AddArrayZeroInitSequence(element, initSequenceOut);
...@@ -69,8 +70,8 @@ void AddArrayZeroInitSequence(const TIntermTyped *initializedNode, TIntermSequen ...@@ -69,8 +70,8 @@ void AddArrayZeroInitSequence(const TIntermTyped *initializedNode, TIntermSequen
// http://crbug.com/709317 // http://crbug.com/709317
for (unsigned int i = 0; i < initializedNode->getArraySize(); ++i) for (unsigned int i = 0; i < initializedNode->getArraySize(); ++i)
{ {
TIntermBinary *element = new TIntermBinary(EOpIndexDirect, initializedNode->deepCopy(), TIntermBinary *element =
TIntermTyped::CreateIndexNode(i)); new TIntermBinary(EOpIndexDirect, initializedNode->deepCopy(), CreateIndexNode(i));
if (element->getType().isStructureContainingArrays()) if (element->getType().isStructureContainingArrays())
{ {
AddStructZeroInitSequence(element, initSequenceOut); AddStructZeroInitSequence(element, initSequenceOut);
...@@ -175,8 +176,8 @@ class InitializeLocalsTraverser : public TIntermTraverser ...@@ -175,8 +176,8 @@ class InitializeLocalsTraverser : public TIntermTraverser
} }
else else
{ {
TIntermBinary *init = new TIntermBinary( TIntermBinary *init =
EOpInitialize, symbol, TIntermTyped::CreateZero(symbol->getType())); new TIntermBinary(EOpInitialize, symbol, CreateZeroNode(symbol->getType()));
queueReplacementWithParent(node, symbol, init, OriginalNode::BECOMES_CHILD); queueReplacementWithParent(node, symbol, init, OriginalNode::BECOMES_CHILD);
} }
} }
......
...@@ -558,105 +558,6 @@ bool TIntermTyped::isConstructorWithOnlyConstantUnionParameters() ...@@ -558,105 +558,6 @@ bool TIntermTyped::isConstructorWithOnlyConstantUnionParameters()
return true; return true;
} }
// static
TIntermTyped *TIntermTyped::CreateIndexNode(int index)
{
TConstantUnion *u = new TConstantUnion[1];
u[0].setIConst(index);
TType type(EbtInt, EbpUndefined, EvqConst, 1);
TIntermConstantUnion *node = new TIntermConstantUnion(u, type);
return node;
}
// static
TIntermTyped *TIntermTyped::CreateZero(const TType &type)
{
TType constType(type);
constType.setQualifier(EvqConst);
if (!type.isArray() && type.getBasicType() != EbtStruct)
{
size_t size = constType.getObjectSize();
TConstantUnion *u = new TConstantUnion[size];
for (size_t i = 0; i < size; ++i)
{
switch (type.getBasicType())
{
case EbtFloat:
u[i].setFConst(0.0f);
break;
case EbtInt:
u[i].setIConst(0);
break;
case EbtUInt:
u[i].setUConst(0u);
break;
case EbtBool:
u[i].setBConst(false);
break;
default:
// CreateZero is called by ParseContext that keeps parsing even when an error
// occurs, so it is possible for CreateZero to be called with non-basic types.
// This happens only on error condition but CreateZero needs to return a value
// with the correct type to continue the typecheck. That's why we handle
// non-basic type by setting whatever value, we just need the type to be right.
u[i].setIConst(42);
break;
}
}
TIntermConstantUnion *node = new TIntermConstantUnion(u, constType);
return node;
}
if (type.getBasicType() == EbtVoid)
{
// Void array. This happens only on error condition, similarly to the case above. We don't
// have a constructor operator for void, so this needs special handling. We'll end up with a
// value without the array type, but that should not be a problem.
constType.clearArrayness();
return CreateZero(constType);
}
TIntermSequence *arguments = new TIntermSequence();
if (type.isArray())
{
TType elementType(type);
elementType.clearArrayness();
size_t arraySize = type.getArraySize();
for (size_t i = 0; i < arraySize; ++i)
{
arguments->push_back(CreateZero(elementType));
}
}
else
{
ASSERT(type.getBasicType() == EbtStruct);
TStructure *structure = type.getStruct();
for (const auto &field : structure->fields())
{
arguments->push_back(CreateZero(*field->type()));
}
}
return TIntermAggregate::CreateConstructor(constType, arguments);
}
// static
TIntermTyped *TIntermTyped::CreateBool(bool value)
{
TConstantUnion *u = new TConstantUnion[1];
u[0].setBConst(value);
TType type(EbtBool, EbpUndefined, EvqConst, 1);
TIntermConstantUnion *node = new TIntermConstantUnion(u, type);
return node;
}
TIntermConstantUnion::TIntermConstantUnion(const TIntermConstantUnion &node) : TIntermTyped(node) TIntermConstantUnion::TIntermConstantUnion(const TIntermConstantUnion &node) : TIntermTyped(node)
{ {
mUnionArrayPointer = node.mUnionArrayPointer; mUnionArrayPointer = node.mUnionArrayPointer;
......
...@@ -180,10 +180,6 @@ class TIntermTyped : public TIntermNode ...@@ -180,10 +180,6 @@ class TIntermTyped : public TIntermNode
bool isConstructorWithOnlyConstantUnionParameters(); bool isConstructorWithOnlyConstantUnionParameters();
static TIntermTyped *CreateIndexNode(int index);
static TIntermTyped *CreateZero(const TType &type);
static TIntermTyped *CreateBool(bool value);
protected: protected:
TType mType; TType mType;
......
//
// Copyright (c) 2017 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.
//
// IntermNode_util.cpp: High-level utilities for creating AST nodes and node hierarchies. Mostly
// meant to be used in AST transforms.
#include "compiler/translator/IntermNode_util.h"
namespace sh
{
namespace
{
TName GetInternalFunctionName(const char *name)
{
TString nameStr(name);
TName nameObj(nameStr);
nameObj.setInternal(true);
return nameObj;
}
} // anonymous namespace
TIntermFunctionPrototype *CreateInternalFunctionPrototypeNode(const TType &returnType,
const char *name,
const TSymbolUniqueId &functionId)
{
TIntermFunctionPrototype *functionNode = new TIntermFunctionPrototype(returnType, functionId);
functionNode->getFunctionSymbolInfo()->setNameObj(GetInternalFunctionName(name));
return functionNode;
}
TIntermFunctionDefinition *CreateInternalFunctionDefinitionNode(const TType &returnType,
const char *name,
TIntermBlock *functionBody,
const TSymbolUniqueId &functionId)
{
TIntermFunctionPrototype *prototypeNode =
CreateInternalFunctionPrototypeNode(returnType, name, functionId);
return new TIntermFunctionDefinition(prototypeNode, functionBody);
}
TIntermAggregate *CreateInternalFunctionCallNode(const TType &returnType,
const char *name,
const TSymbolUniqueId &functionId,
TIntermSequence *arguments)
{
TIntermAggregate *functionNode = TIntermAggregate::CreateFunctionCall(
returnType, functionId, GetInternalFunctionName(name), arguments);
return functionNode;
}
TIntermTyped *CreateZeroNode(const TType &type)
{
TType constType(type);
constType.setQualifier(EvqConst);
if (!type.isArray() && type.getBasicType() != EbtStruct)
{
size_t size = constType.getObjectSize();
TConstantUnion *u = new TConstantUnion[size];
for (size_t i = 0; i < size; ++i)
{
switch (type.getBasicType())
{
case EbtFloat:
u[i].setFConst(0.0f);
break;
case EbtInt:
u[i].setIConst(0);
break;
case EbtUInt:
u[i].setUConst(0u);
break;
case EbtBool:
u[i].setBConst(false);
break;
default:
// CreateZeroNode is called by ParseContext that keeps parsing even when an
// error occurs, so it is possible for CreateZeroNode to be called with
// non-basic types. This happens only on error condition but CreateZeroNode
// needs to return a value with the correct type to continue the typecheck.
// That's why we handle non-basic type by setting whatever value, we just need
// the type to be right.
u[i].setIConst(42);
break;
}
}
TIntermConstantUnion *node = new TIntermConstantUnion(u, constType);
return node;
}
if (type.getBasicType() == EbtVoid)
{
// Void array. This happens only on error condition, similarly to the case above. We don't
// have a constructor operator for void, so this needs special handling. We'll end up with a
// value without the array type, but that should not be a problem.
constType.clearArrayness();
return CreateZeroNode(constType);
}
TIntermSequence *arguments = new TIntermSequence();
if (type.isArray())
{
TType elementType(type);
elementType.clearArrayness();
size_t arraySize = type.getArraySize();
for (size_t i = 0; i < arraySize; ++i)
{
arguments->push_back(CreateZeroNode(elementType));
}
}
else
{
ASSERT(type.getBasicType() == EbtStruct);
TStructure *structure = type.getStruct();
for (const auto &field : structure->fields())
{
arguments->push_back(CreateZeroNode(*field->type()));
}
}
return TIntermAggregate::CreateConstructor(constType, arguments);
}
TIntermConstantUnion *CreateIndexNode(int index)
{
TConstantUnion *u = new TConstantUnion[1];
u[0].setIConst(index);
TType type(EbtInt, EbpUndefined, EvqConst, 1);
TIntermConstantUnion *node = new TIntermConstantUnion(u, type);
return node;
}
TIntermConstantUnion *CreateBoolNode(bool value)
{
TConstantUnion *u = new TConstantUnion[1];
u[0].setBConst(value);
TType type(EbtBool, EbpUndefined, EvqConst, 1);
TIntermConstantUnion *node = new TIntermConstantUnion(u, type);
return node;
}
TIntermBlock *EnsureBlock(TIntermNode *node)
{
if (node == nullptr)
return nullptr;
TIntermBlock *blockNode = node->getAsBlock();
if (blockNode != nullptr)
return blockNode;
blockNode = new TIntermBlock();
blockNode->setLine(node->getLine());
blockNode->appendStatement(node);
return blockNode;
}
} // namespace sh
//
// Copyright (c) 2017 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.
//
// IntermNode_util.h: High-level utilities for creating AST nodes and node hierarchies. Mostly meant
// to be used in AST transforms.
#ifndef COMPILER_TRANSLATOR_INTERMNODEUTIL_H_
#define COMPILER_TRANSLATOR_INTERMNODEUTIL_H_
#include "compiler/translator/IntermNode.h"
namespace sh
{
TIntermFunctionPrototype *CreateInternalFunctionPrototypeNode(const TType &returnType,
const char *name,
const TSymbolUniqueId &functionId);
TIntermFunctionDefinition *CreateInternalFunctionDefinitionNode(const TType &returnType,
const char *name,
TIntermBlock *functionBody,
const TSymbolUniqueId &functionId);
TIntermAggregate *CreateInternalFunctionCallNode(const TType &returnType,
const char *name,
const TSymbolUniqueId &functionId,
TIntermSequence *arguments);
TIntermTyped *CreateZeroNode(const TType &type);
TIntermConstantUnion *CreateIndexNode(int index);
TIntermConstantUnion *CreateBoolNode(bool value);
// If the input node is nullptr, return nullptr.
// If the input node is a block node, return it.
// If the input node is not a block node, put it inside a block node and return that.
TIntermBlock *EnsureBlock(TIntermNode *node);
} // namespace sh
#endif // COMPILER_TRANSLATOR_INTERMNODEUTIL_H_
\ No newline at end of file
...@@ -713,46 +713,6 @@ void TIntermTraverser::queueReplacementWithParent(TIntermNode *parent, ...@@ -713,46 +713,6 @@ void TIntermTraverser::queueReplacementWithParent(TIntermNode *parent,
mReplacements.push_back(NodeUpdateEntry(parent, original, replacement, originalBecomesChild)); mReplacements.push_back(NodeUpdateEntry(parent, original, replacement, originalBecomesChild));
} }
TName TIntermTraverser::GetInternalFunctionName(const char *name)
{
TString nameStr(name);
TName nameObj(nameStr);
nameObj.setInternal(true);
return nameObj;
}
TIntermFunctionPrototype *TIntermTraverser::CreateInternalFunctionPrototypeNode(
const TType &returnType,
const char *name,
const TSymbolUniqueId &functionId)
{
TIntermFunctionPrototype *functionNode = new TIntermFunctionPrototype(returnType, functionId);
functionNode->getFunctionSymbolInfo()->setNameObj(GetInternalFunctionName(name));
return functionNode;
}
TIntermFunctionDefinition *TIntermTraverser::CreateInternalFunctionDefinitionNode(
const TType &returnType,
const char *name,
TIntermBlock *functionBody,
const TSymbolUniqueId &functionId)
{
TIntermFunctionPrototype *prototypeNode =
CreateInternalFunctionPrototypeNode(returnType, name, functionId);
return new TIntermFunctionDefinition(prototypeNode, functionBody);
}
TIntermAggregate *TIntermTraverser::CreateInternalFunctionCallNode(
const TType &returnType,
const char *name,
const TSymbolUniqueId &functionId,
TIntermSequence *arguments)
{
TIntermAggregate *functionNode = TIntermAggregate::CreateFunctionCall(
returnType, functionId, GetInternalFunctionName(name), arguments);
return functionNode;
}
TLValueTrackingTraverser::TLValueTrackingTraverser(bool preVisit, TLValueTrackingTraverser::TLValueTrackingTraverser(bool preVisit,
bool inVisit, bool inVisit,
bool postVisit, bool postVisit,
......
...@@ -102,20 +102,6 @@ class TIntermTraverser : angle::NonCopyable ...@@ -102,20 +102,6 @@ class TIntermTraverser : angle::NonCopyable
// Start creating temporary symbols from the given temporary symbol index + 1. // Start creating temporary symbols from the given temporary symbol index + 1.
void useTemporaryId(TSymbolUniqueId *temporaryId); void useTemporaryId(TSymbolUniqueId *temporaryId);
static TIntermFunctionPrototype *CreateInternalFunctionPrototypeNode(
const TType &returnType,
const char *name,
const TSymbolUniqueId &functionId);
static TIntermFunctionDefinition *CreateInternalFunctionDefinitionNode(
const TType &returnType,
const char *name,
TIntermBlock *functionBody,
const TSymbolUniqueId &functionId);
static TIntermAggregate *CreateInternalFunctionCallNode(const TType &returnType,
const char *name,
const TSymbolUniqueId &functionId,
TIntermSequence *arguments);
protected: protected:
// Should only be called from traverse*() functions // Should only be called from traverse*() functions
void incrementDepth(TIntermNode *current) void incrementDepth(TIntermNode *current)
...@@ -261,8 +247,6 @@ class TIntermTraverser : angle::NonCopyable ...@@ -261,8 +247,6 @@ class TIntermTraverser : angle::NonCopyable
std::vector<NodeInsertMultipleEntry> mInsertions; std::vector<NodeInsertMultipleEntry> mInsertions;
private: private:
static TName GetInternalFunctionName(const char *name);
static bool CompareInsertion(const NodeInsertMultipleEntry &a, static bool CompareInsertion(const NodeInsertMultipleEntry &a,
const NodeInsertMultipleEntry &b); const NodeInsertMultipleEntry &b);
......
//
// Copyright (c) 2002-2014 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.
//
//
// Build the intermediate representation.
//
#include <float.h>
#include <limits.h>
#include <algorithm>
#include "compiler/translator/Intermediate.h"
#include "compiler/translator/SymbolTable.h"
namespace sh
{
////////////////////////////////////////////////////////////////////////////
//
// First set of functions are to help build the intermediate representation.
// These functions are not member functions of the nodes.
// They are called from parser productions.
//
/////////////////////////////////////////////////////////////////////////////
// If the input node is nullptr, return nullptr.
// If the input node is a block node, return it.
// If the input node is not a block node, put it inside a block node and return that.
TIntermBlock *TIntermediate::EnsureBlock(TIntermNode *node)
{
if (node == nullptr)
return nullptr;
TIntermBlock *blockNode = node->getAsBlock();
if (blockNode != nullptr)
return blockNode;
blockNode = new TIntermBlock();
blockNode->setLine(node->getLine());
blockNode->appendStatement(node);
return blockNode;
}
} // namespace sh
//
// Copyright (c) 2002-2014 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.
//
#ifndef COMPILER_TRANSLATOR_INTERMEDIATE_H_
#define COMPILER_TRANSLATOR_INTERMEDIATE_H_
#include "compiler/translator/IntermNode.h"
namespace sh
{
//
// Set of helper functions to help build the tree.
// TODO(oetuaho@nvidia.com): Clean this up, it doesn't need to be a class.
//
class TIntermediate
{
public:
static TIntermBlock *EnsureBlock(TIntermNode *node);
private:
TIntermediate(){};
};
} // namespace sh
#endif // COMPILER_TRANSLATOR_INTERMEDIATE_H_
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "common/mathutil.h" #include "common/mathutil.h"
#include "compiler/preprocessor/SourceLocation.h" #include "compiler/preprocessor/SourceLocation.h"
#include "compiler/translator/Cache.h" #include "compiler/translator/Cache.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/ValidateGlobalInitializer.h" #include "compiler/translator/ValidateGlobalInitializer.h"
#include "compiler/translator/ValidateSwitch.h" #include "compiler/translator/ValidateSwitch.h"
#include "compiler/translator/glslang.h" #include "compiler/translator/glslang.h"
...@@ -1875,7 +1876,7 @@ TIntermNode *TParseContext::addLoop(TLoopType type, ...@@ -1875,7 +1876,7 @@ TIntermNode *TParseContext::addLoop(TLoopType type,
(typedCond->getBasicType() == EbtBool && !typedCond->isArray() && (typedCond->getBasicType() == EbtBool && !typedCond->isArray() &&
!typedCond->isVector())); !typedCond->isVector()));
node = new TIntermLoop(type, init, typedCond, expr, TIntermediate::EnsureBlock(body)); node = new TIntermLoop(type, init, typedCond, expr, EnsureBlock(body));
node->setLine(line); node->setLine(line);
return node; return node;
} }
...@@ -1898,8 +1899,7 @@ TIntermNode *TParseContext::addLoop(TLoopType type, ...@@ -1898,8 +1899,7 @@ TIntermNode *TParseContext::addLoop(TLoopType type,
TIntermBinary *conditionInit = new TIntermBinary(EOpAssign, declarator->getLeft()->deepCopy(), TIntermBinary *conditionInit = new TIntermBinary(EOpAssign, declarator->getLeft()->deepCopy(),
declarator->getRight()->deepCopy()); declarator->getRight()->deepCopy());
TIntermLoop *loop = TIntermLoop *loop = new TIntermLoop(type, init, conditionInit, expr, EnsureBlock(body));
new TIntermLoop(type, init, conditionInit, expr, TIntermediate::EnsureBlock(body));
block->appendStatement(loop); block->appendStatement(loop);
loop->setLine(line); loop->setLine(line);
block->setLine(line); block->setLine(line);
...@@ -1917,16 +1917,15 @@ TIntermNode *TParseContext::addIfElse(TIntermTyped *cond, ...@@ -1917,16 +1917,15 @@ TIntermNode *TParseContext::addIfElse(TIntermTyped *cond,
{ {
if (cond->getAsConstantUnion()->getBConst(0) == true) if (cond->getAsConstantUnion()->getBConst(0) == true)
{ {
return TIntermediate::EnsureBlock(code.node1); return EnsureBlock(code.node1);
} }
else else
{ {
return TIntermediate::EnsureBlock(code.node2); return EnsureBlock(code.node2);
} }
} }
TIntermIfElse *node = new TIntermIfElse(cond, TIntermediate::EnsureBlock(code.node1), TIntermIfElse *node = new TIntermIfElse(cond, EnsureBlock(code.node1), EnsureBlock(code.node2));
TIntermediate::EnsureBlock(code.node2));
node->setLine(loc); node->setLine(loc);
return node; return node;
...@@ -3084,14 +3083,14 @@ TIntermTyped *TParseContext::addConstructor(TIntermSequence *arguments, ...@@ -3084,14 +3083,14 @@ TIntermTyped *TParseContext::addConstructor(TIntermSequence *arguments,
{ {
error(line, "implicitly sized array constructor must have at least one argument", "[]"); error(line, "implicitly sized array constructor must have at least one argument", "[]");
type.setArraySize(1u); type.setArraySize(1u);
return TIntermTyped::CreateZero(type); return CreateZeroNode(type);
} }
type.setArraySize(static_cast<unsigned int>(arguments->size())); type.setArraySize(static_cast<unsigned int>(arguments->size()));
} }
if (!checkConstructorArguments(line, arguments, type)) if (!checkConstructorArguments(line, arguments, type))
{ {
return TIntermTyped::CreateZero(type); return CreateZeroNode(type);
} }
TIntermAggregate *constructorNode = TIntermAggregate::CreateConstructor(type, arguments); TIntermAggregate *constructorNode = TIntermAggregate::CreateConstructor(type, arguments);
...@@ -3350,7 +3349,7 @@ TIntermTyped *TParseContext::addIndexExpression(TIntermTyped *baseExpression, ...@@ -3350,7 +3349,7 @@ TIntermTyped *TParseContext::addIndexExpression(TIntermTyped *baseExpression,
error(location, " left of '[' is not of type array, matrix, or vector ", "expression"); error(location, " left of '[' is not of type array, matrix, or vector ", "expression");
} }
return TIntermTyped::CreateZero(TType(EbtFloat, EbpHigh, EvqConst)); return CreateZeroNode(TType(EbtFloat, EbpHigh, EvqConst));
} }
TIntermConstantUnion *indexConstantUnion = indexExpression->getAsConstantUnion(); TIntermConstantUnion *indexConstantUnion = indexExpression->getAsConstantUnion();
...@@ -3537,7 +3536,7 @@ TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre ...@@ -3537,7 +3536,7 @@ TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
} }
if (fieldFound) if (fieldFound)
{ {
TIntermTyped *index = TIntermTyped::CreateIndexNode(i); TIntermTyped *index = CreateIndexNode(i);
index->setLine(fieldLocation); index->setLine(fieldLocation);
TIntermBinary *node = TIntermBinary *node =
new TIntermBinary(EOpIndexDirectStruct, baseExpression, index); new TIntermBinary(EOpIndexDirectStruct, baseExpression, index);
...@@ -3573,7 +3572,7 @@ TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre ...@@ -3573,7 +3572,7 @@ TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
} }
if (fieldFound) if (fieldFound)
{ {
TIntermTyped *index = TIntermTyped::CreateIndexNode(i); TIntermTyped *index = CreateIndexNode(i);
index->setLine(fieldLocation); index->setLine(fieldLocation);
TIntermBinary *node = TIntermBinary *node =
new TIntermBinary(EOpIndexDirectInterfaceBlock, baseExpression, index); new TIntermBinary(EOpIndexDirectInterfaceBlock, baseExpression, index);
...@@ -4577,7 +4576,7 @@ TIntermTyped *TParseContext::addBinaryMathBooleanResult(TOperator op, ...@@ -4577,7 +4576,7 @@ TIntermTyped *TParseContext::addBinaryMathBooleanResult(TOperator op,
{ {
binaryOpError(loc, GetOperatorString(op), left->getCompleteString(), binaryOpError(loc, GetOperatorString(op), left->getCompleteString(),
right->getCompleteString()); right->getCompleteString());
node = TIntermTyped::CreateZero(TType(EbtBool, EbpUndefined, EvqConst)); node = CreateBoolNode(false);
node->setLine(loc); node->setLine(loc);
} }
return node; return node;
...@@ -5011,7 +5010,7 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(TFunction *fnCall, ...@@ -5011,7 +5010,7 @@ TIntermTyped *TParseContext::addNonConstructorFunctionCall(TFunction *fnCall,
} }
// Error message was already written. Put on a dummy node for error recovery. // Error message was already written. Put on a dummy node for error recovery.
return TIntermTyped::CreateZero(TType(EbtFloat, EbpMedium, EvqConst)); return CreateZeroNode(TType(EbtFloat, EbpMedium, EvqConst));
} }
TIntermTyped *TParseContext::addTernarySelection(TIntermTyped *cond, TIntermTyped *TParseContext::addTernarySelection(TIntermTyped *cond,
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
#include "compiler/translator/Diagnostics.h" #include "compiler/translator/Diagnostics.h"
#include "compiler/translator/DirectiveHandler.h" #include "compiler/translator/DirectiveHandler.h"
#include "compiler/translator/Intermediate.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/translator/QualifierTypes.h" #include "compiler/translator/QualifierTypes.h"
#include "compiler/preprocessor/Preprocessor.h" #include "compiler/preprocessor/Preprocessor.h"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "compiler/translator/InfoSink.h" #include "compiler/translator/InfoSink.h"
#include "compiler/translator/IntermNodePatternMatcher.h" #include "compiler/translator/IntermNodePatternMatcher.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
...@@ -94,7 +95,7 @@ TIntermBinary *CreateIndexDirectBaseSymbolNode(const TType &indexedType, ...@@ -94,7 +95,7 @@ TIntermBinary *CreateIndexDirectBaseSymbolNode(const TType &indexedType,
{ {
TIntermSymbol *baseSymbol = CreateBaseSymbol(indexedType, baseQualifier); TIntermSymbol *baseSymbol = CreateBaseSymbol(indexedType, baseQualifier);
TIntermBinary *indexNode = TIntermBinary *indexNode =
new TIntermBinary(EOpIndexDirect, baseSymbol, TIntermTyped::CreateIndexNode(index)); new TIntermBinary(EOpIndexDirect, baseSymbol, CreateIndexNode(index));
return indexNode; return indexNode;
} }
...@@ -199,8 +200,8 @@ TIntermFunctionDefinition *GetIndexFunctionDefinition(TType type, ...@@ -199,8 +200,8 @@ TIntermFunctionDefinition *GetIndexFunctionDefinition(TType type,
} }
std::string functionName = GetIndexFunctionName(type, write); std::string functionName = GetIndexFunctionName(type, write);
TIntermFunctionPrototype *prototypeNode = TIntermTraverser::CreateInternalFunctionPrototypeNode( TIntermFunctionPrototype *prototypeNode =
returnType, functionName.c_str(), functionId); CreateInternalFunctionPrototypeNode(returnType, functionName.c_str(), functionId);
TQualifier baseQualifier = EvqInOut; TQualifier baseQualifier = EvqInOut;
if (!write) if (!write)
...@@ -352,8 +353,8 @@ TIntermAggregate *CreateIndexFunctionCall(TIntermBinary *node, ...@@ -352,8 +353,8 @@ TIntermAggregate *CreateIndexFunctionCall(TIntermBinary *node,
TType fieldType = GetFieldType(node->getLeft()->getType()); TType fieldType = GetFieldType(node->getLeft()->getType());
std::string functionName = GetIndexFunctionName(node->getLeft()->getType(), false); std::string functionName = GetIndexFunctionName(node->getLeft()->getType(), false);
TIntermAggregate *indexingCall = TIntermTraverser::CreateInternalFunctionCallNode( TIntermAggregate *indexingCall =
fieldType, functionName.c_str(), functionId, arguments); CreateInternalFunctionCallNode(fieldType, functionName.c_str(), functionId, arguments);
indexingCall->setLine(node->getLine()); indexingCall->setLine(node->getLine());
indexingCall->getFunctionSymbolInfo()->setKnownToNotHaveSideEffects(true); indexingCall->getFunctionSymbolInfo()->setKnownToNotHaveSideEffects(true);
return indexingCall; return indexingCall;
...@@ -372,8 +373,8 @@ TIntermAggregate *CreateIndexedWriteFunctionCall(TIntermBinary *node, ...@@ -372,8 +373,8 @@ TIntermAggregate *CreateIndexedWriteFunctionCall(TIntermBinary *node,
arguments->push_back(writtenValue); arguments->push_back(writtenValue);
std::string functionName = GetIndexFunctionName(node->getLeft()->getType(), true); std::string functionName = GetIndexFunctionName(node->getLeft()->getType(), true);
TIntermAggregate *indexedWriteCall = TIntermTraverser::CreateInternalFunctionCallNode( TIntermAggregate *indexedWriteCall =
TType(EbtVoid), functionName.c_str(), functionId, arguments); CreateInternalFunctionCallNode(TType(EbtVoid), functionName.c_str(), functionId, arguments);
indexedWriteCall->setLine(node->getLine()); indexedWriteCall->setLine(node->getLine());
return indexedWriteCall; return indexedWriteCall;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "compiler/translator/RewriteElseBlocks.h" #include "compiler/translator/RewriteElseBlocks.h"
#include "compiler/translator/Intermediate.h" #include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/NodeSearch.h" #include "compiler/translator/NodeSearch.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
...@@ -84,8 +84,7 @@ TIntermNode *ElseBlockRewriter::rewriteIfElse(TIntermIfElse *ifElse) ...@@ -84,8 +84,7 @@ TIntermNode *ElseBlockRewriter::rewriteIfElse(TIntermIfElse *ifElse)
// returns (that are unreachable) we can silence this compile error. // returns (that are unreachable) we can silence this compile error.
if (mFunctionType && mFunctionType->getBasicType() != EbtVoid) if (mFunctionType && mFunctionType->getBasicType() != EbtVoid)
{ {
TIntermNode *returnNode = TIntermNode *returnNode = new TIntermBranch(EOpReturn, CreateZeroNode(*mFunctionType));
new TIntermBranch(EOpReturn, TIntermTyped::CreateZero(*mFunctionType));
negatedElse = new TIntermBlock(); negatedElse = new TIntermBlock();
negatedElse->appendStatement(returnNode); negatedElse->appendStatement(returnNode);
} }
...@@ -94,7 +93,7 @@ TIntermNode *ElseBlockRewriter::rewriteIfElse(TIntermIfElse *ifElse) ...@@ -94,7 +93,7 @@ TIntermNode *ElseBlockRewriter::rewriteIfElse(TIntermIfElse *ifElse)
TIntermUnary *negatedCondition = new TIntermUnary(EOpLogicalNot, conditionSymbolElse); TIntermUnary *negatedCondition = new TIntermUnary(EOpLogicalNot, conditionSymbolElse);
TIntermIfElse *falseIfElse = TIntermIfElse *falseIfElse =
new TIntermIfElse(negatedCondition, ifElse->getFalseBlock(), negatedElse); new TIntermIfElse(negatedCondition, ifElse->getFalseBlock(), negatedElse);
falseBlock = TIntermediate::EnsureBlock(falseIfElse); falseBlock = EnsureBlock(falseIfElse);
} }
TIntermSymbol *conditionSymbolSel = createTempSymbol(boolType); TIntermSymbol *conditionSymbolSel = createTempSymbol(boolType);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "compiler/translator/RewriteTexelFetchOffset.h" #include "compiler/translator/RewriteTexelFetchOffset.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
...@@ -107,7 +108,7 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -107,7 +108,7 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
TIntermSequence *constructOffsetIvecArguments = new TIntermSequence(); TIntermSequence *constructOffsetIvecArguments = new TIntermSequence();
constructOffsetIvecArguments->push_back(sequence->at(3)->getAsTyped()); constructOffsetIvecArguments->push_back(sequence->at(3)->getAsTyped());
TIntermTyped *zeroNode = TIntermTyped::CreateZero(TType(EbtInt)); TIntermTyped *zeroNode = CreateZeroNode(TType(EbtInt));
constructOffsetIvecArguments->push_back(zeroNode); constructOffsetIvecArguments->push_back(zeroNode);
offsetNode = TIntermAggregate::CreateConstructor(texCoordNode->getType(), offsetNode = TIntermAggregate::CreateConstructor(texCoordNode->getType(),
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "compiler/translator/RewriteUnaryMinusOperatorFloat.h" #include "compiler/translator/RewriteUnaryMinusOperatorFloat.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
namespace sh namespace sh
...@@ -72,7 +73,7 @@ bool Traverser::visitUnary(Visit visit, TIntermUnary *node) ...@@ -72,7 +73,7 @@ bool Traverser::visitUnary(Visit visit, TIntermUnary *node)
} }
// 0.0 - float // 0.0 - float
TIntermTyped *zero = TIntermTyped::CreateZero(fValue->getType()); TIntermTyped *zero = CreateZeroNode(fValue->getType());
zero->setLine(fValue->getLine()); zero->setLine(fValue->getLine());
TIntermBinary *sub = new TIntermBinary(EOpSub, zero, fValue); TIntermBinary *sub = new TIntermBinary(EOpSub, zero, fValue);
sub->setLine(fValue->getLine()); sub->setLine(fValue->getLine());
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "angle_gl.h" #include "angle_gl.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
namespace sh namespace sh
...@@ -47,15 +48,14 @@ bool ContainsVectorNode(const TIntermSequence &sequence) ...@@ -47,15 +48,14 @@ bool ContainsVectorNode(const TIntermSequence &sequence)
TIntermBinary *ConstructVectorIndexBinaryNode(TIntermSymbol *symbolNode, int index) TIntermBinary *ConstructVectorIndexBinaryNode(TIntermSymbol *symbolNode, int index)
{ {
return new TIntermBinary(EOpIndexDirect, symbolNode, TIntermTyped::CreateIndexNode(index)); return new TIntermBinary(EOpIndexDirect, symbolNode, CreateIndexNode(index));
} }
TIntermBinary *ConstructMatrixIndexBinaryNode(TIntermSymbol *symbolNode, int colIndex, int rowIndex) TIntermBinary *ConstructMatrixIndexBinaryNode(TIntermSymbol *symbolNode, int colIndex, int rowIndex)
{ {
TIntermBinary *colVectorNode = ConstructVectorIndexBinaryNode(symbolNode, colIndex); TIntermBinary *colVectorNode = ConstructVectorIndexBinaryNode(symbolNode, colIndex);
return new TIntermBinary(EOpIndexDirect, colVectorNode, return new TIntermBinary(EOpIndexDirect, colVectorNode, CreateIndexNode(rowIndex));
TIntermTyped::CreateIndexNode(rowIndex));
} }
class ScalarizeArgsTraverser : public TIntermTraverser class ScalarizeArgsTraverser : public TIntermTraverser
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "compiler/translator/SimplifyLoopConditions.h" #include "compiler/translator/SimplifyLoopConditions.h"
#include "compiler/translator/IntermNodePatternMatcher.h" #include "compiler/translator/IntermNodePatternMatcher.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
namespace sh namespace sh
...@@ -19,15 +20,6 @@ namespace sh ...@@ -19,15 +20,6 @@ namespace sh
namespace namespace
{ {
TIntermConstantUnion *CreateBoolConstantNode(bool value)
{
TConstantUnion *u = new TConstantUnion;
u->setBConst(value);
TIntermConstantUnion *node =
new TIntermConstantUnion(u, TType(EbtBool, EbpUndefined, EvqConst, 1));
return node;
}
class SimplifyLoopConditionsTraverser : public TLValueTrackingTraverser class SimplifyLoopConditionsTraverser : public TLValueTrackingTraverser
{ {
public: public:
...@@ -188,7 +180,7 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node) ...@@ -188,7 +180,7 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
// s0 = expr; // s0 = expr;
// } while (s0); // } while (s0);
TIntermSequence tempInitSeq; TIntermSequence tempInitSeq;
tempInitSeq.push_back(createTempInitDeclaration(CreateBoolConstantNode(true))); tempInitSeq.push_back(createTempInitDeclaration(CreateBoolNode(true)));
insertStatementsInParentBlock(tempInitSeq); insertStatementsInParentBlock(tempInitSeq);
TIntermBlock *newBody = new TIntermBlock(); TIntermBlock *newBody = new TIntermBlock();
...@@ -237,7 +229,7 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node) ...@@ -237,7 +229,7 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
} }
else else
{ {
conditionInitializer = TIntermTyped::CreateBool(true); conditionInitializer = CreateBoolNode(true);
} }
loopScopeSequence->push_back(createTempInitDeclaration(conditionInitializer)); loopScopeSequence->push_back(createTempInitDeclaration(conditionInitializer));
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "compiler/translator/FindMain.h" #include "compiler/translator/FindMain.h"
#include "compiler/translator/IntermNode.h" #include "compiler/translator/IntermNode.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
#include "compiler/translator/util.h" #include "compiler/translator/util.h"
...@@ -55,8 +56,7 @@ void AddFieldUseStatements(const ShaderVariable &var, ...@@ -55,8 +56,7 @@ void AddFieldUseStatements(const ShaderVariable &var,
{ {
for (unsigned int i = 0; i < var.arraySize; ++i) for (unsigned int i = 0; i < var.arraySize; ++i)
{ {
TIntermBinary *element = TIntermBinary *element = new TIntermBinary(EOpIndexDirect, symbol, CreateIndexNode(i));
new TIntermBinary(EOpIndexDirect, symbol, TIntermTyped::CreateIndexNode(i));
sequence->insert(sequence->begin(), element); sequence->insert(sequence->begin(), element);
} }
} }
...@@ -87,13 +87,12 @@ void InsertUseCode(TIntermSequence *sequence, ...@@ -87,13 +87,12 @@ void InsertUseCode(TIntermSequence *sequence,
TIntermSymbol *arraySymbol = new TIntermSymbol(0, name, ubInfo->getType()); TIntermSymbol *arraySymbol = new TIntermSymbol(0, name, ubInfo->getType());
for (unsigned int i = 0; i < block.arraySize; ++i) for (unsigned int i = 0; i < block.arraySize; ++i)
{ {
TIntermBinary *instanceSymbol = new TIntermBinary(EOpIndexDirect, arraySymbol, TIntermBinary *instanceSymbol =
TIntermTyped::CreateIndexNode(i)); new TIntermBinary(EOpIndexDirect, arraySymbol, CreateIndexNode(i));
for (unsigned int j = 0; j < block.fields.size(); ++j) for (unsigned int j = 0; j < block.fields.size(); ++j)
{ {
TIntermBinary *element = TIntermBinary *element = new TIntermBinary(EOpIndexDirectInterfaceBlock,
new TIntermBinary(EOpIndexDirectInterfaceBlock, instanceSymbol, instanceSymbol, CreateIndexNode(j));
TIntermTyped::CreateIndexNode(j));
sequence->insert(sequence->begin(), element); sequence->insert(sequence->begin(), element);
} }
} }
...@@ -106,8 +105,8 @@ void InsertUseCode(TIntermSequence *sequence, ...@@ -106,8 +105,8 @@ void InsertUseCode(TIntermSequence *sequence,
TIntermSymbol *blockSymbol = new TIntermSymbol(0, name, ubInfo->getType()); TIntermSymbol *blockSymbol = new TIntermSymbol(0, name, ubInfo->getType());
for (unsigned int i = 0; i < block.fields.size(); ++i) for (unsigned int i = 0; i < block.fields.size(); ++i)
{ {
TIntermBinary *element = new TIntermBinary( TIntermBinary *element = new TIntermBinary(EOpIndexDirectInterfaceBlock,
EOpIndexDirectInterfaceBlock, blockSymbol, TIntermTyped::CreateIndexNode(i)); blockSymbol, CreateIndexNode(i));
sequence->insert(sequence->begin(), element); sequence->insert(sequence->begin(), element);
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "compiler/translator/FindMain.h" #include "compiler/translator/FindMain.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
#include "tests/test_utils/ShaderCompileTreeTest.h" #include "tests/test_utils/ShaderCompileTreeTest.h"
...@@ -77,7 +78,7 @@ ExpectedLValues CreateIndexedLValueNodeList(const TString &lValueName, ...@@ -77,7 +78,7 @@ ExpectedLValues CreateIndexedLValueNodeList(const TString &lValueName,
{ {
expected[index] = expected[index] =
new TIntermBinary(EOpIndexDirect, new TIntermSymbol(0, lValueName, elementType), new TIntermBinary(EOpIndexDirect, new TIntermSymbol(0, lValueName, elementType),
TIntermTyped::CreateIndexNode(static_cast<int>(index))); CreateIndexNode(static_cast<int>(index)));
} }
return expected; return expected;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment