OLD | NEW |
(Empty) | |
| 1 /* |
| 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 */ |
| 7 |
| 8 #ifndef SKSL_SYMBOLTABLE |
| 9 #define SKSL_SYMBOLTABLE |
| 10 |
| 11 #include <memory> |
| 12 #include <unordered_map> |
| 13 #include "SkSLErrorReporter.h" |
| 14 #include "SkSLSymbol.h" |
| 15 #include "SkSLUnresolvedFunction.h" |
| 16 |
| 17 namespace SkSL { |
| 18 |
| 19 /** |
| 20 * Maps identifiers to symbols. Functions, in particular, are mapped to either F
unctionDeclaration |
| 21 * or UnresolvedFunction depending on whether they are overloaded or not. |
| 22 */ |
| 23 class SymbolTable { |
| 24 public: |
| 25 SymbolTable(ErrorReporter& errorReporter) |
| 26 : fErrorReporter(errorReporter) {} |
| 27 |
| 28 SymbolTable(std::shared_ptr<SymbolTable> parent, ErrorReporter& errorReporte
r) |
| 29 : fParent(parent) |
| 30 , fErrorReporter(errorReporter) {} |
| 31 |
| 32 std::shared_ptr<Symbol> operator[](const std::string& name); |
| 33 |
| 34 void add(const std::string& name, std::shared_ptr<Symbol> symbol); |
| 35 |
| 36 const std::shared_ptr<SymbolTable> fParent; |
| 37 |
| 38 private: |
| 39 static std::vector<std::shared_ptr<FunctionDeclaration>> GetFunctions( |
| 40 const std::sha
red_ptr<Symbol>& s); |
| 41 |
| 42 std::unordered_map<std::string, std::shared_ptr<Symbol>> fSymbols; |
| 43 |
| 44 ErrorReporter& fErrorReporter; |
| 45 }; |
| 46 |
| 47 } // namespace |
| 48 |
| 49 #endif |
OLD | NEW |