diff options
author | 2017-05-10 15:06:17 -0400 | |
---|---|---|
committer | 2017-05-10 19:31:34 +0000 | |
commit | 5ac13c23628c6ee8c3f6056f38527706b403e502 (patch) | |
tree | c8a96588eed9009037bd368bb155a0f990cd4cc3 /src/sksl/ir | |
parent | 37c5a96bbdeac2000c8b31d40f4786b31c39f2dd (diff) |
sksl support for static ifs & switches
Bug: skia:
Change-Id: Ic9e01a3a18efddb19bab26e92bfb473cad294fc1
Reviewed-on: https://skia-review.googlesource.com/16144
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'src/sksl/ir')
-rw-r--r-- | src/sksl/ir/SkSLBlock.h | 2 | ||||
-rw-r--r-- | src/sksl/ir/SkSLIfStatement.h | 10 | ||||
-rw-r--r-- | src/sksl/ir/SkSLSwitchStatement.h | 10 |
3 files changed, 17 insertions, 5 deletions
diff --git a/src/sksl/ir/SkSLBlock.h b/src/sksl/ir/SkSLBlock.h index 11976660b7..bcd4bb1b59 100644 --- a/src/sksl/ir/SkSLBlock.h +++ b/src/sksl/ir/SkSLBlock.h @@ -18,7 +18,7 @@ namespace SkSL { */ struct Block : public Statement { Block(Position position, std::vector<std::unique_ptr<Statement>> statements, - const std::shared_ptr<SymbolTable> symbols) + const std::shared_ptr<SymbolTable> symbols = nullptr) : INHERITED(position, kBlock_Kind) , fSymbols(std::move(symbols)) , fStatements(std::move(statements)) {} diff --git a/src/sksl/ir/SkSLIfStatement.h b/src/sksl/ir/SkSLIfStatement.h index 0377b1253d..b09c10ee95 100644 --- a/src/sksl/ir/SkSLIfStatement.h +++ b/src/sksl/ir/SkSLIfStatement.h @@ -17,21 +17,27 @@ namespace SkSL { * An 'if' statement. */ struct IfStatement : public Statement { - IfStatement(Position position, std::unique_ptr<Expression> test, + IfStatement(Position position, bool isStatic, std::unique_ptr<Expression> test, std::unique_ptr<Statement> ifTrue, std::unique_ptr<Statement> ifFalse) : INHERITED(position, kIf_Kind) + , fIsStatic(isStatic) , fTest(std::move(test)) , fIfTrue(std::move(ifTrue)) , fIfFalse(std::move(ifFalse)) {} String description() const override { - String result = "if (" + fTest->description() + ") " + fIfTrue->description(); + String result; + if (fIsStatic) { + result += "@"; + } + result += "if (" + fTest->description() + ") " + fIfTrue->description(); if (fIfFalse) { result += " else " + fIfFalse->description(); } return result; } + bool fIsStatic; std::unique_ptr<Expression> fTest; std::unique_ptr<Statement> fIfTrue; // may be null diff --git a/src/sksl/ir/SkSLSwitchStatement.h b/src/sksl/ir/SkSLSwitchStatement.h index 88e1e70019..3837554b0d 100644 --- a/src/sksl/ir/SkSLSwitchStatement.h +++ b/src/sksl/ir/SkSLSwitchStatement.h @@ -17,14 +17,19 @@ namespace SkSL { * A 'switch' statement. */ struct SwitchStatement : public Statement { - SwitchStatement(Position position, std::unique_ptr<Expression> value, + SwitchStatement(Position position, bool isStatic, std::unique_ptr<Expression> value, std::vector<std::unique_ptr<SwitchCase>> cases) : INHERITED(position, kSwitch_Kind) + , fIsStatic(isStatic) , fValue(std::move(value)) , fCases(std::move(cases)) {} String description() const override { - String result = String::printf("switch (%s) {\n", + fValue->description().c_str()); + String result; + if (fIsStatic) { + result += "@"; + } + result += String::printf("switch (%s) {\n", fValue->description().c_str()); for (const auto& c : fCases) { result += c->description(); } @@ -32,6 +37,7 @@ struct SwitchStatement : public Statement { return result; } + bool fIsStatic; std::unique_ptr<Expression> fValue; std::vector<std::unique_ptr<SwitchCase>> fCases; |