Simplify built-in function node initialization

Built-ins with no math op associated with them now have the op code
EOpCallBuiltInFunction set. This makes initializing built-in function
nodes simpler, since they can always get the op code from the function
symbol.

We also no longer look for functions in inner scopes, only from the
global scope and from built-in functions.

BUG=angleproject:2267
TEST=angle_unittests

Change-Id: I55a2642f34bb3c8b8f13183c95fa509ec3b9cfdb
Reviewed-on: https://chromium-review.googlesource.com/923724
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/IntermNode.cpp b/src/compiler/translator/IntermNode.cpp
index dca3bc7..c7319f5 100644
--- a/src/compiler/translator/IntermNode.cpp
+++ b/src/compiler/translator/IntermNode.cpp
@@ -352,11 +352,9 @@
 TIntermAggregate *TIntermAggregate::CreateBuiltInFunctionCall(const TFunction &func,
                                                               TIntermSequence *arguments)
 {
-    TIntermAggregate *callNode =
-        new TIntermAggregate(&func, func.getReturnType(), EOpCallBuiltInFunction, arguments);
-    // Note that name needs to be set before texture function type is determined.
-    callNode->setBuiltInFunctionPrecision();
-    return callNode;
+    // op should be either EOpCallBuiltInFunction or a specific math op.
+    ASSERT(func.getBuiltInOp() != EOpNull);
+    return new TIntermAggregate(&func, func.getReturnType(), func.getBuiltInOp(), arguments);
 }
 
 TIntermAggregate *TIntermAggregate::CreateConstructor(const TType &type,
@@ -365,22 +363,11 @@
     return new TIntermAggregate(nullptr, type, EOpConstruct, arguments);
 }
 
-TIntermAggregate *TIntermAggregate::Create(const TFunction &func,
-                                           TOperator op,
-                                           TIntermSequence *arguments)
-{
-    ASSERT(op != EOpCallFunctionInAST);    // Should use CreateFunctionCall
-    ASSERT(op != EOpCallInternalRawFunction);  // Should use CreateRawFunctionCall
-    ASSERT(op != EOpCallBuiltInFunction);  // Should use CreateBuiltInFunctionCall
-    ASSERT(op != EOpConstruct);            // Should use CreateConstructor
-    return new TIntermAggregate(&func, func.getReturnType(), op, arguments);
-}
-
 TIntermAggregate::TIntermAggregate(const TFunction *func,
                                    const TType &type,
                                    TOperator op,
                                    TIntermSequence *arguments)
-    : TIntermOperator(op),
+    : TIntermOperator(op, type),
       mUseEmulatedFunction(false),
       mGotPrecisionFromChildren(false),
       mFunction(func)
@@ -390,14 +377,17 @@
         mArguments.swap(*arguments);
     }
     ASSERT(mFunction == nullptr || mFunction->symbolType() != SymbolType::Empty);
-    setTypePrecisionAndQualifier(type);
+    setPrecisionAndQualifier();
 }
 
-void TIntermAggregate::setTypePrecisionAndQualifier(const TType &type)
+void TIntermAggregate::setPrecisionAndQualifier()
 {
-    setType(type);
     mType.setQualifier(EvqTemporary);
-    if (!isFunctionCall())
+    if (mOp == EOpCallBuiltInFunction)
+    {
+        setBuiltInFunctionPrecision();
+    }
+    else if (!isFunctionCall())
     {
         if (isConstructor())
         {