• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SKSL_ASTPRECISION
9 #define SKSL_ASTPRECISION
10 
11 #include "SkSLASTDeclaration.h"
12 #include "../ir/SkSLModifiers.h"
13 
14 namespace SkSL {
15 
16 /**
17  * Represents a precision declaration (e.g. 'precision mediump float;').
18  */
19 struct ASTPrecision : public ASTDeclaration {
20     // FIXME handle the type
ASTPrecisionASTPrecision21     ASTPrecision(int offset, Modifiers::Flag precision)
22     : INHERITED(offset, kPrecision_Kind)
23     , fPrecision(precision) {}
24 
descriptionASTPrecision25     String description() const {
26         switch (fPrecision) {
27             case Modifiers::kLowp_Flag: return String("precision lowp float;");
28             case Modifiers::kMediump_Flag: return String("precision mediump float;");
29             case Modifiers::kHighp_Flag: return String("precision highp float;");
30             default:
31                 ASSERT(false);
32                 return String("<error>");
33         }
34         ASSERT(false);
35         return String("<error>");
36     }
37 
38     const Modifiers::Flag fPrecision;
39 
40     typedef ASTDeclaration INHERITED;
41 };
42 
43 } // namespace
44 
45 #endif
46