tint/reader: Use ProgramBuilder helpers
Eases the migration to unkeywording types. Bug: tint:1810 Change-Id: If9ccdbf963550774b85b8cd15df8e37c271cde93 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118987 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
136ec1e3b4
commit
5b50790d70
|
@ -955,9 +955,8 @@ bool FunctionEmitter::Emit() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
builder_.AST().AddFunction(create<ast::Function>(
|
builder_.Func(decl.source, decl.name, std::move(decl.params),
|
||||||
decl.source, builder_.Symbols().Register(decl.name), std::move(decl.params),
|
decl.return_type->Build(builder_), body, std::move(decl.attributes));
|
||||||
decl.return_type->Build(builder_), body, std::move(decl.attributes), utils::Empty));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ep_info_ && !ep_info_->inner_name.empty()) {
|
if (ep_info_ && !ep_info_->inner_name.empty()) {
|
||||||
|
@ -1395,7 +1394,6 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* body = create<ast::BlockStatement>(source, stmts, utils::Empty);
|
|
||||||
AttributeList fn_attrs;
|
AttributeList fn_attrs;
|
||||||
fn_attrs.Push(create<ast::StageAttribute>(source, ep_info_->stage));
|
fn_attrs.Push(create<ast::StageAttribute>(source, ep_info_->stage));
|
||||||
|
|
||||||
|
@ -1409,9 +1407,8 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder_.AST().AddFunction(create<ast::Function>(
|
builder_.Func(source, ep_info_->name, std::move(decl.params), return_type, std::move(stmts),
|
||||||
source, builder_.Symbols().Register(ep_info_->name), std::move(decl.params), return_type,
|
std::move(fn_attrs));
|
||||||
body, std::move(fn_attrs), AttributeList{}));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5779,21 +5776,18 @@ bool FunctionEmitter::EmitAtomicOp(const spvtools::opt::Instruction& inst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit stub, will be removed by transform::SpirvAtomic
|
// Emit stub, will be removed by transform::SpirvAtomic
|
||||||
auto sym = builder_.Symbols().New(std::string("stub_") + sem::str(builtin));
|
auto* stub = builder_.Func(
|
||||||
auto* stub_deco = builder_.ASTNodes().Create<transform::SpirvAtomic::Stub>(
|
Source{}, builder_.Symbols().New(std::string("stub_") + sem::str(builtin)),
|
||||||
builder_.ID(), builder_.AllocateNodeID(), builtin);
|
std::move(params), ret_type,
|
||||||
auto* stub =
|
/* body */ nullptr,
|
||||||
create<ast::Function>(Source{}, sym, std::move(params), ret_type,
|
utils::Vector{
|
||||||
/* body */ nullptr,
|
builder_.ASTNodes().Create<transform::SpirvAtomic::Stub>(
|
||||||
AttributeList{
|
builder_.ID(), builder_.AllocateNodeID(), builtin),
|
||||||
stub_deco,
|
builder_.Disable(ast::DisabledValidation::kFunctionHasNoBody),
|
||||||
builder_.Disable(ast::DisabledValidation::kFunctionHasNoBody),
|
});
|
||||||
},
|
|
||||||
AttributeList{});
|
|
||||||
builder_.AST().AddFunction(stub);
|
|
||||||
|
|
||||||
// Emit call to stub, will be replaced with call to atomic builtin by transform::SpirvAtomic
|
// Emit call to stub, will be replaced with call to atomic builtin by transform::SpirvAtomic
|
||||||
auto* call = builder_.Call(Source{}, sym, std::move(exprs));
|
auto* call = builder_.Call(Source{}, stub->symbol, std::move(exprs));
|
||||||
if (inst.type_id() != 0) {
|
if (inst.type_id() != 0) {
|
||||||
auto* result_type = parser_impl_.ConvertType(inst.type_id());
|
auto* result_type = parser_impl_.ConvertType(inst.type_id());
|
||||||
TypedExpression expr{result_type, call};
|
TypedExpression expr{result_type, call};
|
||||||
|
|
|
@ -1167,9 +1167,9 @@ const Type* ParserImpl::ConvertType(uint32_t type_id,
|
||||||
++num_non_writable_members;
|
++num_non_writable_members;
|
||||||
}
|
}
|
||||||
const auto member_name = namer_.GetMemberName(type_id, member_index);
|
const auto member_name = namer_.GetMemberName(type_id, member_index);
|
||||||
auto* ast_struct_member = create<ast::StructMember>(
|
auto* ast_struct_member =
|
||||||
Source{}, builder_.Symbols().Register(member_name), ast_member_ty->Build(builder_),
|
builder_.Member(Source{}, member_name, ast_member_ty->Build(builder_),
|
||||||
std::move(ast_member_decorations));
|
std::move(ast_member_decorations));
|
||||||
ast_members.Push(ast_struct_member);
|
ast_members.Push(ast_struct_member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1390,7 +1390,6 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
||||||
auto* ast_var =
|
auto* ast_var =
|
||||||
MakeOverride(inst.result_id(), ast_type, ast_expr, std::move(spec_id_decos));
|
MakeOverride(inst.result_id(), ast_type, ast_expr, std::move(spec_id_decos));
|
||||||
if (ast_var) {
|
if (ast_var) {
|
||||||
builder_.AST().AddGlobalVariable(ast_var);
|
|
||||||
scalar_spec_constants_.insert(inst.result_id());
|
scalar_spec_constants_.insert(inst.result_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1577,11 +1576,11 @@ const spvtools::opt::analysis::IntConstant* ParserImpl::GetArraySize(uint32_t va
|
||||||
return size->AsIntConstant();
|
return size->AsIntConstant();
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Var* ParserImpl::MakeVar(uint32_t id,
|
const ast::Var* ParserImpl::MakeVar(uint32_t id,
|
||||||
type::AddressSpace address_space,
|
type::AddressSpace address_space,
|
||||||
const Type* storage_type,
|
const Type* storage_type,
|
||||||
const ast::Expression* initializer,
|
const ast::Expression* initializer,
|
||||||
AttributeList decorations) {
|
AttributeList decorations) {
|
||||||
if (storage_type == nullptr) {
|
if (storage_type == nullptr) {
|
||||||
Fail() << "internal error: can't make ast::Variable for null type";
|
Fail() << "internal error: can't make ast::Variable for null type";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1610,35 +1609,37 @@ ast::Var* ParserImpl::MakeVar(uint32_t id,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
||||||
return create<ast::Var>(Source{}, sym, storage_type->Build(builder_), address_space, access,
|
return builder_.Var(Source{}, sym, storage_type->Build(builder_), address_space, access,
|
||||||
initializer, decorations);
|
initializer, decorations);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Let* ParserImpl::MakeLet(uint32_t id, const Type* type, const ast::Expression* initializer) {
|
const ast::Let* ParserImpl::MakeLet(uint32_t id,
|
||||||
|
const Type* type,
|
||||||
|
const ast::Expression* initializer) {
|
||||||
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
||||||
return create<ast::Let>(Source{}, sym, type->Build(builder_), initializer, utils::Empty);
|
return builder_.Let(Source{}, sym, type->Build(builder_), initializer, utils::Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Override* ParserImpl::MakeOverride(uint32_t id,
|
const ast::Override* ParserImpl::MakeOverride(uint32_t id,
|
||||||
const Type* type,
|
const Type* type,
|
||||||
const ast::Expression* initializer,
|
const ast::Expression* initializer,
|
||||||
AttributeList decorations) {
|
AttributeList decorations) {
|
||||||
if (!ConvertDecorationsForVariable(id, &type, &decorations, false)) {
|
if (!ConvertDecorationsForVariable(id, &type, &decorations, false)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
||||||
return create<ast::Override>(Source{}, sym, type->Build(builder_), initializer, decorations);
|
return builder_.Override(Source{}, sym, type->Build(builder_), initializer, decorations);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::Parameter* ParserImpl::MakeParameter(uint32_t id,
|
const ast::Parameter* ParserImpl::MakeParameter(uint32_t id,
|
||||||
const Type* type,
|
const Type* type,
|
||||||
AttributeList decorations) {
|
AttributeList decorations) {
|
||||||
if (!ConvertDecorationsForVariable(id, &type, &decorations, false)) {
|
if (!ConvertDecorationsForVariable(id, &type, &decorations, false)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
auto sym = builder_.Symbols().Register(namer_.Name(id));
|
||||||
return create<ast::Parameter>(Source{}, sym, type->Build(builder_), decorations);
|
return builder_.Param(Source{}, sym, type->Build(builder_), decorations);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::ConvertDecorationsForVariable(uint32_t id,
|
bool ParserImpl::ConvertDecorationsForVariable(uint32_t id,
|
||||||
|
|
|
@ -429,18 +429,18 @@ class ParserImpl : Reader {
|
||||||
/// @param decorations the variable decorations
|
/// @param decorations the variable decorations
|
||||||
/// @returns a new Variable node, or null in the ignorable variable case and
|
/// @returns a new Variable node, or null in the ignorable variable case and
|
||||||
/// in the error case
|
/// in the error case
|
||||||
ast::Var* MakeVar(uint32_t id,
|
const ast::Var* MakeVar(uint32_t id,
|
||||||
type::AddressSpace address_space,
|
type::AddressSpace address_space,
|
||||||
const Type* storage_type,
|
const Type* storage_type,
|
||||||
const ast::Expression* initializer,
|
const ast::Expression* initializer,
|
||||||
AttributeList decorations);
|
AttributeList decorations);
|
||||||
|
|
||||||
/// Creates an AST 'let' node for a SPIR-V ID, including any attached decorations,.
|
/// Creates an AST 'let' node for a SPIR-V ID, including any attached decorations,.
|
||||||
/// @param id the SPIR-V result ID
|
/// @param id the SPIR-V result ID
|
||||||
/// @param type the type of the variable
|
/// @param type the type of the variable
|
||||||
/// @param initializer the variable initializer
|
/// @param initializer the variable initializer
|
||||||
/// @returns the AST 'let' node
|
/// @returns the AST 'let' node
|
||||||
ast::Let* MakeLet(uint32_t id, const Type* type, const ast::Expression* initializer);
|
const ast::Let* MakeLet(uint32_t id, const Type* type, const ast::Expression* initializer);
|
||||||
|
|
||||||
/// Creates an AST 'override' node for a SPIR-V ID, including any attached decorations.
|
/// Creates an AST 'override' node for a SPIR-V ID, including any attached decorations.
|
||||||
/// @param id the SPIR-V result ID
|
/// @param id the SPIR-V result ID
|
||||||
|
@ -448,10 +448,10 @@ class ParserImpl : Reader {
|
||||||
/// @param initializer the variable initializer
|
/// @param initializer the variable initializer
|
||||||
/// @param decorations the variable decorations
|
/// @param decorations the variable decorations
|
||||||
/// @returns the AST 'override' node
|
/// @returns the AST 'override' node
|
||||||
ast::Override* MakeOverride(uint32_t id,
|
const ast::Override* MakeOverride(uint32_t id,
|
||||||
const Type* type,
|
const Type* type,
|
||||||
const ast::Expression* initializer,
|
const ast::Expression* initializer,
|
||||||
AttributeList decorations);
|
AttributeList decorations);
|
||||||
|
|
||||||
/// Creates an AST parameter node for a SPIR-V ID, including any attached decorations, unless
|
/// Creates an AST parameter node for a SPIR-V ID, including any attached decorations, unless
|
||||||
/// it's an ignorable builtin variable.
|
/// it's an ignorable builtin variable.
|
||||||
|
@ -459,7 +459,7 @@ class ParserImpl : Reader {
|
||||||
/// @param type the type of the parameter
|
/// @param type the type of the parameter
|
||||||
/// @param decorations the parameter decorations
|
/// @param decorations the parameter decorations
|
||||||
/// @returns the AST parameter node
|
/// @returns the AST parameter node
|
||||||
ast::Parameter* MakeParameter(uint32_t id, const Type* type, AttributeList decorations);
|
const ast::Parameter* MakeParameter(uint32_t id, const Type* type, AttributeList decorations);
|
||||||
|
|
||||||
/// Returns true if a constant expression can be generated.
|
/// Returns true if a constant expression can be generated.
|
||||||
/// @param id the SPIR-V ID of the value
|
/// @param id the SPIR-V ID of the value
|
||||||
|
@ -885,7 +885,7 @@ class ParserImpl : Reader {
|
||||||
std::unordered_map<const spvtools::opt::Instruction*, const Type*> handle_type_;
|
std::unordered_map<const spvtools::opt::Instruction*, const Type*> handle_type_;
|
||||||
|
|
||||||
/// Maps the SPIR-V ID of a module-scope variable to its AST variable.
|
/// Maps the SPIR-V ID of a module-scope variable to its AST variable.
|
||||||
utils::Hashmap<uint32_t, ast::Var*, 16> module_variable_;
|
utils::Hashmap<uint32_t, const ast::Var*, 16> module_variable_;
|
||||||
|
|
||||||
// Set of symbols of declared type that have been added, used to avoid
|
// Set of symbols of declared type that have been added, used to avoid
|
||||||
// adding duplicates.
|
// adding duplicates.
|
||||||
|
|
|
@ -505,8 +505,6 @@ Maybe<Void> ParserImpl::global_decl() {
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder_.AST().AddGlobalVariable(gc.value);
|
|
||||||
return kSuccess;
|
return kSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +563,6 @@ Maybe<Void> ParserImpl::global_decl() {
|
||||||
errored = true;
|
errored = true;
|
||||||
}
|
}
|
||||||
if (func.matched) {
|
if (func.matched) {
|
||||||
builder_.AST().AddFunction(func.value);
|
|
||||||
return kSuccess;
|
return kSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,13 +628,13 @@ Maybe<const ast::Variable*> ParserImpl::global_variable_decl(AttributeList& attr
|
||||||
|
|
||||||
TINT_DEFER(attrs.Clear());
|
TINT_DEFER(attrs.Clear());
|
||||||
|
|
||||||
return create<ast::Var>(decl->source, // source
|
return builder_.Var(decl->source, // source
|
||||||
builder_.Symbols().Register(decl->name), // symbol
|
decl->name, // symbol
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
decl->address_space, // address space
|
decl->address_space, // address space
|
||||||
decl->access, // access control
|
decl->access, // access control
|
||||||
initializer, // initializer
|
initializer, // initializer
|
||||||
std::move(attrs)); // attributes
|
std::move(attrs)); // attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
// global_constant_decl :
|
// global_constant_decl :
|
||||||
|
@ -646,7 +643,6 @@ Maybe<const ast::Variable*> ParserImpl::global_variable_decl(AttributeList& attr
|
||||||
// global_const_initializer
|
// global_const_initializer
|
||||||
// : EQUAL const_expr
|
// : EQUAL const_expr
|
||||||
Maybe<const ast::Variable*> ParserImpl::global_constant_decl(AttributeList& attrs) {
|
Maybe<const ast::Variable*> ParserImpl::global_constant_decl(AttributeList& attrs) {
|
||||||
bool is_const = false;
|
|
||||||
bool is_overridable = false;
|
bool is_overridable = false;
|
||||||
const char* use = nullptr;
|
const char* use = nullptr;
|
||||||
Source source;
|
Source source;
|
||||||
|
@ -690,25 +686,18 @@ Maybe<const ast::Variable*> ParserImpl::global_constant_decl(AttributeList& attr
|
||||||
|
|
||||||
TINT_DEFER(attrs.Clear());
|
TINT_DEFER(attrs.Clear());
|
||||||
|
|
||||||
if (is_const) {
|
|
||||||
return create<ast::Const>(decl->source, // source
|
|
||||||
builder_.Symbols().Register(decl->name), // symbol
|
|
||||||
decl->type, // type
|
|
||||||
initializer, // initializer
|
|
||||||
std::move(attrs)); // attributes
|
|
||||||
}
|
|
||||||
if (is_overridable) {
|
if (is_overridable) {
|
||||||
return create<ast::Override>(decl->source, // source
|
return builder_.Override(decl->source, // source
|
||||||
builder_.Symbols().Register(decl->name), // symbol
|
decl->name, // symbol
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
initializer, // initializer
|
initializer, // initializer
|
||||||
std::move(attrs)); // attributes
|
std::move(attrs)); // attributes
|
||||||
}
|
}
|
||||||
return create<ast::Const>(decl->source, // source
|
return builder_.GlobalConst(decl->source, // source
|
||||||
builder_.Symbols().Register(decl->name), // symbol
|
decl->name, // symbol
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
initializer, // initializer
|
initializer, // initializer
|
||||||
std::move(attrs)); // attributes
|
std::move(attrs)); // attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
// variable_decl
|
// variable_decl
|
||||||
|
@ -1451,7 +1440,7 @@ Expect<ParserImpl::StructMemberList> ParserImpl::expect_struct_body_decl() {
|
||||||
|
|
||||||
// struct_member
|
// struct_member
|
||||||
// : attribute* ident_with_type_specifier
|
// : attribute* ident_with_type_specifier
|
||||||
Expect<ast::StructMember*> ParserImpl::expect_struct_member() {
|
Expect<const ast::StructMember*> ParserImpl::expect_struct_member() {
|
||||||
auto attrs = attribute_list();
|
auto attrs = attribute_list();
|
||||||
if (attrs.errored) {
|
if (attrs.errored) {
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
@ -1462,8 +1451,7 @@ Expect<ast::StructMember*> ParserImpl::expect_struct_member() {
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
}
|
}
|
||||||
|
|
||||||
return create<ast::StructMember>(decl->source, builder_.Symbols().Register(decl->name),
|
return builder_.Member(decl->source, decl->name, decl->type, std::move(attrs.value));
|
||||||
decl->type, std::move(attrs.value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// const_assert_statement
|
// const_assert_statement
|
||||||
|
@ -1523,9 +1511,8 @@ Maybe<const ast::Function*> ParserImpl::function_decl(AttributeList& attrs) {
|
||||||
|
|
||||||
TINT_DEFER(attrs.Clear());
|
TINT_DEFER(attrs.Clear());
|
||||||
|
|
||||||
return create<ast::Function>(header->source, builder_.Symbols().Register(header->name),
|
return builder_.Func(header->source, header->name, header->params, header->return_type,
|
||||||
header->params, header->return_type, body.value, std::move(attrs),
|
body.value, std::move(attrs), header->return_type_attributes);
|
||||||
header->return_type_attributes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// function_header
|
// function_header
|
||||||
|
@ -1618,7 +1605,7 @@ Expect<ParserImpl::ParameterList> ParserImpl::expect_param_list() {
|
||||||
|
|
||||||
// param
|
// param
|
||||||
// : attribute_list* ident COLON type_specifier
|
// : attribute_list* ident COLON type_specifier
|
||||||
Expect<ast::Parameter*> ParserImpl::expect_param() {
|
Expect<const ast::Parameter*> ParserImpl::expect_param() {
|
||||||
auto attrs = attribute_list();
|
auto attrs = attribute_list();
|
||||||
|
|
||||||
auto decl = expect_ident_with_type_specifier("parameter");
|
auto decl = expect_ident_with_type_specifier("parameter");
|
||||||
|
@ -1626,10 +1613,10 @@ Expect<ast::Parameter*> ParserImpl::expect_param() {
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
}
|
}
|
||||||
|
|
||||||
return create<ast::Parameter>(decl->source, // source
|
return builder_.Param(decl->source, // source
|
||||||
builder_.Symbols().Register(decl->name), // symbol
|
decl->name, // symbol
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
std::move(attrs.value)); // attributes
|
std::move(attrs.value)); // attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
// interpolation_sample_name
|
// interpolation_sample_name
|
||||||
|
@ -1943,11 +1930,10 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_statement() {
|
||||||
return add_error(peek(), "missing initializer for 'const' declaration");
|
return add_error(peek(), "missing initializer for 'const' declaration");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* const_ = create<ast::Const>(typed_ident->source, // source
|
auto* const_ = builder_.Const(typed_ident->source, // source
|
||||||
builder_.Symbols().Register(typed_ident->name), // symbol
|
typed_ident->name, // symbol
|
||||||
typed_ident->type, // type
|
typed_ident->type, // type
|
||||||
initializer.value, // initializer
|
initializer.value); // initializer
|
||||||
utils::Empty); // attributes
|
|
||||||
|
|
||||||
return create<ast::VariableDeclStatement>(decl_source, const_);
|
return create<ast::VariableDeclStatement>(decl_source, const_);
|
||||||
}
|
}
|
||||||
|
@ -1972,11 +1958,10 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_statement() {
|
||||||
return add_error(peek(), "missing initializer for 'let' declaration");
|
return add_error(peek(), "missing initializer for 'let' declaration");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* let = create<ast::Let>(typed_ident->source, // source
|
auto* let = builder_.Let(typed_ident->source, // source
|
||||||
builder_.Symbols().Register(typed_ident->name), // symbol
|
typed_ident->name, // symbol
|
||||||
typed_ident->type, // type
|
typed_ident->type, // type
|
||||||
initializer.value, // initializer
|
initializer.value); // initializer
|
||||||
utils::Empty); // attributes
|
|
||||||
|
|
||||||
return create<ast::VariableDeclStatement>(decl_source, let);
|
return create<ast::VariableDeclStatement>(decl_source, let);
|
||||||
}
|
}
|
||||||
|
@ -2004,13 +1989,12 @@ Maybe<const ast::VariableDeclStatement*> ParserImpl::variable_statement() {
|
||||||
initializer = initializer_expr.value;
|
initializer = initializer_expr.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* var = create<ast::Var>(decl_source, // source
|
auto* var = builder_.Var(decl_source, // source
|
||||||
builder_.Symbols().Register(decl->name), // symbol
|
decl->name, // symbol
|
||||||
decl->type, // type
|
decl->type, // type
|
||||||
decl->address_space, // address space
|
decl->address_space, // address space
|
||||||
decl->access, // access control
|
decl->access, // access control
|
||||||
initializer, // initializer
|
initializer); // initializer
|
||||||
utils::Empty); // attributes
|
|
||||||
|
|
||||||
return create<ast::VariableDeclStatement>(var->source, var);
|
return create<ast::VariableDeclStatement>(var->source, var);
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,7 +474,7 @@ class ParserImpl {
|
||||||
Expect<StructMemberList> expect_struct_body_decl();
|
Expect<StructMemberList> expect_struct_body_decl();
|
||||||
/// Parses a `struct_member` grammar element, erroring on parse failure.
|
/// Parses a `struct_member` grammar element, erroring on parse failure.
|
||||||
/// @returns the struct member or nullptr
|
/// @returns the struct member or nullptr
|
||||||
Expect<ast::StructMember*> expect_struct_member();
|
Expect<const ast::StructMember*> expect_struct_member();
|
||||||
/// Parses a `function_decl` grammar element with the initial
|
/// Parses a `function_decl` grammar element with the initial
|
||||||
/// `function_attribute_decl*` provided as `attrs`.
|
/// `function_attribute_decl*` provided as `attrs`.
|
||||||
/// @param attrs the list of attributes for the function declaration. If attributes are consumed
|
/// @param attrs the list of attributes for the function declaration. If attributes are consumed
|
||||||
|
@ -519,7 +519,7 @@ class ParserImpl {
|
||||||
Expect<ParameterList> expect_param_list();
|
Expect<ParameterList> expect_param_list();
|
||||||
/// Parses a `param` grammar element, erroring on parse failure.
|
/// Parses a `param` grammar element, erroring on parse failure.
|
||||||
/// @returns the parsed variable
|
/// @returns the parsed variable
|
||||||
Expect<ast::Parameter*> expect_param();
|
Expect<const ast::Parameter*> expect_param();
|
||||||
/// Parses a `pipeline_stage` grammar element, erroring if the next token does
|
/// Parses a `pipeline_stage` grammar element, erroring if the next token does
|
||||||
/// not match a stage name.
|
/// not match a stage name.
|
||||||
/// @returns the pipeline stage.
|
/// @returns the pipeline stage.
|
||||||
|
|
Loading…
Reference in New Issue