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_IRNODE
9#define SKSL_IRNODE
10
11#include "src/sksl/SkSLLexer.h"
12#include "src/sksl/SkSLString.h"
13
14namespace SkSL {
15
16/**
17 * Represents a node in the intermediate representation (IR) tree. The IR is a fully-resolved
18 * version of the program (all types determined, everything validated), ready for code generation.
19 */
20struct IRNode {
21 IRNode(int offset)
22 : fOffset(offset) {}
23
24 virtual ~IRNode() {}
25
26 virtual int nodeCount() const {
27 SkASSERT(false);
28 return 1;
29 }
30
31 virtual String description() const = 0;
32
33 // character offset of this element within the program being compiled, for error reporting
34 // purposes
35 int fOffset;
36};
37
38} // namespace SkSL
39
40#endif
41