mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 06:03:34 +00:00
Change-Id: I883168a1a84457138de85decb921c5c430c32bd8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108702 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
65 lines
2.4 KiB
C++
65 lines
2.4 KiB
C++
// Copyright 2021 The Tint Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef SRC_TINT_RESOLVER_DEPENDENCY_GRAPH_H_
|
|
#define SRC_TINT_RESOLVER_DEPENDENCY_GRAPH_H_
|
|
|
|
#include <vector>
|
|
|
|
#include "src/tint/ast/module.h"
|
|
#include "src/tint/diagnostic/diagnostic.h"
|
|
#include "src/tint/utils/hashmap.h"
|
|
|
|
namespace tint::resolver {
|
|
|
|
/// DependencyGraph holds information about module-scope declaration dependency
|
|
/// analysis and symbol resolutions.
|
|
struct DependencyGraph {
|
|
/// Constructor
|
|
DependencyGraph();
|
|
/// Move-constructor
|
|
DependencyGraph(DependencyGraph&&);
|
|
/// Destructor
|
|
~DependencyGraph();
|
|
|
|
/// Build() performs symbol resolution and dependency analysis on `module`,
|
|
/// populating `output` with the resulting dependency graph.
|
|
/// @param module the AST module to analyse
|
|
/// @param symbols the symbol table
|
|
/// @param diagnostics the diagnostic list to populate with errors / warnings
|
|
/// @param output the resulting DependencyGraph
|
|
/// @returns true on success, false on error
|
|
static bool Build(const ast::Module& module,
|
|
const SymbolTable& symbols,
|
|
diag::List& diagnostics,
|
|
DependencyGraph& output);
|
|
|
|
/// All globals in dependency-sorted order.
|
|
utils::Vector<const ast::Node*, 32> ordered_globals;
|
|
|
|
/// Map of ast::IdentifierExpression or ast::TypeName to a type, function, or
|
|
/// variable that declares the symbol.
|
|
utils::Hashmap<const ast::Node*, const ast::Node*, 64> resolved_symbols;
|
|
|
|
/// Map of ast::Variable to a type, function, or variable that is shadowed by
|
|
/// the variable key. A declaration (X) shadows another (Y) if X and Y use
|
|
/// the same symbol, and X is declared in a sub-scope of the scope that
|
|
/// declares Y.
|
|
utils::Hashmap<const ast::Variable*, const ast::Node*, 16> shadows;
|
|
};
|
|
|
|
} // namespace tint::resolver
|
|
|
|
#endif // SRC_TINT_RESOLVER_DEPENDENCY_GRAPH_H_
|