/* * 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 #include #include #include "SkSLErrorReporter.h" #include "SkSLSymbol.h" namespace SkSL { struct FunctionDeclaration; /** * 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 parent, ErrorReporter& errorReporter) : fParent(parent) , fErrorReporter(errorReporter) {} const Symbol* operator[](const SkString& name); void add(const SkString& name, std::unique_ptr symbol); void addWithoutOwnership(const SkString& name, const Symbol* symbol); Symbol* takeOwnership(Symbol* s); void markAllFunctionsBuiltin(); const std::shared_ptr fParent; private: static std::vector GetFunctions(const Symbol& s); std::vector> fOwnedPointers; std::unordered_map fSymbols; ErrorReporter& fErrorReporter; }; } // namespace #endif