Chromium Code Reviews| 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 + "("; | |
|
dogben
2016/06/21 21:52:50
nit: maybe fReturnType->description()?
| |
| 31 std::string separator = ""; | |
| 32 for (auto p : fParameters) { | |
|
dogben
2016/06/21 21:52:50
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) { | |
|
dogben
2016/06/21 21:52:50
Should this method be const?
nit: parameter can b
| |
| 42 return fName == f->fName && fParameters == f->fParameters; | |
| 43 } | |
| 44 | |
| 45 mutable bool fDefined; | |
|
dogben
2016/06/21 21:52:50
nit: Seems like this doesn't really need to be mut
| |
| 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 |