mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-11 14:41:50 +00:00
Global tweaks to handle having no sem::Type
Soon, we'll start migrating the AST from using sem::Types to ast::Types. This change fixes up a bunch of places that makes the assumption that the semantic type is always expected. Bug: tint:724 Change-Id: I96096bdf7177751ca6c6240e1739244cbeb82761 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49348 Commit-Queue: Ben Clayton <bclayton@chromium.org> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
2ac55febf5
commit
f5f311e264
@@ -26,7 +26,7 @@ BitcastExpression::BitcastExpression(ProgramID program_id,
|
||||
typ::Type type,
|
||||
Expression* expr)
|
||||
: Base(program_id, source), type_(type), expr_(expr) {
|
||||
TINT_ASSERT(type_.sem);
|
||||
TINT_ASSERT(type_.ast || type_.sem);
|
||||
TINT_ASSERT(expr_);
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(expr, program_id);
|
||||
}
|
||||
@@ -46,8 +46,9 @@ void BitcastExpression::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Bitcast[" << result_type_str(sem) << "]<" << type_->type_name()
|
||||
<< ">{" << std::endl;
|
||||
out << "Bitcast[" << result_type_str(sem) << "]<"
|
||||
<< (type_.ast ? type_.ast->type_name() : type_.sem->type_name()) << ">{"
|
||||
<< std::endl;
|
||||
expr_->to_str(sem, out, indent + 2);
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
|
||||
@@ -45,7 +45,7 @@ Function::Function(ProgramID program_id,
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(param, program_id);
|
||||
}
|
||||
TINT_ASSERT(symbol_.IsValid());
|
||||
TINT_ASSERT(return_type_.sem);
|
||||
TINT_ASSERT(return_type_.ast || return_type_.sem);
|
||||
for (auto* deco : decorations_) {
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(deco, program_id);
|
||||
}
|
||||
@@ -92,7 +92,9 @@ void Function::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Function " << symbol_.to_str() << " -> " << return_type_->type_name()
|
||||
out << "Function " << symbol_.to_str() << " -> "
|
||||
<< (return_type_.ast ? return_type_.ast->type_name()
|
||||
: return_type_.sem->type_name())
|
||||
<< std::endl;
|
||||
|
||||
for (auto* deco : decorations()) {
|
||||
|
||||
@@ -30,7 +30,7 @@ StructMember::StructMember(ProgramID program_id,
|
||||
symbol_(sym),
|
||||
type_(type),
|
||||
decorations_(std::move(decorations)) {
|
||||
TINT_ASSERT(type.sem);
|
||||
TINT_ASSERT(type.ast || type.sem);
|
||||
TINT_ASSERT(symbol_.IsValid());
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(symbol_, program_id);
|
||||
for (auto* deco : decorations_) {
|
||||
@@ -76,7 +76,9 @@ void StructMember::to_str(const sem::Info& sem,
|
||||
out << "]] ";
|
||||
}
|
||||
|
||||
out << symbol_.to_str() << ": " << type_->type_name() << "}" << std::endl;
|
||||
out << symbol_.to_str() << ": "
|
||||
<< (type_.ast ? type_.ast->type_name() : type_.sem->type_name()) << "}"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
|
||||
@@ -26,7 +26,7 @@ TypeConstructorExpression::TypeConstructorExpression(ProgramID program_id,
|
||||
typ::Type type,
|
||||
ExpressionList values)
|
||||
: Base(program_id, source), type_(type), values_(std::move(values)) {
|
||||
TINT_ASSERT(type_.sem);
|
||||
TINT_ASSERT(type_.ast || type_.sem);
|
||||
for (auto* val : values_) {
|
||||
TINT_ASSERT(val);
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(val, program_id);
|
||||
@@ -53,7 +53,8 @@ void TypeConstructorExpression::to_str(const sem::Info& sem,
|
||||
make_indent(out, indent);
|
||||
out << "TypeConstructor[" << result_type_str(sem) << "]{" << std::endl;
|
||||
make_indent(out, indent + 2);
|
||||
out << type_->type_name() << std::endl;
|
||||
out << (type_.ast ? type_.ast->type_name() : type_.sem->type_name())
|
||||
<< std::endl;
|
||||
|
||||
for (auto* val : values_) {
|
||||
val->to_str(sem, out, indent + 2);
|
||||
|
||||
@@ -41,7 +41,7 @@ Variable::Variable(ProgramID program_id,
|
||||
TINT_ASSERT(symbol_.IsValid());
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(symbol_, program_id);
|
||||
// no type means we must have a constructor to infer it
|
||||
TINT_ASSERT(type_.sem || constructor);
|
||||
TINT_ASSERT(type_.ast || type_.sem || constructor);
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(constructor, program_id);
|
||||
}
|
||||
|
||||
@@ -90,9 +90,8 @@ void Variable::info_to_str(const sem::Info& sem,
|
||||
out << (var_sem ? var_sem->StorageClass() : declared_storage_class())
|
||||
<< std::endl;
|
||||
make_indent(out, indent);
|
||||
if (type_.sem) {
|
||||
out << type_->type_name() << std::endl;
|
||||
}
|
||||
out << (type_.sem ? type_.sem->type_name() : type_.ast->type_name())
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
void Variable::constructor_to_str(const sem::Info& sem,
|
||||
|
||||
Reference in New Issue
Block a user