OLD | NEW |
---|---|
(Empty) | |
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_FUNCTIONDECLARATION | |
9 #define SKSL_FUNCTIONDECLARATION | |
10 | |
11 #include "SkSLModifiers.h" | |
12 #include "SkSLSymbol.h" | |
13 #include "SkSLType.h" | |
14 #include "SkSLVariable.h" | |
15 | |
16 namespace SkSL { | |
17 | |
18 /** | |
19 * A function declaration (not a definition -- does not contain a body). | |
20 */ | |
21 struct FunctionDeclaration : public Symbol { | |
22 FunctionDeclaration(Position position, std::string name, | |
23 std::vector<std::shared_ptr<Variable>> parameters, | |
24 std::shared_ptr<Type> returnType) | |
25 : INHERITED(position, kFunctionDeclaration_Kind, std::move(name)) | |
26 , fParameters(parameters) | |
27 , fReturnType(returnType) {} | |
28 | |
29 std::string description() const override { | |
30 std::string result = fReturnType->fName + " " + fName + "("; | |
31 std::string separator = ""; | |
32 for (auto p : fParameters) { | |
dogben
2016/06/22 17:43:57
nit: const ref
| |
33 result += separator; | |
34 separator = ", "; | |
35 result += p->description(); | |
36 } | |
37 result += ")"; | |
38 return result; | |
39 } | |
40 | |
41 bool matches(std::shared_ptr<FunctionDeclaration> f) { | |
42 return fName == f->fName && fParameters == f->fParameters; | |
43 } | |
44 | |
45 mutable bool fDefined; | |
dogben
2016/06/22 17:43:57
nit: seems like this doesn't need to be mutable.
ethannicholas
2016/06/24 21:23:10
While you are correct that it isn't needed from a
| |
46 const std::vector<std::shared_ptr<Variable>> fParameters; | |
47 const std::shared_ptr<Type> fReturnType; | |
48 | |
49 typedef Symbol INHERITED; | |
50 }; | |
51 | |
52 } // namespace | |
53 | |
54 #endif | |
OLD | NEW |