Commit 95ed1947 by Olli Etuaho Committed by Commit Bot

Add a class for function lookups

Using a purpose-built class for function lookups instead of using a combination of TFunction and a struct container for the this node and arguments makes the code clearer. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I3f345d836abeaa7f84cc46b4b840fd06c7e2e1a7 Reviewed-on: https://chromium-review.googlesource.com/897363Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 5c5d7dee
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
'compiler/translator/FlagStd140Structs.h', 'compiler/translator/FlagStd140Structs.h',
'compiler/translator/FoldExpressions.cpp', 'compiler/translator/FoldExpressions.cpp',
'compiler/translator/FoldExpressions.h', 'compiler/translator/FoldExpressions.h',
'compiler/translator/FunctionLookup.cpp',
'compiler/translator/FunctionLookup.h',
'compiler/translator/HashNames.cpp', 'compiler/translator/HashNames.cpp',
'compiler/translator/HashNames.h', 'compiler/translator/HashNames.h',
'compiler/translator/ImmutableString.cpp', 'compiler/translator/ImmutableString.cpp',
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "compiler/translator/EmulatePrecision.h" #include "compiler/translator/EmulatePrecision.h"
#include "compiler/translator/FunctionLookup.h"
#include <memory> #include <memory>
namespace sh namespace sh
...@@ -713,7 +715,7 @@ const TFunction *EmulatePrecision::getInternalFunction(TString *functionName, ...@@ -713,7 +715,7 @@ const TFunction *EmulatePrecision::getInternalFunction(TString *functionName,
const TVector<TConstParameter> &parameters, const TVector<TConstParameter> &parameters,
bool knownToNotHaveSideEffects) bool knownToNotHaveSideEffects)
{ {
TString mangledName = TFunction::GetMangledNameFromCall(*functionName, *arguments); TString mangledName = TFunctionLookup::GetMangledName(*functionName, *arguments);
if (mInternalFunctions.find(mangledName) == mInternalFunctions.end()) if (mInternalFunctions.find(mangledName) == mInternalFunctions.end())
{ {
TFunction *func = new TFunction(mSymbolTable, functionName, new TType(returnType), TFunction *func = new TFunction(mSymbolTable, functionName, new TType(returnType),
......
//
// Copyright (c) 2018 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.
//
// FunctionLookup.cpp: Used for storing function calls that have not yet been resolved during
// parsing.
//
#include "compiler/translator/FunctionLookup.h"
namespace sh
{
namespace
{
const char kFunctionMangledNameSeparator = '(';
} // anonymous namespace
TFunctionLookup::TFunctionLookup(const TString *name, const TType *constructorType)
: mName(name), mConstructorType(constructorType), mThisNode(nullptr)
{
}
// static
TFunctionLookup *TFunctionLookup::CreateConstructor(const TType *type)
{
ASSERT(type != nullptr);
return new TFunctionLookup(nullptr, type);
}
// static
TFunctionLookup *TFunctionLookup::CreateFunctionCall(const TString *name)
{
ASSERT(name != nullptr);
return new TFunctionLookup(name, nullptr);
}
const TString &TFunctionLookup::name() const
{
return *mName;
}
const TString &TFunctionLookup::getMangledName() const
{
return GetMangledName(*mName, mArguments);
}
const TString &TFunctionLookup::GetMangledName(const TString &functionName,
const TIntermSequence &arguments)
{
std::string newName = functionName.c_str();
newName += kFunctionMangledNameSeparator;
for (TIntermNode *argument : arguments)
{
newName += argument->getAsTyped()->getType().getMangledName();
}
return *NewPoolTString(newName.c_str());
}
bool TFunctionLookup::isConstructor() const
{
return mConstructorType != nullptr;
}
const TType &TFunctionLookup::constructorType() const
{
return *mConstructorType;
}
void TFunctionLookup::setThisNode(TIntermTyped *thisNode)
{
mThisNode = thisNode;
}
TIntermTyped *TFunctionLookup::thisNode() const
{
return mThisNode;
}
void TFunctionLookup::addArgument(TIntermTyped *argument)
{
mArguments.push_back(argument);
}
TIntermSequence &TFunctionLookup::arguments()
{
return mArguments;
}
} // namespace sh
//
// Copyright (c) 2018 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.
//
// FunctionLookup.h: Used for storing function calls that have not yet been resolved during parsing.
//
#ifndef COMPILER_TRANSLATOR_FUNCTIONLOOKUP_H_
#define COMPILER_TRANSLATOR_FUNCTIONLOOKUP_H_
#include "compiler/translator/IntermNode.h"
namespace sh
{
// A function look-up.
class TFunctionLookup : angle::NonCopyable
{
public:
POOL_ALLOCATOR_NEW_DELETE();
static TFunctionLookup *CreateConstructor(const TType *type);
static TFunctionLookup *CreateFunctionCall(const TString *name);
const TString &name() const;
const TString &getMangledName() const;
static const TString &GetMangledName(const TString &functionName,
const TIntermSequence &arguments);
bool isConstructor() const;
const TType &constructorType() const;
void setThisNode(TIntermTyped *thisNode);
TIntermTyped *thisNode() const;
void addArgument(TIntermTyped *argument);
TIntermSequence &arguments();
private:
TFunctionLookup(const TString *name, const TType *constructorType);
const TString *mName;
const TType *const mConstructorType;
TIntermTyped *mThisNode;
TIntermSequence mArguments;
};
} // namespace sh
#endif // COMPILER_TRANSLATOR_FUNCTIONLOOKUP_H_
...@@ -509,21 +509,6 @@ void TIntermAggregate::setBuiltInFunctionPrecision() ...@@ -509,21 +509,6 @@ void TIntermAggregate::setBuiltInFunctionPrecision()
mType.setPrecision(precision); mType.setPrecision(precision);
} }
TString TIntermAggregate::getSymbolTableMangledName() const
{
ASSERT(!isConstructor());
switch (mOp)
{
case EOpCallInternalRawFunction:
case EOpCallBuiltInFunction:
case EOpCallFunctionInAST:
return TFunction::GetMangledNameFromCall(mFunction->name(), mArguments);
default:
TString opString = GetOperatorString(mOp);
return TFunction::GetMangledNameFromCall(opString, mArguments);
}
}
const char *TIntermAggregate::functionName() const const char *TIntermAggregate::functionName() const
{ {
ASSERT(!isConstructor()); ASSERT(!isConstructor());
......
...@@ -533,15 +533,6 @@ class TIntermUnary : public TIntermOperator ...@@ -533,15 +533,6 @@ class TIntermUnary : public TIntermOperator
typedef TVector<TIntermNode *> TIntermSequence; typedef TVector<TIntermNode *> TIntermSequence;
typedef TVector<int> TQualifierList; typedef TVector<int> TQualifierList;
//
// This is just to help yacc.
//
struct TIntermFunctionCallOrMethod
{
TIntermSequence *arguments;
TIntermNode *thisNode;
};
// Interface for node classes that have an arbitrarily sized set of children. // Interface for node classes that have an arbitrarily sized set of children.
class TIntermAggregateBase class TIntermAggregateBase
{ {
...@@ -599,8 +590,6 @@ class TIntermAggregate : public TIntermOperator, public TIntermAggregateBase ...@@ -599,8 +590,6 @@ class TIntermAggregate : public TIntermOperator, public TIntermAggregateBase
TIntermSequence *getSequence() override { return &mArguments; } TIntermSequence *getSequence() override { return &mArguments; }
const TIntermSequence *getSequence() const override { return &mArguments; } const TIntermSequence *getSequence() const override { return &mArguments; }
TString getSymbolTableMangledName() const;
void setUseEmulatedFunction() { mUseEmulatedFunction = true; } void setUseEmulatedFunction() { mUseEmulatedFunction = true; }
bool getUseEmulatedFunction() { return mUseEmulatedFunction; } bool getUseEmulatedFunction() { return mUseEmulatedFunction; }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "compiler/translator/IntermNode_util.h" #include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/FunctionLookup.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
namespace sh namespace sh
...@@ -21,7 +22,7 @@ const TFunction *LookUpBuiltInFunction(const TString &name, ...@@ -21,7 +22,7 @@ const TFunction *LookUpBuiltInFunction(const TString &name,
const TSymbolTable &symbolTable, const TSymbolTable &symbolTable,
int shaderVersion) int shaderVersion)
{ {
TString mangledName = TFunction::GetMangledNameFromCall(name, *arguments); const TString &mangledName = TFunctionLookup::GetMangledName(name, *arguments);
const TSymbol *symbol = symbolTable.findBuiltIn(mangledName, shaderVersion); const TSymbol *symbol = symbolTable.findBuiltIn(mangledName, shaderVersion);
if (symbol) if (symbol)
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "compiler/translator/Declarator.h" #include "compiler/translator/Declarator.h"
#include "compiler/translator/Diagnostics.h" #include "compiler/translator/Diagnostics.h"
#include "compiler/translator/DirectiveHandler.h" #include "compiler/translator/DirectiveHandler.h"
#include "compiler/translator/FunctionLookup.h"
#include "compiler/translator/QualifierTypes.h" #include "compiler/translator/QualifierTypes.h"
#include "compiler/translator/SymbolTable.h" #include "compiler/translator/SymbolTable.h"
...@@ -120,7 +121,7 @@ class TParseContext : angle::NonCopyable ...@@ -120,7 +121,7 @@ class TParseContext : angle::NonCopyable
void checkIsScalarInteger(TIntermTyped *node, const char *token); void checkIsScalarInteger(TIntermTyped *node, const char *token);
bool checkIsAtGlobalLevel(const TSourceLoc &line, const char *token); bool checkIsAtGlobalLevel(const TSourceLoc &line, const char *token);
bool checkConstructorArguments(const TSourceLoc &line, bool checkConstructorArguments(const TSourceLoc &line,
const TIntermSequence *arguments, const TIntermSequence &arguments,
const TType &type); const TType &type);
// Returns a sanitized array size to use (the size is at least 1). // Returns a sanitized array size to use (the size is at least 1).
...@@ -291,8 +292,8 @@ class TParseContext : angle::NonCopyable ...@@ -291,8 +292,8 @@ class TParseContext : angle::NonCopyable
TFunction *parseFunctionHeader(const TPublicType &type, TFunction *parseFunctionHeader(const TPublicType &type,
const TString *name, const TString *name,
const TSourceLoc &location); const TSourceLoc &location);
TFunction *addNonConstructorFunc(const TString *name, const TSourceLoc &loc); TFunctionLookup *addNonConstructorFunc(const TString *name);
TFunction *addConstructorFunc(const TPublicType &publicType); TFunctionLookup *addConstructorFunc(const TPublicType &publicType);
TParameter parseParameterDeclarator(const TPublicType &publicType, TParameter parseParameterDeclarator(const TPublicType &publicType,
const TString *name, const TString *name,
const TSourceLoc &nameLoc); const TSourceLoc &nameLoc);
...@@ -419,14 +420,10 @@ class TParseContext : angle::NonCopyable ...@@ -419,14 +420,10 @@ class TParseContext : angle::NonCopyable
void checkImageMemoryAccessForUserDefinedFunctions(const TFunction *functionDefinition, void checkImageMemoryAccessForUserDefinedFunctions(const TFunction *functionDefinition,
const TIntermAggregate *functionCall); const TIntermAggregate *functionCall);
void checkAtomicMemoryBuiltinFunctions(TIntermAggregate *functionCall); void checkAtomicMemoryBuiltinFunctions(TIntermAggregate *functionCall);
TIntermSequence *createEmptyArgumentsList();
// fnCall is only storing the built-in op, and function name or constructor type. arguments // fnCall is only storing the built-in op, and function name or constructor type. arguments
// has the arguments. // has the arguments.
TIntermTyped *addFunctionCallOrMethod(TFunction *fnCall, TIntermTyped *addFunctionCallOrMethod(TFunctionLookup *fnCall, const TSourceLoc &loc);
TIntermSequence *arguments,
TIntermNode *thisNode,
const TSourceLoc &loc);
TIntermTyped *addTernarySelection(TIntermTyped *cond, TIntermTyped *addTernarySelection(TIntermTyped *cond,
TIntermTyped *trueExpression, TIntermTyped *trueExpression,
...@@ -523,7 +520,7 @@ class TParseContext : angle::NonCopyable ...@@ -523,7 +520,7 @@ class TParseContext : angle::NonCopyable
void checkYuvIsNotSpecified(const TSourceLoc &location, bool yuv); void checkYuvIsNotSpecified(const TSourceLoc &location, bool yuv);
bool checkUnsizedArrayConstructorArgumentDimensionality(TIntermSequence *arguments, bool checkUnsizedArrayConstructorArgumentDimensionality(const TIntermSequence &arguments,
TType type, TType type,
const TSourceLoc &line); const TSourceLoc &line);
...@@ -549,16 +546,9 @@ class TParseContext : angle::NonCopyable ...@@ -549,16 +546,9 @@ class TParseContext : angle::NonCopyable
const TSourceLoc &loc); const TSourceLoc &loc);
TIntermTyped *createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc); TIntermTyped *createUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc);
TIntermTyped *addMethod(const TString &name, TIntermTyped *addMethod(TFunctionLookup *fnCall, const TSourceLoc &loc);
TIntermSequence *arguments, TIntermTyped *addConstructor(TFunctionLookup *fnCall, const TSourceLoc &line);
TIntermNode *thisNode, TIntermTyped *addNonConstructorFunctionCall(TFunctionLookup *fnCall, const TSourceLoc &loc);
const TSourceLoc &loc);
TIntermTyped *addConstructor(TIntermSequence *arguments,
TType type,
const TSourceLoc &line);
TIntermTyped *addNonConstructorFunctionCall(const TString &name,
TIntermSequence *arguments,
const TSourceLoc &loc);
// Return either the original expression or the folded version of the expression in case the // Return either the original expression or the folded version of the expression in case the
// folded node will validate the same way during subsequent parsing. // folded node will validate the same way during subsequent parsing.
......
...@@ -35,7 +35,7 @@ TSymbol::TSymbol(TSymbolTable *symbolTable, ...@@ -35,7 +35,7 @@ TSymbol::TSymbol(TSymbolTable *symbolTable,
{ {
ASSERT(mSymbolType == SymbolType::BuiltIn || mExtension == TExtension::UNDEFINED); ASSERT(mSymbolType == SymbolType::BuiltIn || mExtension == TExtension::UNDEFINED);
ASSERT(mName != nullptr || mSymbolType == SymbolType::AngleInternal || ASSERT(mName != nullptr || mSymbolType == SymbolType::AngleInternal ||
mSymbolType == SymbolType::NotResolved || mSymbolType == SymbolType::Empty); mSymbolType == SymbolType::Empty);
ASSERT(mName == nullptr || *mName != ""); ASSERT(mName == nullptr || *mName != "");
} }
...@@ -167,19 +167,6 @@ const TString *TFunction::buildMangledName() const ...@@ -167,19 +167,6 @@ const TString *TFunction::buildMangledName() const
return NewPoolTString(newName.c_str()); return NewPoolTString(newName.c_str());
} }
const TString &TFunction::GetMangledNameFromCall(const TString &functionName,
const TIntermSequence &arguments)
{
std::string newName = functionName.c_str();
newName += kFunctionMangledNameSeparator;
for (TIntermNode *argument : arguments)
{
newName += argument->getAsTyped()->getType().getMangledName();
}
return *NewPoolTString(newName.c_str());
}
bool TFunction::isMain() const bool TFunction::isMain() const
{ {
return symbolType() == SymbolType::UserDefined && name() == "main"; return symbolType() == SymbolType::UserDefined && name() == "main";
......
...@@ -24,8 +24,7 @@ enum class SymbolType ...@@ -24,8 +24,7 @@ enum class SymbolType
BuiltIn, BuiltIn,
UserDefined, UserDefined,
AngleInternal, AngleInternal,
Empty, // Meaning symbol without a name. Empty // Meaning symbol without a name.
NotResolved
}; };
// Symbol base class. (Can build functions or variables out of these...) // Symbol base class. (Can build functions or variables out of these...)
...@@ -209,9 +208,6 @@ class TFunction : public TSymbol ...@@ -209,9 +208,6 @@ class TFunction : public TSymbol
return *mangledName; return *mangledName;
} }
static const TString &GetMangledNameFromCall(const TString &functionName,
const TIntermSequence &arguments);
const TType &getReturnType() const { return *returnType; } const TType &getReturnType() const { return *returnType; }
TOperator getBuiltInOp() const { return op; } TOperator getBuiltInOp() const { return op; }
...@@ -236,11 +232,9 @@ class TFunction : public TSymbol ...@@ -236,11 +232,9 @@ class TFunction : public TSymbol
typedef TVector<TConstParameter> TParamList; typedef TVector<TConstParameter> TParamList;
TParamList parameters; TParamList parameters;
const TType *returnType; const TType *const returnType;
mutable const TString *mangledName; mutable const TString *mangledName;
// TODO(oetuaho): Remove op from TFunction once TFunction is not used for looking up builtins or const TOperator op; // Only set for built-ins
// constructors.
TOperator op;
bool defined; bool defined;
bool mHasPrototypeDeclaration; bool mHasPrototypeDeclaration;
bool mKnownToNotHaveSideEffects; bool mKnownToNotHaveSideEffects;
......
...@@ -76,7 +76,6 @@ using namespace sh; ...@@ -76,7 +76,6 @@ using namespace sh;
union { union {
TIntermNode *intermNode; TIntermNode *intermNode;
TIntermNodePair nodePair; TIntermNodePair nodePair;
TIntermFunctionCallOrMethod callOrMethodPair;
TIntermTyped *intermTypedNode; TIntermTyped *intermTypedNode;
TIntermAggregate *intermAggregate; TIntermAggregate *intermAggregate;
TIntermBlock *intermBlock; TIntermBlock *intermBlock;
...@@ -93,6 +92,7 @@ using namespace sh; ...@@ -93,6 +92,7 @@ using namespace sh;
TLayoutQualifier layoutQualifier; TLayoutQualifier layoutQualifier;
TQualifier qualifier; TQualifier qualifier;
TFunction *function; TFunction *function;
TFunctionLookup *functionLookup;
TParameter param; TParameter param;
TDeclarator *declarator; TDeclarator *declarator;
TDeclaratorList *declaratorList; TDeclaratorList *declaratorList;
...@@ -236,10 +236,12 @@ extern void yyerror(YYLTYPE* yylloc, TParseContext* context, void *scanner, cons ...@@ -236,10 +236,12 @@ extern void yyerror(YYLTYPE* yylloc, TParseContext* context, void *scanner, cons
%type <interm.declarator> struct_declarator %type <interm.declarator> struct_declarator
%type <interm.declaratorList> struct_declarator_list %type <interm.declaratorList> struct_declarator_list
%type <interm.fieldList> struct_declaration struct_declaration_list %type <interm.fieldList> struct_declaration struct_declaration_list
%type <interm.function> function_header function_declarator function_identifier %type <interm.function> function_header function_declarator
%type <interm.function> function_header_with_parameters function_call_header %type <interm.function> function_header_with_parameters
%type <interm> function_call_header_with_parameters function_call_header_no_parameters function_call_generic function_prototype %type <interm.functionLookup> function_identifier function_call_header
%type <interm> function_call_or_method %type <interm.functionLookup> function_call_header_with_parameters function_call_header_no_parameters
%type <interm.functionLookup> function_call_generic function_call_or_method
%type <interm> function_prototype
%type <lex> enter_struct %type <lex> enter_struct
...@@ -328,19 +330,18 @@ integer_expression ...@@ -328,19 +330,18 @@ integer_expression
function_call function_call
: function_call_or_method { : function_call_or_method {
$$ = context->addFunctionCallOrMethod($1.function, $1.callOrMethodPair.arguments, $1.callOrMethodPair.thisNode, @1); $$ = context->addFunctionCallOrMethod($1, @1);
} }
; ;
function_call_or_method function_call_or_method
: function_call_generic { : function_call_generic {
$$ = $1; $$ = $1;
$$.callOrMethodPair.thisNode = nullptr;
} }
| postfix_expression DOT function_call_generic { | postfix_expression DOT function_call_generic {
ES3_OR_NEWER("", @3, "methods"); ES3_OR_NEWER("", @3, "methods");
$$ = $3; $$ = $3;
$$.callOrMethodPair.thisNode = $1; $$->setThisNode($1);
} }
; ;
...@@ -355,24 +356,21 @@ function_call_generic ...@@ -355,24 +356,21 @@ function_call_generic
function_call_header_no_parameters function_call_header_no_parameters
: function_call_header VOID_TYPE { : function_call_header VOID_TYPE {
$$.function = $1; $$ = $1;
$$.callOrMethodPair.arguments = context->createEmptyArgumentsList();
} }
| function_call_header { | function_call_header {
$$.function = $1; $$ = $1;
$$.callOrMethodPair.arguments = context->createEmptyArgumentsList();
} }
; ;
function_call_header_with_parameters function_call_header_with_parameters
: function_call_header assignment_expression { : function_call_header assignment_expression {
$$.callOrMethodPair.arguments = context->createEmptyArgumentsList(); $$ = $1;
$$.function = $1; $$->addArgument($2);
$$.callOrMethodPair.arguments->push_back($2);
} }
| function_call_header_with_parameters COMMA assignment_expression { | function_call_header_with_parameters COMMA assignment_expression {
$$.function = $1.function; $$ = $1;
$$.callOrMethodPair.arguments->push_back($3); $$->addArgument($3);
} }
; ;
...@@ -389,10 +387,10 @@ function_identifier ...@@ -389,10 +387,10 @@ function_identifier
$$ = context->addConstructorFunc($1); $$ = context->addConstructorFunc($1);
} }
| IDENTIFIER { | IDENTIFIER {
$$ = context->addNonConstructorFunc($1.string, @1); $$ = context->addNonConstructorFunc($1.string);
} }
| FIELD_SELECTION { | FIELD_SELECTION {
$$ = context->addNonConstructorFunc($1.string, @1); $$ = context->addNonConstructorFunc($1.string);
} }
; ;
......
...@@ -317,7 +317,6 @@ union YYSTYPE ...@@ -317,7 +317,6 @@ union YYSTYPE
union { union {
TIntermNode *intermNode; TIntermNode *intermNode;
TIntermNodePair nodePair; TIntermNodePair nodePair;
TIntermFunctionCallOrMethod callOrMethodPair;
TIntermTyped *intermTypedNode; TIntermTyped *intermTypedNode;
TIntermAggregate *intermAggregate; TIntermAggregate *intermAggregate;
TIntermBlock *intermBlock; TIntermBlock *intermBlock;
...@@ -334,6 +333,7 @@ union YYSTYPE ...@@ -334,6 +333,7 @@ union YYSTYPE
TLayoutQualifier layoutQualifier; TLayoutQualifier layoutQualifier;
TQualifier qualifier; TQualifier qualifier;
TFunction *function; TFunction *function;
TFunctionLookup *functionLookup;
TParameter param; TParameter param;
TDeclarator *declarator; TDeclarator *declarator;
TDeclaratorList *declaratorList; TDeclaratorList *declaratorList;
...@@ -743,36 +743,36 @@ static const yytype_uint8 yytranslate[] = ...@@ -743,36 +743,36 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] = static const yytype_uint16 yyrline[] =
{ {
0, 250, 250, 251, 254, 264, 267, 272, 277, 282, 0, 252, 252, 253, 256, 266, 269, 274, 279, 284,
287, 296, 302, 305, 308, 311, 314, 317, 323, 330, 289, 298, 304, 307, 310, 313, 316, 319, 325, 332,
336, 340, 348, 351, 357, 361, 368, 373, 380, 388, 338, 341, 349, 352, 358, 361, 367, 371, 378, 386,
391, 394, 400, 403, 406, 409, 416, 417, 418, 419, 389, 392, 398, 401, 404, 407, 414, 415, 416, 417,
427, 428, 431, 434, 441, 442, 445, 451, 452, 456, 425, 426, 429, 432, 439, 440, 443, 449, 450, 454,
463, 464, 467, 470, 473, 479, 480, 483, 489, 490, 461, 462, 465, 468, 471, 477, 478, 481, 487, 488,
497, 498, 505, 506, 513, 514, 520, 521, 527, 528, 495, 496, 503, 504, 511, 512, 518, 519, 525, 526,
534, 535, 541, 542, 548, 549, 550, 551, 555, 556, 532, 533, 539, 540, 546, 547, 548, 549, 553, 554,
557, 561, 565, 569, 573, 580, 583, 589, 596, 603, 555, 559, 563, 567, 571, 578, 581, 587, 594, 601,
606, 609, 613, 617, 621, 625, 629, 636, 643, 646, 604, 607, 611, 615, 619, 623, 627, 634, 641, 644,
653, 661, 678, 688, 691, 697, 701, 705, 709, 716, 651, 659, 676, 686, 689, 695, 699, 703, 707, 714,
723, 726, 730, 734, 739, 746, 750, 754, 758, 763, 721, 724, 728, 732, 737, 744, 748, 752, 756, 761,
770, 774, 780, 783, 789, 793, 800, 806, 810, 814, 768, 772, 778, 781, 787, 791, 798, 804, 808, 812,
817, 820, 829, 834, 838, 841, 844, 847, 850, 854, 815, 818, 827, 832, 836, 839, 842, 845, 848, 852,
857, 861, 864, 867, 870, 873, 876, 883, 890, 893, 855, 859, 862, 865, 868, 871, 874, 881, 888, 891,
896, 902, 909, 912, 918, 921, 924, 927, 933, 936, 894, 900, 907, 910, 916, 919, 922, 925, 931, 934,
943, 948, 955, 960, 971, 974, 977, 980, 983, 986, 941, 946, 953, 958, 969, 972, 975, 978, 981, 984,
990, 994, 998, 1002, 1006, 1010, 1014, 1018, 1022, 1026, 988, 992, 996, 1000, 1004, 1008, 1012, 1016, 1020, 1024,
1030, 1034, 1038, 1042, 1046, 1050, 1054, 1058, 1062, 1066, 1028, 1032, 1036, 1040, 1044, 1048, 1052, 1056, 1060, 1064,
1070, 1077, 1080, 1083, 1086, 1089, 1092, 1095, 1098, 1101, 1068, 1075, 1078, 1081, 1084, 1087, 1090, 1093, 1096, 1099,
1104, 1107, 1110, 1113, 1116, 1119, 1122, 1125, 1128, 1131, 1102, 1105, 1108, 1111, 1114, 1117, 1120, 1123, 1126, 1129,
1141, 1148, 1155, 1158, 1161, 1164, 1167, 1170, 1173, 1176, 1139, 1146, 1153, 1156, 1159, 1162, 1165, 1168, 1171, 1174,
1179, 1182, 1185, 1188, 1191, 1194, 1197, 1205, 1205, 1208, 1177, 1180, 1183, 1186, 1189, 1192, 1195, 1203, 1203, 1206,
1208, 1214, 1217, 1223, 1226, 1233, 1237, 1243, 1246, 1252, 1206, 1212, 1215, 1221, 1224, 1231, 1235, 1241, 1244, 1250,
1256, 1260, 1261, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1254, 1258, 1259, 1265, 1266, 1267, 1268, 1269, 1270, 1271,
1277, 1281, 1281, 1281, 1288, 1289, 1293, 1293, 1294, 1294, 1275, 1279, 1279, 1279, 1286, 1287, 1291, 1291, 1292, 1292,
1299, 1303, 1310, 1314, 1321, 1322, 1326, 1332, 1336, 1345, 1297, 1301, 1308, 1312, 1319, 1320, 1324, 1330, 1334, 1343,
1345, 1352, 1355, 1361, 1365, 1371, 1371, 1376, 1376, 1380, 1343, 1350, 1353, 1359, 1363, 1369, 1369, 1374, 1374, 1378,
1380, 1388, 1391, 1397, 1400, 1406, 1410, 1417, 1420, 1423, 1378, 1386, 1389, 1395, 1398, 1404, 1408, 1415, 1418, 1421,
1426, 1429, 1437, 1443, 1449, 1452, 1458, 1458 1424, 1427, 1435, 1441, 1447, 1450, 1456, 1456
}; };
#endif #endif
...@@ -2636,7 +2636,7 @@ yyreduce: ...@@ -2636,7 +2636,7 @@ yyreduce:
case 19: case 19:
{ {
(yyval.interm.intermTypedNode) = context->addFunctionCallOrMethod((yyvsp[0].interm).function, (yyvsp[0].interm).callOrMethodPair.arguments, (yyvsp[0].interm).callOrMethodPair.thisNode, (yylsp[0])); (yyval.interm.intermTypedNode) = context->addFunctionCallOrMethod((yyvsp[0].interm.functionLookup), (yylsp[0]));
} }
break; break;
...@@ -2644,8 +2644,7 @@ yyreduce: ...@@ -2644,8 +2644,7 @@ yyreduce:
case 20: case 20:
{ {
(yyval.interm) = (yyvsp[0].interm); (yyval.interm.functionLookup) = (yyvsp[0].interm.functionLookup);
(yyval.interm).callOrMethodPair.thisNode = nullptr;
} }
break; break;
...@@ -2654,8 +2653,8 @@ yyreduce: ...@@ -2654,8 +2653,8 @@ yyreduce:
{ {
ES3_OR_NEWER("", (yylsp[0]), "methods"); ES3_OR_NEWER("", (yylsp[0]), "methods");
(yyval.interm) = (yyvsp[0].interm); (yyval.interm.functionLookup) = (yyvsp[0].interm.functionLookup);
(yyval.interm).callOrMethodPair.thisNode = (yyvsp[-2].interm.intermTypedNode); (yyval.interm.functionLookup)->setThisNode((yyvsp[-2].interm.intermTypedNode));
} }
break; break;
...@@ -2663,7 +2662,7 @@ yyreduce: ...@@ -2663,7 +2662,7 @@ yyreduce:
case 22: case 22:
{ {
(yyval.interm) = (yyvsp[-1].interm); (yyval.interm.functionLookup) = (yyvsp[-1].interm.functionLookup);
} }
break; break;
...@@ -2671,7 +2670,7 @@ yyreduce: ...@@ -2671,7 +2670,7 @@ yyreduce:
case 23: case 23:
{ {
(yyval.interm) = (yyvsp[-1].interm); (yyval.interm.functionLookup) = (yyvsp[-1].interm.functionLookup);
} }
break; break;
...@@ -2679,8 +2678,7 @@ yyreduce: ...@@ -2679,8 +2678,7 @@ yyreduce:
case 24: case 24:
{ {
(yyval.interm).function = (yyvsp[-1].interm.function); (yyval.interm.functionLookup) = (yyvsp[-1].interm.functionLookup);
(yyval.interm).callOrMethodPair.arguments = context->createEmptyArgumentsList();
} }
break; break;
...@@ -2688,8 +2686,7 @@ yyreduce: ...@@ -2688,8 +2686,7 @@ yyreduce:
case 25: case 25:
{ {
(yyval.interm).function = (yyvsp[0].interm.function); (yyval.interm.functionLookup) = (yyvsp[0].interm.functionLookup);
(yyval.interm).callOrMethodPair.arguments = context->createEmptyArgumentsList();
} }
break; break;
...@@ -2697,9 +2694,8 @@ yyreduce: ...@@ -2697,9 +2694,8 @@ yyreduce:
case 26: case 26:
{ {
(yyval.interm).callOrMethodPair.arguments = context->createEmptyArgumentsList(); (yyval.interm.functionLookup) = (yyvsp[-1].interm.functionLookup);
(yyval.interm).function = (yyvsp[-1].interm.function); (yyval.interm.functionLookup)->addArgument((yyvsp[0].interm.intermTypedNode));
(yyval.interm).callOrMethodPair.arguments->push_back((yyvsp[0].interm.intermTypedNode));
} }
break; break;
...@@ -2707,8 +2703,8 @@ yyreduce: ...@@ -2707,8 +2703,8 @@ yyreduce:
case 27: case 27:
{ {
(yyval.interm).function = (yyvsp[-2].interm).function; (yyval.interm.functionLookup) = (yyvsp[-2].interm.functionLookup);
(yyval.interm).callOrMethodPair.arguments->push_back((yyvsp[0].interm.intermTypedNode)); (yyval.interm.functionLookup)->addArgument((yyvsp[0].interm.intermTypedNode));
} }
break; break;
...@@ -2716,7 +2712,7 @@ yyreduce: ...@@ -2716,7 +2712,7 @@ yyreduce:
case 28: case 28:
{ {
(yyval.interm.function) = (yyvsp[-1].interm.function); (yyval.interm.functionLookup) = (yyvsp[-1].interm.functionLookup);
} }
break; break;
...@@ -2724,7 +2720,7 @@ yyreduce: ...@@ -2724,7 +2720,7 @@ yyreduce:
case 29: case 29:
{ {
(yyval.interm.function) = context->addConstructorFunc((yyvsp[0].interm.type)); (yyval.interm.functionLookup) = context->addConstructorFunc((yyvsp[0].interm.type));
} }
break; break;
...@@ -2732,7 +2728,7 @@ yyreduce: ...@@ -2732,7 +2728,7 @@ yyreduce:
case 30: case 30:
{ {
(yyval.interm.function) = context->addNonConstructorFunc((yyvsp[0].lex).string, (yylsp[0])); (yyval.interm.functionLookup) = context->addNonConstructorFunc((yyvsp[0].lex).string);
} }
break; break;
...@@ -2740,7 +2736,7 @@ yyreduce: ...@@ -2740,7 +2736,7 @@ yyreduce:
case 31: case 31:
{ {
(yyval.interm.function) = context->addNonConstructorFunc((yyvsp[0].lex).string, (yylsp[0])); (yyval.interm.functionLookup) = context->addNonConstructorFunc((yyvsp[0].lex).string);
} }
break; break;
......
...@@ -228,7 +228,6 @@ union YYSTYPE ...@@ -228,7 +228,6 @@ union YYSTYPE
union { union {
TIntermNode *intermNode; TIntermNode *intermNode;
TIntermNodePair nodePair; TIntermNodePair nodePair;
TIntermFunctionCallOrMethod callOrMethodPair;
TIntermTyped *intermTypedNode; TIntermTyped *intermTypedNode;
TIntermAggregate *intermAggregate; TIntermAggregate *intermAggregate;
TIntermBlock *intermBlock; TIntermBlock *intermBlock;
...@@ -245,6 +244,7 @@ union YYSTYPE ...@@ -245,6 +244,7 @@ union YYSTYPE
TLayoutQualifier layoutQualifier; TLayoutQualifier layoutQualifier;
TQualifier qualifier; TQualifier qualifier;
TFunction *function; TFunction *function;
TFunctionLookup *functionLookup;
TParameter param; TParameter param;
TDeclarator *declarator; TDeclarator *declarator;
TDeclaratorList *declaratorList; TDeclaratorList *declaratorList;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "angle_gl.h" #include "angle_gl.h"
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
#include "compiler/translator/FunctionLookup.h"
#include "compiler/translator/IntermTraverse.h" #include "compiler/translator/IntermTraverse.h"
namespace sh namespace sh
...@@ -18,6 +19,22 @@ namespace sh ...@@ -18,6 +19,22 @@ namespace sh
namespace namespace
{ {
const TString &GetSymbolTableMangledName(TIntermAggregate *node)
{
ASSERT(!node->isConstructor());
switch (node->getOp())
{
case EOpCallInternalRawFunction:
case EOpCallBuiltInFunction:
case EOpCallFunctionInAST:
return TFunctionLookup::GetMangledName(node->getFunction()->name(),
*node->getSequence());
default:
TString opString = GetOperatorString(node->getOp());
return TFunctionLookup::GetMangledName(opString, *node->getSequence());
}
}
class FunctionCallFinder : public TIntermTraverser class FunctionCallFinder : public TIntermTraverser
{ {
public: public:
...@@ -30,7 +47,7 @@ class FunctionCallFinder : public TIntermTraverser ...@@ -30,7 +47,7 @@ class FunctionCallFinder : public TIntermTraverser
bool visitAggregate(Visit visit, TIntermAggregate *node) override bool visitAggregate(Visit visit, TIntermAggregate *node) override
{ {
if (node->isFunctionCall() && node->getSymbolTableMangledName() == mFunctionMangledName) if (node->isFunctionCall() && GetSymbolTableMangledName(node) == mFunctionMangledName)
{ {
mNodeFound = node; mNodeFound = node;
return false; return false;
......
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