| Index: src/sksl/ir/SkSLSymbolTable.h
|
| diff --git a/src/sksl/ir/SkSLSymbolTable.h b/src/sksl/ir/SkSLSymbolTable.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0938f5b9acd1590e21a96c645543a7c6e7a94489
|
| --- /dev/null
|
| +++ b/src/sksl/ir/SkSLSymbolTable.h
|
| @@ -0,0 +1,49 @@
|
| +/*
|
| + * Copyright 2016 Google Inc.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#ifndef SKSL_SYMBOLTABLE
|
| +#define SKSL_SYMBOLTABLE
|
| +
|
| +#include <memory>
|
| +#include <unordered_map>
|
| +#include "SkSLErrorReporter.h"
|
| +#include "SkSLSymbol.h"
|
| +#include "SkSLUnresolvedFunction.h"
|
| +
|
| +namespace SkSL {
|
| +
|
| +/**
|
| + * Maps identifiers to symbols. Functions, in particular, are mapped to either FunctionDeclaration
|
| + * or UnresolvedFunction depending on whether they are overloaded or not.
|
| + */
|
| +class SymbolTable {
|
| +public:
|
| + SymbolTable(ErrorReporter& errorReporter)
|
| + : fErrorReporter(errorReporter) {}
|
| +
|
| + SymbolTable(std::shared_ptr<SymbolTable> parent, ErrorReporter& errorReporter)
|
| + : fParent(parent)
|
| + , fErrorReporter(errorReporter) {}
|
| +
|
| + std::shared_ptr<Symbol> operator[](std::string name);
|
| +
|
| + void add(std::string name, std::shared_ptr<Symbol> symbol);
|
| +
|
| + const std::shared_ptr<SymbolTable> fParent;
|
| +
|
| +private:
|
| + static std::vector<std::shared_ptr<FunctionDeclaration>> GetFunctions(
|
| + std::shared_ptr<Symbol> s);
|
| +
|
| + std::unordered_map<std::string, std::shared_ptr<Symbol>> fSymbols;
|
| +
|
| + ErrorReporter& fErrorReporter;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +#endif
|
|
|