aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLIRGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-02-23 16:18:54 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-23 16:20:10 +0000
commit7d975fc200bbbea991ec4c04c08f3a5ea7b847af (patch)
tree813ff12f25afc903a65880be187ef88162fad866 /src/sksl/SkSLIRGenerator.cpp
parentd196cbe9c270799a6edb6e110ab647c5a4a850a2 (diff)
Revert "skslc switch support"
This reverts commit 2b1e468dabd2ac7bea7ec17740275f4f4aad30c3. Reason for revert: bot breakage Original change's description: > skslc switch support > > BUG=skia: > > Change-Id: Ida7f9e80139aa1e4f43804cafbcac640e47fab25 > Reviewed-on: https://skia-review.googlesource.com/8771 > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Ben Wagner <benjaminwagner@google.com> > TBR=benjaminwagner@google.com,ethannicholas@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Change-Id: Iaaa35d10a15704279c6883d4d68f6d4ad5078320 Reviewed-on: https://skia-review.googlesource.com/8792 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLIRGenerator.cpp')
-rw-r--r--src/sksl/SkSLIRGenerator.cpp78
1 files changed, 2 insertions, 76 deletions
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index ae2a90f899..247766f51e 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -8,7 +8,6 @@
#include "SkSLIRGenerator.h"
#include "limits.h"
-#include <unordered_set>
#include "SkSLCompiler.h"
#include "ast/SkSLASTBoolLiteral.h"
@@ -40,8 +39,6 @@
#include "ir/SkSLPostfixExpression.h"
#include "ir/SkSLPrefixExpression.h"
#include "ir/SkSLReturnStatement.h"
-#include "ir/SkSLSwitchCase.h"
-#include "ir/SkSLSwitchStatement.h"
#include "ir/SkSLSwizzle.h"
#include "ir/SkSLTernaryExpression.h"
#include "ir/SkSLUnresolvedFunction.h"
@@ -84,27 +81,12 @@ public:
IRGenerator* fIR;
};
-class AutoSwitchLevel {
-public:
- AutoSwitchLevel(IRGenerator* ir)
- : fIR(ir) {
- fIR->fSwitchLevel++;
- }
-
- ~AutoSwitchLevel() {
- fIR->fSwitchLevel--;
- }
-
- IRGenerator* fIR;
-};
-
IRGenerator::IRGenerator(const Context* context, std::shared_ptr<SymbolTable> symbolTable,
ErrorReporter& errorReporter)
: fContext(*context)
, fCurrentFunction(nullptr)
, fSymbolTable(std::move(symbolTable))
, fLoopLevel(0)
-, fSwitchLevel(0)
, fErrors(errorReporter) {}
void IRGenerator::pushSymbolTable() {
@@ -171,8 +153,6 @@ std::unique_ptr<Statement> IRGenerator::convertStatement(const ASTStatement& sta
return this->convertWhile((ASTWhileStatement&) statement);
case ASTStatement::kDo_Kind:
return this->convertDo((ASTDoStatement&) statement);
- case ASTStatement::kSwitch_Kind:
- return this->convertSwitch((ASTSwitchStatement&) statement);
case ASTStatement::kReturn_Kind:
return this->convertReturn((ASTReturnStatement&) statement);
case ASTStatement::kBreak_Kind:
@@ -377,60 +357,6 @@ std::unique_ptr<Statement> IRGenerator::convertDo(const ASTDoStatement& d) {
std::move(test)));
}
-std::unique_ptr<Statement> IRGenerator::convertSwitch(const ASTSwitchStatement& s) {
- AutoSwitchLevel level(this);
- std::unique_ptr<Expression> value = this->convertExpression(*s.fValue);
- if (!value) {
- return nullptr;
- }
- if (value->fType != *fContext.fUInt_Type) {
- value = this->coerce(std::move(value), *fContext.fInt_Type);
- if (!value) {
- return nullptr;
- }
- }
- AutoSymbolTable table(this);
- std::unordered_set<int> caseValues;
- std::vector<std::unique_ptr<SwitchCase>> cases;
- for (const auto& c : s.fCases) {
- std::unique_ptr<Expression> caseValue;
- if (c->fValue) {
- caseValue = this->convertExpression(*c->fValue);
- if (!caseValue) {
- return nullptr;
- }
- if (caseValue->fType != *fContext.fUInt_Type) {
- caseValue = this->coerce(std::move(caseValue), *fContext.fInt_Type);
- if (!caseValue) {
- return nullptr;
- }
- }
- if (!caseValue->isConstant()) {
- fErrors.error(caseValue->fPosition, "case value must be a constant");
- return nullptr;
- }
- ASSERT(caseValue->fKind == Expression::kIntLiteral_Kind);
- int64_t v = ((IntLiteral&) *caseValue).fValue;
- if (caseValues.find(v) != caseValues.end()) {
- fErrors.error(caseValue->fPosition, "duplicate case value");
- }
- caseValues.insert(v);
- }
- std::vector<std::unique_ptr<Statement>> statements;
- for (const auto& s : c->fStatements) {
- std::unique_ptr<Statement> converted = this->convertStatement(*s);
- if (!converted) {
- return nullptr;
- }
- statements.push_back(std::move(converted));
- }
- cases.emplace_back(new SwitchCase(c->fPosition, std::move(caseValue),
- std::move(statements)));
- }
- return std::unique_ptr<Statement>(new SwitchStatement(s.fPosition, std::move(value),
- std::move(cases)));
-}
-
std::unique_ptr<Statement> IRGenerator::convertExpressionStatement(
const ASTExpressionStatement& s) {
std::unique_ptr<Expression> e = this->convertExpression(*s.fExpression);
@@ -467,10 +393,10 @@ std::unique_ptr<Statement> IRGenerator::convertReturn(const ASTReturnStatement&
}
std::unique_ptr<Statement> IRGenerator::convertBreak(const ASTBreakStatement& b) {
- if (fLoopLevel > 0 || fSwitchLevel > 0) {
+ if (fLoopLevel > 0) {
return std::unique_ptr<Statement>(new BreakStatement(b.fPosition));
} else {
- fErrors.error(b.fPosition, "break statement must be inside a loop or switch");
+ fErrors.error(b.fPosition, "break statement must be inside a loop");
return nullptr;
}
}