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_ASTPARAMETER
9 : #define SKSL_ASTPARAMETER
10 :
11 : #include "SkSLASTPositionNode.h"
12 : #include "SkSLASTType.h"
13 : #include "../ir/SkSLModifiers.h"
14 :
15 : namespace SkSL {
16 :
17 : /**
18 : * A declaration of a parameter, as part of a function declaration.
19 : */
20 0 : struct ASTParameter : public ASTPositionNode {
21 : // 'sizes' is a list of the array sizes appearing on a parameter, in source order.
22 : // e.g. int x[3][1] would have sizes [3, 1].
23 0 : ASTParameter(Position position, Modifiers modifiers, std::unique_ptr<ASTType> type,
24 : String name, std::vector<int> sizes)
25 0 : : INHERITED(position)
26 : , fModifiers(modifiers)
27 0 : , fType(std::move(type))
28 0 : , fName(std::move(name))
29 0 : , fSizes(std::move(sizes)) {}
30 :
31 0 : String description() const override {
32 0 : String result = fModifiers.description() + fType->description() + " " + fName;
33 0 : for (int size : fSizes) {
34 0 : result += "[" + to_string(size) + "]";
35 : }
36 0 : return result;
37 : }
38 :
39 : const Modifiers fModifiers;
40 : const std::unique_ptr<ASTType> fType;
41 : const String fName;
42 : const std::vector<int> fSizes;
43 :
44 : typedef ASTPositionNode INHERITED;
45 : };
46 :
47 : } // namespace
48 :
49 : #endif
|