tint/ast: Change Function::symbol to Function::name

Function::name is an ast::Identifier.

The goal here is to have all AST nodes use an identifier instead of
symbols directly. This will greatly simplify the renamer transform,
and gives the symbol a Source location, which is helpful for
diagnostics and tooling.

Change-Id: I723a9a104668758db2cb32051efa1f6d3c105913
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119280
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2023-02-09 10:34:14 +00:00
parent 057a733758
commit ce31d187ef
32 changed files with 157 additions and 120 deletions

View File

@@ -600,7 +600,7 @@ struct DirectVariableAccess::State {
// Function was not called. Create a single variant with an empty signature.
FnVariant variant;
variant.name = ctx.Clone(fn->Declaration()->symbol);
variant.name = ctx.Clone(fn->Declaration()->name->symbol);
variant.order = 0; // Unaltered comes first.
fn_info->variants.Add(FnVariant::Signature{}, std::move(variant));
}
@@ -679,7 +679,7 @@ struct DirectVariableAccess::State {
if (target_signature.IsEmpty()) {
// Call target does not require any argument changes.
FnVariant variant;
variant.name = ctx.Clone(target->Declaration()->symbol);
variant.name = ctx.Clone(target->Declaration()->name->symbol);
variant.order = 0; // Unaltered comes first.
return variant;
}
@@ -688,7 +688,7 @@ struct DirectVariableAccess::State {
// This is derived from the original function name and the pointer parameter
// chains.
std::stringstream ss;
ss << ctx.src->Symbols().NameFor(target->Declaration()->symbol);
ss << ctx.src->Symbols().NameFor(target->Declaration()->name->symbol);
for (auto* param : target->Parameters()) {
if (auto indices = target_signature.Find(param)) {
ss << "_" << AccessShapeName(*indices);
@@ -855,7 +855,7 @@ struct DirectVariableAccess::State {
auto attrs = ctx.Clone(fn->Declaration()->attributes);
auto ret_attrs = ctx.Clone(fn->Declaration()->return_type_attributes);
pending_variant =
b.create<ast::Function>(variant.name, std::move(params), ret_ty, body,
b.create<ast::Function>(b.Ident(variant.name), std::move(params), ret_ty, body,
std::move(attrs), std::move(ret_attrs));
}