aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLParser.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-09-18 02:41:08 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-18 03:01:47 +0000
commit27185a9b9756d2f5fcc077c6c2c005259d4ba517 (patch)
tree7b1747160cb0fb3fb69ecd61de24f4310ee8cf7b /src/sksl/SkSLParser.cpp
parent56fbbd65807d1c4ff63b5233764c6e15cba51bb4 (diff)
Revert "Revert "Revert "Switched highp float to highfloat and mediump float to half."""
This reverts commit 05d5a13fea6246648de7e41358ed338d53c85ea2. Reason for revert: looks like it broke filterfastbounds Original change's description: > Revert "Revert "Switched highp float to highfloat and mediump float to half."" > > This reverts commit 1d816b92bb7cf2258007f3f74ffd143b89f25d01. > > Bug: skia: > Change-Id: I388b5e5e9bf619db48297a80c9a80c039f26c9f1 > Reviewed-on: https://skia-review.googlesource.com/46464 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> TBR=bsalomon@google.com,ethannicholas@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia: Change-Id: Iddf6aef2ab084aa73da7ceebdfc303a1d2b80cde Reviewed-on: https://skia-review.googlesource.com/47441 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLParser.cpp')
-rw-r--r--src/sksl/SkSLParser.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index 9bfa62f2f5..d8ecc618bc 100644
--- a/src/sksl/SkSLParser.cpp
+++ b/src/sksl/SkSLParser.cpp
@@ -29,6 +29,7 @@
#include "ast/SkSLASTIntLiteral.h"
#include "ast/SkSLASTModifiersDeclaration.h"
#include "ast/SkSLASTParameter.h"
+#include "ast/SkSLASTPrecision.h"
#include "ast/SkSLASTPrefixExpression.h"
#include "ast/SkSLASTReturnStatement.h"
#include "ast/SkSLASTSection.h"
@@ -80,13 +81,20 @@ Parser::Parser(const char* text, size_t length, SymbolTable& types, ErrorReporte
fLexer.start(text, length);
}
-/* (directive | section | declaration)* END_OF_FILE */
+/* (precision | directive | section | declaration)* END_OF_FILE */
std::vector<std::unique_ptr<ASTDeclaration>> Parser::file() {
std::vector<std::unique_ptr<ASTDeclaration>> result;
for (;;) {
switch (this->peek().fKind) {
case Token::END_OF_FILE:
return result;
+ case Token::PRECISION: {
+ std::unique_ptr<ASTDeclaration> precision = this->precision();
+ if (precision) {
+ result.push_back(std::move(precision));
+ }
+ break;
+ }
case Token::DIRECTIVE: {
std::unique_ptr<ASTDeclaration> decl = this->directive();
if (decl) {
@@ -188,6 +196,36 @@ bool Parser::isType(StringFragment name) {
return nullptr != fTypes[name];
}
+/* PRECISION (LOWP | MEDIUMP | HIGHP) type SEMICOLON */
+std::unique_ptr<ASTDeclaration> Parser::precision() {
+ if (!this->expect(Token::PRECISION, "'precision'")) {
+ return nullptr;
+ }
+ Modifiers::Flag result;
+ Token p = this->nextToken();
+ switch (p.fKind) {
+ case Token::LOWP:
+ result = Modifiers::kLowp_Flag;
+ break;
+ case Token::MEDIUMP:
+ result = Modifiers::kMediump_Flag;
+ break;
+ case Token::HIGHP:
+ result = Modifiers::kHighp_Flag;
+ break;
+ default:
+ this->error(p, "expected 'lowp', 'mediump', or 'highp', but found '" +
+ this->text(p) + "'");
+ return nullptr;
+ }
+ // FIXME handle the type
+ if (!this->type()) {
+ return nullptr;
+ }
+ this->expect(Token::SEMICOLON, "';'");
+ return std::unique_ptr<ASTDeclaration>(new ASTPrecision(p.fOffset, result));
+}
+
/* DIRECTIVE(#version) INT_LITERAL ("es" | "compatibility")? |
DIRECTIVE(#extension) IDENTIFIER COLON IDENTIFIER */
std::unique_ptr<ASTDeclaration> Parser::directive() {