aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLParser.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2016-11-20 14:53:35 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-20 14:53:48 +0000
commit792d0f13d6cb58ddf27b45e6835ba54c1d8ade77 (patch)
tree929ba3d4638561e480bb070da4d01eec2cce21ab /src/sksl/SkSLParser.cpp
parent7a5b48a75b6f5819c196d158eefa70677783554f (diff)
Revert "switched skslc from std::string to SkString"
This reverts commit d8df21a1e08b5b3380261f4b90acfbdc538ef93c. Reason for revert: Breaking Roll Original change's description: > switched skslc from std::string to SkString > > BUG=skia: > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4977 > > Change-Id: I15e24963b09b719a2c07da67745114f5ac66cee8 > Reviewed-on: https://skia-review.googlesource.com/4977 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > TBR=bsalomon@google.com,benjaminwagner@google.com,ethannicholas@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I84d5311beb9d5e607b7a4a3c138332f0c8f19648 Reviewed-on: https://skia-review.googlesource.com/5077 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/sksl/SkSLParser.cpp')
-rw-r--r--src/sksl/SkSLParser.cpp37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index 03d0d337a8..2be664dbd8 100644
--- a/src/sksl/SkSLParser.cpp
+++ b/src/sksl/SkSLParser.cpp
@@ -88,7 +88,7 @@ public:
bool checkValid() {
if (fParser->fDepth > MAX_PARSE_DEPTH) {
- fParser->error(fParser->peek().fPosition, SkString("exceeded max parse depth"));
+ fParser->error(fParser->peek().fPosition, "exceeded max parse depth");
return false;
}
return true;
@@ -98,8 +98,8 @@ private:
Parser* fParser;
};
-Parser::Parser(SkString text, SymbolTable& types, ErrorReporter& errors)
-: fPushback(Position(-1, -1), Token::INVALID_TOKEN, SkString())
+Parser::Parser(std::string text, SymbolTable& types, ErrorReporter& errors)
+: fPushback(Position(-1, -1), Token::INVALID_TOKEN, "")
, fTypes(types)
, fErrors(errors) {
sksllex_init(&fScanner);
@@ -157,13 +157,13 @@ Token Parser::nextToken() {
return result;
}
int token = sksllex(fScanner);
- SkString text;
+ std::string text;
switch ((Token::Kind) token) {
case Token::IDENTIFIER: // fall through
case Token::INT_LITERAL: // fall through
case Token::FLOAT_LITERAL: // fall through
case Token::DIRECTIVE:
- text = SkString(skslget_text(fScanner));
+ text = std::string(skslget_text(fScanner));
break;
default:
break;
@@ -181,12 +181,7 @@ Token Parser::peek() {
return fPushback;
}
-
-bool Parser::expect(Token::Kind kind, const char* expected, Token* result) {
- return this->expect(kind, SkString(expected), result);
-}
-
-bool Parser::expect(Token::Kind kind, SkString expected, Token* result) {
+bool Parser::expect(Token::Kind kind, std::string expected, Token* result) {
Token next = this->nextToken();
if (next.fKind == kind) {
if (result) {
@@ -199,15 +194,11 @@ bool Parser::expect(Token::Kind kind, SkString expected, Token* result) {
}
}
-void Parser::error(Position p, const char* msg) {
- this->error(p, SkString(msg));
-}
-
-void Parser::error(Position p, SkString msg) {
+void Parser::error(Position p, std::string msg) {
fErrors.error(p, msg);
}
-bool Parser::isType(SkString name) {
+bool Parser::isType(std::string name) {
return nullptr != fTypes[name];
}
@@ -379,7 +370,7 @@ std::unique_ptr<ASTType> Parser::structDeclaration() {
return nullptr;
}
uint64_t columns = ((ASTIntLiteral&) *var.fSizes[i]).fValue;
- SkString name = type->name() + "[" + to_string(columns) + "]";
+ std::string name = type->name() + "[" + to_string(columns) + "]";
type = new Type(name, Type::kArray_Kind, *type, (int) columns);
fTypes.takeOwnership((Type*) type);
}
@@ -426,7 +417,7 @@ std::unique_ptr<ASTVarDeclarations> Parser::structVarDeclaration(ASTModifiers mo
(LBRACKET expression? RBRACKET)* (EQ expression)?)* SEMICOLON */
std::unique_ptr<ASTVarDeclarations> Parser::varDeclarationEnd(ASTModifiers mods,
std::unique_ptr<ASTType> type,
- SkString name) {
+ std::string name) {
std::vector<ASTVarDeclaration> vars;
std::vector<std::unique_ptr<ASTExpression>> currentVarSizes;
while (this->peek().fKind == Token::LBRACKET) {
@@ -740,7 +731,7 @@ std::unique_ptr<ASTDeclaration> Parser::interfaceBlock(ASTModifiers mods) {
decls.push_back(std::move(decl));
}
this->nextToken();
- SkString valueName;
+ std::string valueName;
if (this->peek().fKind == Token::IDENTIFIER) {
valueName = this->nextToken().fText;
}
@@ -1370,7 +1361,7 @@ std::unique_ptr<ASTSuffix> Parser::suffix() {
}
case Token::DOT: {
Position pos = this->peek().fPosition;
- SkString text;
+ std::string text;
if (this->identifier(&text)) {
return std::unique_ptr<ASTSuffix>(new ASTFieldSuffix(pos, std::move(text)));
}
@@ -1415,7 +1406,7 @@ std::unique_ptr<ASTExpression> Parser::term() {
Token t = this->peek();
switch (t.fKind) {
case Token::IDENTIFIER: {
- SkString text;
+ std::string text;
if (this->identifier(&text)) {
result.reset(new ASTIdentifier(t.fPosition, std::move(text)));
}
@@ -1496,7 +1487,7 @@ bool Parser::boolLiteral(bool* dest) {
}
/* IDENTIFIER */
-bool Parser::identifier(SkString* dest) {
+bool Parser::identifier(std::string* dest) {
Token t;
if (this->expect(Token::IDENTIFIER, "identifier", &t)) {
*dest = t.fText;