fixed sksl static ifs to work for CircleEffect

static ifs (and switches) in .fp files are a bit tricky, because they
aren't necessarily static when the CPP file is being produced. They
become static when the CPP file produces the final SkSL; at this point
the final values of the 'in' variables are known.

This change permits 'deferred' static ifs and switches. The initial
compilation (.fp -> .cpp) passes the @if / @switch through, and then
the final compilation (.cpp's generated SkSL -> GLSL or whatever)
enforces the static test.

Bug: skia:
Change-Id: I0087dfe1725c8fd350507ac77f64db1d82659cdf
Reviewed-on: https://skia-review.googlesource.com/23403
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 593397b..3a037e7 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -54,8 +54,9 @@
 
 namespace SkSL {
 
-Compiler::Compiler()
-: fErrorCount(0) {
+Compiler::Compiler(Flags flags)
+: fFlags(flags)
+, fErrorCount(0) {
     auto types = std::shared_ptr<SymbolTable>(new SymbolTable(this));
     auto symbols = std::shared_ptr<SymbolTable>(new SymbolTable(types, this));
     fIRGenerator = new IRGenerator(&fContext, symbols, *this);
@@ -931,7 +932,7 @@
                             (*iter)->setStatement(std::move(newBlock));
                             break;
                         } else {
-                            if (s.fIsStatic) {
+                            if (s.fIsStatic && !(fFlags & kPermitInvalidStaticTests_Flag)) {
                                 this->error(s.fPosition,
                                             "static switch contains non-static conditional break");
                                 s.fIsStatic = false;
@@ -947,7 +948,7 @@
                         if (newBlock) {
                             (*iter)->setStatement(std::move(newBlock));
                         } else {
-                            if (s.fIsStatic) {
+                            if (s.fIsStatic && !(fFlags & kPermitInvalidStaticTests_Flag)) {
                                 this->error(s.fPosition,
                                             "static switch contains non-static conditional break");
                                 s.fIsStatic = false;
@@ -1047,13 +1048,15 @@
                 const Statement& s = **iter->statement();
                 switch (s.fKind) {
                     case Statement::kIf_Kind:
-                        if (((const IfStatement&) s).fIsStatic) {
+                        if (((const IfStatement&) s).fIsStatic &&
+                            !(fFlags & kPermitInvalidStaticTests_Flag)) {
                             this->error(s.fPosition, "static if has non-static test");
                         }
                         ++iter;
                         break;
                     case Statement::kSwitch_Kind:
-                        if (((const SwitchStatement&) s).fIsStatic) {
+                        if (((const SwitchStatement&) s).fIsStatic &&
+                             !(fFlags & kPermitInvalidStaticTests_Flag)) {
                             this->error(s.fPosition, "static switch has non-static test");
                         }
                         ++iter;