Line data Source code
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_INTLITERAL
9 : #define SKSL_INTLITERAL
10 :
11 : #include "SkSLContext.h"
12 : #include "SkSLExpression.h"
13 :
14 : namespace SkSL {
15 :
16 : /**
17 : * A literal integer.
18 : */
19 0 : struct IntLiteral : public Expression {
20 : // FIXME: we will need to revisit this if/when we add full support for both signed and unsigned
21 : // 64-bit integers, but for right now an int64_t will hold every value we care about
22 0 : IntLiteral(const Context& context, Position position, int64_t value, const Type* type = nullptr)
23 0 : : INHERITED(position, kIntLiteral_Kind, type ? *type : *context.fInt_Type)
24 0 : , fValue(value) {}
25 :
26 0 : virtual String description() const override {
27 0 : return to_string(fValue);
28 : }
29 :
30 0 : bool isConstant() const override {
31 0 : return true;
32 : }
33 :
34 : const int64_t fValue;
35 :
36 : typedef Expression INHERITED;
37 : };
38 :
39 : } // namespace
40 :
41 : #endif
|