Store expressions in switch case statements.

This CL moves switch case statements to store Expression instead
of an IntLiteralExpression. The SEM is updated to store the
materialized constant instead of accessing the expression value
directly.

Bug: tint:1633
Change-Id: Id79dabb806be1049f775299732bc1c7b1bf0c05f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106300
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair
2022-10-19 00:43:41 +00:00
committed by Dawn LUCI CQ
parent 00aa7ef462
commit d32fbe07e7
19 changed files with 360 additions and 120 deletions

View File

@@ -25,7 +25,7 @@ namespace tint::ast {
CaseStatement::CaseStatement(ProgramID pid,
NodeID nid,
const Source& src,
utils::VectorRef<const IntLiteralExpression*> s,
utils::VectorRef<const Expression*> s,
const BlockStatement* b)
: Base(pid, nid, src), selectors(std::move(s)), body(b) {
TINT_ASSERT(AST, body);

View File

@@ -18,7 +18,7 @@
#include <vector>
#include "src/tint/ast/block_statement.h"
#include "src/tint/ast/int_literal_expression.h"
#include "src/tint/ast/expression.h"
namespace tint::ast {
@@ -34,7 +34,7 @@ class CaseStatement final : public Castable<CaseStatement, Statement> {
CaseStatement(ProgramID pid,
NodeID nid,
const Source& src,
utils::VectorRef<const IntLiteralExpression*> selectors,
utils::VectorRef<const Expression*> selectors,
const BlockStatement* body);
/// Move constructor
CaseStatement(CaseStatement&&);
@@ -50,7 +50,7 @@ class CaseStatement final : public Castable<CaseStatement, Statement> {
const CaseStatement* Clone(CloneContext* ctx) const override;
/// The case selectors, empty if none set
const utils::Vector<const IntLiteralExpression*, 4> selectors;
const utils::Vector<const Expression*, 4> selectors;
/// The case body
const BlockStatement* const body;