Reorganized new sources from recently applied patch into third_party directory.

Review URL: https://codereview.appspot.com/7105049

git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1779 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/ArrayBoundsClamper.cpp b/src/compiler/ArrayBoundsClamper.cpp
deleted file mode 100644
index 6a31721..0000000
--- a/src/compiler/ArrayBoundsClamper.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "compiler/ArrayBoundsClamper.h"
-
-const char* kIntClampBegin = "// BEGIN: Generated code for array bounds clamping\n\n";
-const char* kIntClampEnd = "// END: Generated code for array bounds clamping\n\n";
-const char* kIntClampDefinition = "int webgl_int_clamp(int value, int minValue, int maxValue) { return ((value < minValue) ? minValue : ((value > maxValue) ? maxValue : value)); }\n\n";
-
-namespace {
-
-class ArrayBoundsClamperMarker : public TIntermTraverser {
-public:
-    ArrayBoundsClamperMarker()
-        : mNeedsClamp(false)
-   {
-   }
-
-   virtual bool visitBinary(Visit visit, TIntermBinary* node)
-   {
-       if (node->getOp() == EOpIndexIndirect)
-       {
-           TIntermTyped* left = node->getLeft();
-           if (left->isArray() || left->isVector() || left->isMatrix())
-           {
-               node->setAddIndexClamp();
-               mNeedsClamp = true;
-           }
-       }
-       return true;
-   }
-
-    bool GetNeedsClamp() { return mNeedsClamp; }
-
-private:
-    bool mNeedsClamp;
-};
-
-}  // anonymous namespace
-
-ArrayBoundsClamper::ArrayBoundsClamper()
-    : mArrayBoundsClampDefinitionNeeded(false)
-{
-}
-
-void ArrayBoundsClamper::OutputClampingFunctionDefinition(TInfoSinkBase& out) const
-{
-    if (!mArrayBoundsClampDefinitionNeeded)
-    {
-        return;
-    }
-    out << kIntClampBegin << kIntClampDefinition << kIntClampEnd;
-}
-
-void ArrayBoundsClamper::MarkIndirectArrayBoundsForClamping(TIntermNode* root)
-{
-    ASSERT(root);
-
-    ArrayBoundsClamperMarker clamper;
-    root->traverse(&clamper);
-    if (clamper.GetNeedsClamp())
-    {
-        SetArrayBoundsClampDefinitionNeeded();
-    }
-}
-
diff --git a/src/compiler/ArrayBoundsClamper.h b/src/compiler/ArrayBoundsClamper.h
deleted file mode 100644
index d4a8d69..0000000
--- a/src/compiler/ArrayBoundsClamper.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef COMPILER_ARRAY_BOUNDS_CLAMPER_H_
-#define COMPILER_ARRAY_BOUNDS_CLAMPER_H_
-
-#include "GLSLANG/ShaderLang.h"
-
-#include "compiler/InfoSink.h"
-#include "compiler/intermediate.h"
-
-class ArrayBoundsClamper {
-public:
-    ArrayBoundsClamper();
-
-    // Output array clamp function source into the shader source.
-    void OutputClampingFunctionDefinition(TInfoSinkBase& out) const;
-
-    // Marks nodes in the tree that index arrays indirectly as
-    // requiring clamping.
-    void MarkIndirectArrayBoundsForClamping(TIntermNode* root);
-
-    void Cleanup()
-    {
-        mArrayBoundsClampDefinitionNeeded = false;
-    }
-
-private:
-    bool GetArrayBoundsClampDefinitionNeeded() const { return mArrayBoundsClampDefinitionNeeded; }
-    void SetArrayBoundsClampDefinitionNeeded() { mArrayBoundsClampDefinitionNeeded = true; }
-    
-    bool mArrayBoundsClampDefinitionNeeded;
-};
-
-#endif // COMPILER_ARRAY_BOUNDS_CLAMPER_H_
diff --git a/src/compiler/Compiler.cpp b/src/compiler/Compiler.cpp
index dce8c68..1e2c945 100644
--- a/src/compiler/Compiler.cpp
+++ b/src/compiler/Compiler.cpp
@@ -4,7 +4,6 @@
 // found in the LICENSE file.
 //
 
-#include "compiler/ArrayBoundsClamper.h"
 #include "compiler/BuiltInFunctionEmulator.h"
 #include "compiler/DetectRecursion.h"
 #include "compiler/ForLoopUnroll.h"
@@ -20,6 +19,7 @@
 #include "compiler/depgraph/DependencyGraphOutput.h"
 #include "compiler/timing/RestrictFragmentShaderTiming.h"
 #include "compiler/timing/RestrictVertexShaderTiming.h"
+#include "third_party/compiler/ArrayBoundsClamper.h"
 
 bool isWebGLBasedSpec(ShShaderSpec spec)
 {
diff --git a/src/compiler/ShHandle.h b/src/compiler/ShHandle.h
index 9a6f8dd..a50be62 100644
--- a/src/compiler/ShHandle.h
+++ b/src/compiler/ShHandle.h
@@ -16,13 +16,13 @@
 
 #include "GLSLANG/ShaderLang.h"
 
-#include "compiler/ArrayBoundsClamper.h"
 #include "compiler/BuiltInFunctionEmulator.h"
 #include "compiler/ExtensionBehavior.h"
 #include "compiler/HashNames.h"
 #include "compiler/InfoSink.h"
 #include "compiler/SymbolTable.h"
 #include "compiler/VariableInfo.h"
+#include "third_party/compiler/ArrayBoundsClamper.h"
 
 class LongNameMap;
 class TCompiler;
diff --git a/src/compiler/translator_common.vcxproj b/src/compiler/translator_common.vcxproj
index 04d0e32..7d0195b 100644
--- a/src/compiler/translator_common.vcxproj
+++ b/src/compiler/translator_common.vcxproj
@@ -138,7 +138,6 @@
     </ClCompile>

   </ItemDefinitionGroup>

   <ItemGroup>

-    <ClCompile Include="ArrayBoundsClamper.cpp" />

     <ClCompile Include="BuiltInFunctionEmulator.cpp" />

     <ClCompile Include="Compiler.cpp" />

     <ClCompile Include="debug.cpp" />

@@ -174,6 +173,7 @@
     <ClCompile Include="depgraph\DependencyGraphTraverse.cpp" />

     <ClCompile Include="timing\RestrictFragmentShaderTiming.cpp" />

     <ClCompile Include="timing\RestrictVertexShaderTiming.cpp" />

+    <ClCompile Include="..\third_party\compiler\ArrayBoundsClamper.cpp" />

   </ItemGroup>

   <ItemGroup>

     <CustomBuild Include="glslang.l">

@@ -226,7 +226,6 @@
     </CustomBuild>

   </ItemGroup>

   <ItemGroup>

-    <ClInclude Include="ArrayBoundsClamper.h" />

     <ClInclude Include="BaseTypes.h" />

     <ClInclude Include="BuiltInFunctionEmulator.h" />

     <ClInclude Include="Common.h" />

@@ -266,8 +265,9 @@
     <ClInclude Include="depgraph\DependencyGraph.h" />

     <ClInclude Include="depgraph\DependencyGraphBuilder.h" />

     <ClInclude Include="depgraph\DependencyGraphOutput.h" />

+    <ClInclude Include="..\third_party\compiler\ArrayBoundsClamper.h" />

   </ItemGroup>

   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

   <ImportGroup Label="ExtensionTargets">

   </ImportGroup>

-</Project>
\ No newline at end of file
+</Project>