blob: 01227c637e2196cb547ec9bfa9ca67319d4319d7 [file] [log] [blame]
ethannicholasb3058bd2016-07-01 08:22:01 -07001/*
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 */
Ethan Nicholas11d53972016-11-28 11:23:23 -05007
ethannicholasb3058bd2016-07-01 08:22:01 -07008#ifndef SKSL_ASTPARAMETER
9#define SKSL_ASTPARAMETER
10
Hal Canary6b20a552017-02-07 14:09:38 -050011#include "SkSLASTPositionNode.h"
ethannicholasb3058bd2016-07-01 08:22:01 -070012#include "SkSLASTType.h"
Ethan Nicholas11d53972016-11-28 11:23:23 -050013#include "../ir/SkSLModifiers.h"
ethannicholasb3058bd2016-07-01 08:22:01 -070014
15namespace SkSL {
16
17/**
18 * A declaration of a parameter, as part of a function declaration.
19 */
20struct ASTParameter : public ASTPositionNode {
Ethan Nicholas11d53972016-11-28 11:23:23 -050021 // 'sizes' is a list of the array sizes appearing on a parameter, in source order.
ethannicholasb3058bd2016-07-01 08:22:01 -070022 // e.g. int x[3][1] would have sizes [3, 1].
Ethan Nicholas11d53972016-11-28 11:23:23 -050023 ASTParameter(Position position, Modifiers modifiers, std::unique_ptr<ASTType> type,
Ethan Nicholas0df1b042017-03-31 13:56:23 -040024 String name, std::vector<int> sizes)
ethannicholasb3058bd2016-07-01 08:22:01 -070025 : INHERITED(position)
26 , fModifiers(modifiers)
27 , fType(std::move(type))
28 , fName(std::move(name))
29 , fSizes(std::move(sizes)) {}
30
Ethan Nicholas0df1b042017-03-31 13:56:23 -040031 String description() const override {
32 String result = fModifiers.description() + fType->description() + " " + fName;
ethannicholasb3058bd2016-07-01 08:22:01 -070033 for (int size : fSizes) {
34 result += "[" + to_string(size) + "]";
35 }
36 return result;
37 }
38
Ethan Nicholas11d53972016-11-28 11:23:23 -050039 const Modifiers fModifiers;
ethannicholasb3058bd2016-07-01 08:22:01 -070040 const std::unique_ptr<ASTType> fType;
Ethan Nicholas0df1b042017-03-31 13:56:23 -040041 const String fName;
ethannicholasb3058bd2016-07-01 08:22:01 -070042 const std::vector<int> fSizes;
43
44 typedef ASTPositionNode INHERITED;
45};
46
47} // namespace
48
49#endif