| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SKSL_FUNCTIONDECLARATION | 8 #ifndef SKSL_FUNCTIONDECLARATION |
| 9 #define SKSL_FUNCTIONDECLARATION | 9 #define SKSL_FUNCTIONDECLARATION |
| 10 | 10 |
| 11 #include "SkSLModifiers.h" | 11 #include "SkSLModifiers.h" |
| 12 #include "SkSLSymbol.h" | 12 #include "SkSLSymbol.h" |
| 13 #include "SkSLSymbolTable.h" | 13 #include "SkSLSymbolTable.h" |
| 14 #include "SkSLType.h" | 14 #include "SkSLType.h" |
| 15 #include "SkSLVariable.h" | 15 #include "SkSLVariable.h" |
| 16 | 16 |
| 17 namespace SkSL { | 17 namespace SkSL { |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * A function declaration (not a definition -- does not contain a body). | 20 * A function declaration (not a definition -- does not contain a body). |
| 21 */ | 21 */ |
| 22 struct FunctionDeclaration : public Symbol { | 22 struct FunctionDeclaration : public Symbol { |
| 23 FunctionDeclaration(Position position, std::string name, | 23 FunctionDeclaration(Position position, std::string name, |
| 24 std::vector<const Variable*> parameters, const Type& ret
urnType) | 24 std::vector<const Variable*> parameters, const Type& ret
urnType) |
| 25 : INHERITED(position, kFunctionDeclaration_Kind, std::move(name)) | 25 : INHERITED(position, kFunctionDeclaration_Kind, std::move(name)) |
| 26 , fDefined(false) | 26 , fDefined(false) |
| 27 , fBuiltin(false) |
| 27 , fParameters(std::move(parameters)) | 28 , fParameters(std::move(parameters)) |
| 28 , fReturnType(returnType) {} | 29 , fReturnType(returnType) {} |
| 29 | 30 |
| 30 std::string description() const override { | 31 std::string description() const override { |
| 31 std::string result = fReturnType.description() + " " + fName + "("; | 32 std::string result = fReturnType.description() + " " + fName + "("; |
| 32 std::string separator = ""; | 33 std::string separator = ""; |
| 33 for (auto p : fParameters) { | 34 for (auto p : fParameters) { |
| 34 result += separator; | 35 result += separator; |
| 35 separator = ", "; | 36 separator = ", "; |
| 36 result += p->description(); | 37 result += p->description(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 } | 49 } |
| 49 for (size_t i = 0; i < fParameters.size(); i++) { | 50 for (size_t i = 0; i < fParameters.size(); i++) { |
| 50 if (fParameters[i]->fType != f.fParameters[i]->fType) { | 51 if (fParameters[i]->fType != f.fParameters[i]->fType) { |
| 51 return false; | 52 return false; |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 return true; | 55 return true; |
| 55 } | 56 } |
| 56 | 57 |
| 57 mutable bool fDefined; | 58 mutable bool fDefined; |
| 59 bool fBuiltin; |
| 58 const std::vector<const Variable*> fParameters; | 60 const std::vector<const Variable*> fParameters; |
| 59 const Type& fReturnType; | 61 const Type& fReturnType; |
| 60 | 62 |
| 61 typedef Symbol INHERITED; | 63 typedef Symbol INHERITED; |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 } // namespace | 66 } // namespace |
| 65 | 67 |
| 66 #endif | 68 #endif |
| OLD | NEW |