diff --git a/src/tint/resolver/dependency_graph.cc b/src/tint/resolver/dependency_graph.cc index 0a9bdc015b..94efafb3e7 100644 --- a/src/tint/resolver/dependency_graph.cc +++ b/src/tint/resolver/dependency_graph.cc @@ -420,7 +420,7 @@ class DependencyScanner { DependencyGraph& graph_; DependencyEdges& dependency_edges_; - ScopeStack scope_stack_; + ScopeStack scope_stack_; Global* current_global_ = nullptr; }; diff --git a/src/tint/scope_stack.h b/src/tint/scope_stack.h index 8bc97a3a2f..6892b402c0 100644 --- a/src/tint/scope_stack.h +++ b/src/tint/scope_stack.h @@ -24,7 +24,7 @@ namespace tint { /// Used to store a stack of scope information. /// The stack starts with a global scope which can not be popped. -template +template class ScopeStack { public: /// Constructor @@ -47,32 +47,32 @@ class ScopeStack { } /// Assigns the value into the top most scope of the stack. - /// @param symbol the symbol of the value + /// @param key the key of the value /// @param val the value - /// @returns the old value if there was an existing symbol at the top of the + /// @returns the old value if there was an existing key at the top of the /// stack, otherwise the zero initializer for type T. - T Set(const Symbol& symbol, T val) { - std::swap(val, stack_.back()[symbol]); + V Set(const K& key, V val) { + std::swap(val, stack_.back()[key]); return val; } /// Retrieves a value from the stack - /// @param symbol the symbol to look for + /// @param key the key to look for /// @returns the value, or the zero initializer if the value was not found - T Get(const Symbol& symbol) const { + V Get(const K& key) const { for (auto iter = stack_.rbegin(); iter != stack_.rend(); ++iter) { auto& map = *iter; - auto val = map.find(symbol); + auto val = map.find(key); if (val != map.end()) { return val->second; } } - return T{}; + return V{}; } private: - std::vector> stack_; + std::vector> stack_; }; } // namespace tint diff --git a/src/tint/scope_stack_test.cc b/src/tint/scope_stack_test.cc index 80628073c1..8ed1f81f68 100644 --- a/src/tint/scope_stack_test.cc +++ b/src/tint/scope_stack_test.cc @@ -22,7 +22,7 @@ namespace { class ScopeStackTest : public ProgramBuilder, public testing::Test {}; TEST_F(ScopeStackTest, Get) { - ScopeStack s; + ScopeStack s; Symbol a(1, ID()); Symbol b(3, ID()); s.Push(); @@ -44,13 +44,13 @@ TEST_F(ScopeStackTest, Get) { } TEST_F(ScopeStackTest, Get_MissingSymbol) { - ScopeStack s; + ScopeStack s; Symbol sym(1, ID()); EXPECT_EQ(s.Get(sym), 0u); } TEST_F(ScopeStackTest, Set) { - ScopeStack s; + ScopeStack s; Symbol a(1, ID()); Symbol b(2, ID());