blob: 0277db1f07140cb2d955f1d94248eeea5c939273 [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 Nicholas0df1b042017-03-31 13:56:23 -04007
ethannicholasb3058bd2016-07-01 08:22:01 -07008#ifndef SKSL_FUNCTIONDEFINITION
9#define SKSL_FUNCTIONDEFINITION
10
11#include "SkSLBlock.h"
12#include "SkSLFunctionDeclaration.h"
13#include "SkSLProgramElement.h"
14
15namespace SkSL {
16
17/**
18 * A function definition (a declaration plus an associated block of code).
19 */
20struct FunctionDefinition : public ProgramElement {
Ethan Nicholas0df1b042017-03-31 13:56:23 -040021 FunctionDefinition(Position position, const FunctionDeclaration& declaration,
Ethan Nicholascb670962017-04-20 19:31:52 -040022 std::unique_ptr<Statement> body)
ethannicholasb3058bd2016-07-01 08:22:01 -070023 : INHERITED(position, kFunction_Kind)
ethannicholasd598f792016-07-25 10:08:54 -070024 , fDeclaration(declaration)
ethannicholasb3058bd2016-07-01 08:22:01 -070025 , fBody(std::move(body)) {}
26
Ethan Nicholas0df1b042017-03-31 13:56:23 -040027 String description() const override {
ethannicholasd598f792016-07-25 10:08:54 -070028 return fDeclaration.description() + " " + fBody->description();
ethannicholasb3058bd2016-07-01 08:22:01 -070029 }
30
ethannicholasd598f792016-07-25 10:08:54 -070031 const FunctionDeclaration& fDeclaration;
Ethan Nicholascb670962017-04-20 19:31:52 -040032 std::unique_ptr<Statement> fBody;
ethannicholasb3058bd2016-07-01 08:22:01 -070033
34 typedef ProgramElement INHERITED;
35};
36
37} // namespace
38
39#endif