diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-07-14 10:12:15 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-14 14:41:04 +0000 |
commit | 6e1cbc012b10e99d9caed19eef43939778d1d8ff (patch) | |
tree | 94a884a96e8412ab0e852f6489321fd83de4b2a6 /src/sksl/SkSLCompiler.cpp | |
parent | 9a03642ad2fce5805642783f68078a0a6bf03554 (diff) |
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>
Diffstat (limited to 'src/sksl/SkSLCompiler.cpp')
-rw-r--r-- | src/sksl/SkSLCompiler.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp index 593397bd2a..3a037e798e 100644 --- a/src/sksl/SkSLCompiler.cpp +++ b/src/sksl/SkSLCompiler.cpp @@ -54,8 +54,9 @@ static const char* SKSL_FP_INCLUDE = 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 @@ void Compiler::simplifyStatement(DefinitionMap& definitions, (*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 @@ void Compiler::simplifyStatement(DefinitionMap& definitions, 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 @@ void Compiler::scanCFG(FunctionDefinition& f) { 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; |