blob: 6b7ada35a1b84cdffa5d3b6c3cc6d8ce83f69c07 [file] [log] [blame]
* Copyright 2020 Google LLC
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#include "include/private/SkSLProgramElement.h"
#include "include/private/SkTHash.h"
#include <functional>
#include <memory>
#include <string>
namespace SkSL {
* Represents the builtin elements in the Context.
class BuiltinMap {
BuiltinMap(BuiltinMap* parent) : fParent(parent) {}
void insertOrDie(std::string key, std::unique_ptr<ProgramElement> element);
const ProgramElement* find(const std::string& key);
const ProgramElement* findAndInclude(const std::string& key);
void resetAlreadyIncluded();
void foreach(const std::function<void(const std::string&, const ProgramElement&)>& fn) const;
struct BuiltinElement {
std::unique_ptr<ProgramElement> fElement;
bool fAlreadyIncluded = false;
SkTHashMap<std::string, BuiltinElement> fElements;
BuiltinMap* fParent = nullptr;
} // namespace SkSL