blob: e87ee63e7aef62ac7682ae07c60b632edee7ca90 [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 Nicholase1d9cb82017-02-06 18:53:07 +000022 std::unique_ptr<Block> 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 Nicholase1d9cb82017-02-06 18:53:07 +000032 const std::unique_ptr<Block> fBody;
ethannicholasb3058bd2016-07-01 08:22:01 -070033
34 typedef ProgramElement INHERITED;
35};
36
37} // namespace
38
39#endif