Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: src/sksl/SkSLParser.cpp

Issue 2143323003: Revert of SkSL performance improvements (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/sksl/SkSLIRGenerator.cpp ('k') | src/sksl/SkSLSPIRVCodeGenerator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "stdio.h" 8 #include "stdio.h"
9 #include "SkSLParser.h" 9 #include "SkSLParser.h"
10 #include "SkSLToken.h" 10 #include "SkSLToken.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "ast/SkSLASTPrefixExpression.h" 45 #include "ast/SkSLASTPrefixExpression.h"
46 #include "ast/SkSLASTReturnStatement.h" 46 #include "ast/SkSLASTReturnStatement.h"
47 #include "ast/SkSLASTStatement.h" 47 #include "ast/SkSLASTStatement.h"
48 #include "ast/SkSLASTSuffixExpression.h" 48 #include "ast/SkSLASTSuffixExpression.h"
49 #include "ast/SkSLASTTernaryExpression.h" 49 #include "ast/SkSLASTTernaryExpression.h"
50 #include "ast/SkSLASTType.h" 50 #include "ast/SkSLASTType.h"
51 #include "ast/SkSLASTVarDeclaration.h" 51 #include "ast/SkSLASTVarDeclaration.h"
52 #include "ast/SkSLASTVarDeclarationStatement.h" 52 #include "ast/SkSLASTVarDeclarationStatement.h"
53 #include "ast/SkSLASTWhileStatement.h" 53 #include "ast/SkSLASTWhileStatement.h"
54 #include "ir/SkSLSymbolTable.h" 54 #include "ir/SkSLSymbolTable.h"
55 #include "ir/SkSLType.h"
56 55
57 namespace SkSL { 56 namespace SkSL {
58 57
59 Parser::Parser(std::string text, SymbolTable& types, ErrorReporter& errors) 58 Parser::Parser(std::string text, SymbolTable& types, ErrorReporter& errors)
60 : fPushback(Position(-1, -1), Token::INVALID_TOKEN, "") 59 : fPushback(Position(-1, -1), Token::INVALID_TOKEN, "")
61 , fTypes(types) 60 , fTypes(types)
62 , fErrors(errors) { 61 , fErrors(errors) {
63 sksllex_init(&fScanner); 62 sksllex_init(&fScanner);
64 fBuffer = sksl_scan_string(text.c_str(), fScanner); 63 fBuffer = sksl_scan_string(text.c_str(), fScanner);
65 skslset_lineno(1, fScanner); 64 skslset_lineno(1, fScanner);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 if (!this->expect(Token::LBRACE, "'{'")) { 283 if (!this->expect(Token::LBRACE, "'{'")) {
285 return nullptr; 284 return nullptr;
286 } 285 }
287 std::vector<Type::Field> fields; 286 std::vector<Type::Field> fields;
288 while (this->peek().fKind != Token::RBRACE) { 287 while (this->peek().fKind != Token::RBRACE) {
289 std::unique_ptr<ASTVarDeclaration> decl = this->varDeclaration(); 288 std::unique_ptr<ASTVarDeclaration> decl = this->varDeclaration();
290 if (!decl) { 289 if (!decl) {
291 return nullptr; 290 return nullptr;
292 } 291 }
293 for (size_t i = 0; i < decl->fNames.size(); i++) { 292 for (size_t i = 0; i < decl->fNames.size(); i++) {
294 auto type = (const Type*) fTypes[decl->fType->fName]; 293 auto type = std::static_pointer_cast<Type>(fTypes[decl->fType->fName ]);
295 for (int j = (int) decl->fSizes[i].size() - 1; j >= 0; j--) { 294 for (int j = (int) decl->fSizes[i].size() - 1; j >= 0; j--) {
296 if (decl->fSizes[i][j]->fKind != ASTExpression::kInt_Kind) { 295 if (decl->fSizes[i][j]->fKind == ASTExpression::kInt_Kind) {
297 this->error(decl->fPosition, "array size in struct field mus t be a constant"); 296 this->error(decl->fPosition, "array size in struct field mus t be a constant");
298 } 297 }
299 uint64_t columns = ((ASTIntLiteral&) *decl->fSizes[i][j]).fValue ; 298 uint64_t columns = ((ASTIntLiteral&) *decl->fSizes[i][j]).fValue ;
300 std::string name = type->name() + "[" + to_string(columns) + "]" ; 299 std::string name = type->name() + "[" + to_string(columns) + "]" ;
301 type = new Type(name, Type::kArray_Kind, *type, (int) columns); 300 type = std::shared_ptr<Type>(new Type(name, Type::kArray_Kind, s td::move(type),
302 fTypes.takeOwnership((Type*) type); 301 (int) columns));
303 } 302 }
304 fields.push_back(Type::Field(decl->fModifiers, decl->fNames[i], *typ e)); 303 fields.push_back(Type::Field(decl->fModifiers, decl->fNames[i], std: :move(type)));
305 if (decl->fValues[i]) { 304 if (decl->fValues[i]) {
306 this->error(decl->fPosition, "initializers are not permitted on struct fields"); 305 this->error(decl->fPosition, "initializers are not permitted on struct fields");
307 } 306 }
308 } 307 }
309 } 308 }
310 if (!this->expect(Token::RBRACE, "'}'")) { 309 if (!this->expect(Token::RBRACE, "'}'")) {
311 return nullptr; 310 return nullptr;
312 } 311 }
313 fTypes.add(name.fText, std::unique_ptr<Type>(new Type(name.fText, fields))); 312 std::shared_ptr<Type> type(new Type(name.fText, fields));
314 return std::unique_ptr<ASTType>(new ASTType(name.fPosition, name.fText, 313 fTypes.add(type->fName, type);
314 return std::unique_ptr<ASTType>(new ASTType(name.fPosition, type->fName,
315 ASTType::kStruct_Kind)); 315 ASTType::kStruct_Kind));
316 } 316 }
317 317
318 /* structDeclaration ((IDENTIFIER varDeclarationEnd) | SEMICOLON) */ 318 /* structDeclaration ((IDENTIFIER varDeclarationEnd) | SEMICOLON) */
319 std::unique_ptr<ASTVarDeclaration> Parser::structVarDeclaration(ASTModifiers mod ifiers) { 319 std::unique_ptr<ASTVarDeclaration> Parser::structVarDeclaration(ASTModifiers mod ifiers) {
320 std::unique_ptr<ASTType> type = this->structDeclaration(); 320 std::unique_ptr<ASTType> type = this->structDeclaration();
321 if (!type) { 321 if (!type) {
322 return nullptr; 322 return nullptr;
323 } 323 }
324 if (peek().fKind == Token::IDENTIFIER) { 324 if (peek().fKind == Token::IDENTIFIER) {
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 bool Parser::identifier(std::string* dest) { 1382 bool Parser::identifier(std::string* dest) {
1383 Token t; 1383 Token t;
1384 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { 1384 if (this->expect(Token::IDENTIFIER, "identifier", &t)) {
1385 *dest = t.fText; 1385 *dest = t.fText;
1386 return true; 1386 return true;
1387 } 1387 }
1388 return false; 1388 return false;
1389 } 1389 }
1390 1390
1391 } // namespace 1391 } // namespace
OLDNEW
« no previous file with comments | « src/sksl/SkSLIRGenerator.cpp ('k') | src/sksl/SkSLSPIRVCodeGenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698