SkSLIntLiteral.h revision 0df1b04db87c3d86ee0b0bd6aa2cb5b6be32cac2
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
14namespace SkSL {
15
16/**
17 * A literal integer.
18 */
19struct 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    IntLiteral(const Context& context, Position position, int64_t value, const Type* type = nullptr)
23    : INHERITED(position, kIntLiteral_Kind, type ? *type : *context.fInt_Type)
24    , fValue(value) {}
25
26    virtual String description() const override {
27        return to_string(fValue);
28    }
29
30   bool isConstant() const override {
31        return true;
32    }
33
34    const int64_t fValue;
35
36    typedef Expression INHERITED;
37};
38
39} // namespace
40
41#endif
42