/*
 * Copyright 2020 Google LLC
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SKSL_STRUCTDEFINITION
#define SKSL_STRUCTDEFINITION

#include <memory>

#include "include/private/SkSLProgramElement.h"
#include "src/sksl/ir/SkSLSymbolTable.h"
#include "src/sksl/ir/SkSLType.h"

namespace SkSL {

/**
 * A struct at global scope, as in:
 *
 * struct RenderData {
 *   float3 color;
 *   bool highQuality;
 * };
 */
class StructDefinition final : public ProgramElement {
public:
    inline static constexpr Kind kProgramElementKind = Kind::kStructDefinition;

    StructDefinition(int line, const Type& type)
    : INHERITED(line, kProgramElementKind)
    , fType(&type) {}

    const Type& type() const {
        return *fType;
    }

    std::unique_ptr<ProgramElement> clone() const override {
        return std::make_unique<StructDefinition>(fLine, this->type());
    }

    std::string description() const override {
        std::string s = "struct ";
        s += this->type().name();
        s += " { ";
        for (const auto& f : this->type().fields()) {
            s += f.fModifiers.description();
            s += f.fType->description();
            s += " ";
            s += f.fName;
            s += "; ";
        }
        s += "};";
        return s;
    }

private:
    const Type* fType = nullptr;

    using INHERITED = ProgramElement;
};

}  // namespace SkSL

#endif
