OLD | NEW |
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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 if (!this->expect(Token::EQ, "'='")) { | 519 if (!this->expect(Token::EQ, "'='")) { |
520 return -1; | 520 return -1; |
521 } | 521 } |
522 Token resultToken; | 522 Token resultToken; |
523 if (this->expect(Token::INT_LITERAL, "a non-negative integer", &resultToken)
) { | 523 if (this->expect(Token::INT_LITERAL, "a non-negative integer", &resultToken)
) { |
524 return SkSL::stoi(resultToken.fText); | 524 return SkSL::stoi(resultToken.fText); |
525 } | 525 } |
526 return -1; | 526 return -1; |
527 } | 527 } |
528 | 528 |
529 /* LAYOUT LPAREN IDENTIFIER (EQ INT_LITERAL)? (COMMA IDENTIFIER (EQ INT_LITERAL)
?)* RPAREN */ | 529 /* LAYOUT LPAREN IDENTIFIER EQ INT_LITERAL (COMMA IDENTIFIER EQ INT_LITERAL)* |
| 530 RPAREN */ |
530 ASTLayout Parser::layout() { | 531 ASTLayout Parser::layout() { |
531 int location = -1; | 532 int location = -1; |
532 int binding = -1; | 533 int binding = -1; |
533 int index = -1; | 534 int index = -1; |
534 int set = -1; | 535 int set = -1; |
535 int builtin = -1; | 536 int builtin = -1; |
536 bool originUpperLeft = false; | 537 bool originUpperLeft = false; |
537 bool overrideCoverage = false; | 538 bool overrideCoverage = false; |
538 bool blendSupportAllEquations = false; | 539 bool blendSupportAllEquations = false; |
539 bool pushConstant = false; | |
540 if (this->peek().fKind == Token::LAYOUT) { | 540 if (this->peek().fKind == Token::LAYOUT) { |
541 this->nextToken(); | 541 this->nextToken(); |
542 if (!this->expect(Token::LPAREN, "'('")) { | 542 if (!this->expect(Token::LPAREN, "'('")) { |
543 return ASTLayout(location, binding, index, set, builtin, originUpper
Left, | 543 return ASTLayout(location, binding, index, set, builtin, originUpper
Left, |
544 overrideCoverage, blendSupportAllEquations, pushCon
stant); | 544 overrideCoverage, blendSupportAllEquations); |
545 } | 545 } |
546 for (;;) { | 546 for (;;) { |
547 Token t = this->nextToken(); | 547 Token t = this->nextToken(); |
548 if (t.fText == "location") { | 548 if (t.fText == "location") { |
549 location = this->layoutInt(); | 549 location = this->layoutInt(); |
550 } else if (t.fText == "binding") { | 550 } else if (t.fText == "binding") { |
551 binding = this->layoutInt(); | 551 binding = this->layoutInt(); |
552 } else if (t.fText == "index") { | 552 } else if (t.fText == "index") { |
553 index = this->layoutInt(); | 553 index = this->layoutInt(); |
554 } else if (t.fText == "set") { | 554 } else if (t.fText == "set") { |
555 set = this->layoutInt(); | 555 set = this->layoutInt(); |
556 } else if (t.fText == "builtin") { | 556 } else if (t.fText == "builtin") { |
557 builtin = this->layoutInt(); | 557 builtin = this->layoutInt(); |
558 } else if (t.fText == "origin_upper_left") { | 558 } else if (t.fText == "origin_upper_left") { |
559 originUpperLeft = true; | 559 originUpperLeft = true; |
560 } else if (t.fText == "override_coverage") { | 560 } else if (t.fText == "override_coverage") { |
561 overrideCoverage = true; | 561 overrideCoverage = true; |
562 } else if (t.fText == "blend_support_all_equations") { | 562 } else if (t.fText == "blend_support_all_equations") { |
563 blendSupportAllEquations = true; | 563 blendSupportAllEquations = true; |
564 } else if (t.fText == "push_constant") { | |
565 pushConstant = true; | |
566 } else { | 564 } else { |
567 this->error(t.fPosition, ("'" + t.fText + | 565 this->error(t.fPosition, ("'" + t.fText + |
568 "' is not a valid layout qualifier").c
_str()); | 566 "' is not a valid layout qualifier").c
_str()); |
569 } | 567 } |
570 if (this->peek().fKind == Token::RPAREN) { | 568 if (this->peek().fKind == Token::RPAREN) { |
571 this->nextToken(); | 569 this->nextToken(); |
572 break; | 570 break; |
573 } | 571 } |
574 if (!this->expect(Token::COMMA, "','")) { | 572 if (!this->expect(Token::COMMA, "','")) { |
575 break; | 573 break; |
576 } | 574 } |
577 } | 575 } |
578 } | 576 } |
579 return ASTLayout(location, binding, index, set, builtin, originUpperLeft, ov
errideCoverage, | 577 return ASTLayout(location, binding, index, set, builtin, originUpperLeft, ov
errideCoverage, |
580 blendSupportAllEquations, pushConstant); | 578 blendSupportAllEquations); |
581 } | 579 } |
582 | 580 |
583 /* layout? (UNIFORM | CONST | IN | OUT | INOUT | LOWP | MEDIUMP | HIGHP | FLAT |
NOPERSPECTIVE)* */ | 581 /* layout? (UNIFORM | CONST | IN | OUT | INOUT | LOWP | MEDIUMP | HIGHP | FLAT |
NOPERSPECTIVE)* */ |
584 ASTModifiers Parser::modifiers() { | 582 ASTModifiers Parser::modifiers() { |
585 ASTLayout layout = this->layout(); | 583 ASTLayout layout = this->layout(); |
586 int flags = 0; | 584 int flags = 0; |
587 for (;;) { | 585 for (;;) { |
588 // TODO: handle duplicate / incompatible flags | 586 // TODO: handle duplicate / incompatible flags |
589 switch (peek().fKind) { | 587 switch (peek().fKind) { |
590 case Token::UNIFORM: | 588 case Token::UNIFORM: |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 bool Parser::identifier(std::string* dest) { | 1487 bool Parser::identifier(std::string* dest) { |
1490 Token t; | 1488 Token t; |
1491 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { | 1489 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { |
1492 *dest = t.fText; | 1490 *dest = t.fText; |
1493 return true; | 1491 return true; |
1494 } | 1492 } |
1495 return false; | 1493 return false; |
1496 } | 1494 } |
1497 | 1495 |
1498 } // namespace | 1496 } // namespace |
OLD | NEW |