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)* | 529 /* LAYOUT LPAREN IDENTIFIER (EQ INT_LITERAL)? (COMMA IDENTIFIER (EQ INT_LITERAL)
?)* RPAREN */ |
530 RPAREN */ | |
531 ASTLayout Parser::layout() { | 530 ASTLayout Parser::layout() { |
532 int location = -1; | 531 int location = -1; |
533 int binding = -1; | 532 int binding = -1; |
534 int index = -1; | 533 int index = -1; |
535 int set = -1; | 534 int set = -1; |
536 int builtin = -1; | 535 int builtin = -1; |
537 bool originUpperLeft = false; | 536 bool originUpperLeft = false; |
538 bool overrideCoverage = false; | 537 bool overrideCoverage = false; |
539 bool blendSupportAllEquations = false; | 538 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); | 544 overrideCoverage, blendSupportAllEquations, pushCon
stant); |
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; |
564 } else { | 566 } else { |
565 this->error(t.fPosition, ("'" + t.fText + | 567 this->error(t.fPosition, ("'" + t.fText + |
566 "' is not a valid layout qualifier").c
_str()); | 568 "' is not a valid layout qualifier").c
_str()); |
567 } | 569 } |
568 if (this->peek().fKind == Token::RPAREN) { | 570 if (this->peek().fKind == Token::RPAREN) { |
569 this->nextToken(); | 571 this->nextToken(); |
570 break; | 572 break; |
571 } | 573 } |
572 if (!this->expect(Token::COMMA, "','")) { | 574 if (!this->expect(Token::COMMA, "','")) { |
573 break; | 575 break; |
574 } | 576 } |
575 } | 577 } |
576 } | 578 } |
577 return ASTLayout(location, binding, index, set, builtin, originUpperLeft, ov
errideCoverage, | 579 return ASTLayout(location, binding, index, set, builtin, originUpperLeft, ov
errideCoverage, |
578 blendSupportAllEquations); | 580 blendSupportAllEquations, pushConstant); |
579 } | 581 } |
580 | 582 |
581 /* layout? (UNIFORM | CONST | IN | OUT | INOUT | LOWP | MEDIUMP | HIGHP | FLAT |
NOPERSPECTIVE)* */ | 583 /* layout? (UNIFORM | CONST | IN | OUT | INOUT | LOWP | MEDIUMP | HIGHP | FLAT |
NOPERSPECTIVE)* */ |
582 ASTModifiers Parser::modifiers() { | 584 ASTModifiers Parser::modifiers() { |
583 ASTLayout layout = this->layout(); | 585 ASTLayout layout = this->layout(); |
584 int flags = 0; | 586 int flags = 0; |
585 for (;;) { | 587 for (;;) { |
586 // TODO: handle duplicate / incompatible flags | 588 // TODO: handle duplicate / incompatible flags |
587 switch (peek().fKind) { | 589 switch (peek().fKind) { |
588 case Token::UNIFORM: | 590 case Token::UNIFORM: |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 bool Parser::identifier(std::string* dest) { | 1489 bool Parser::identifier(std::string* dest) { |
1488 Token t; | 1490 Token t; |
1489 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { | 1491 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { |
1490 *dest = t.fText; | 1492 *dest = t.fText; |
1491 return true; | 1493 return true; |
1492 } | 1494 } |
1493 return false; | 1495 return false; |
1494 } | 1496 } |
1495 | 1497 |
1496 } // namespace | 1498 } // namespace |
OLD | NEW |