mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-04 12:16:10 +00:00
[tint][ir][ToProgram] Implement var expressions
Bug: tint:1902 Change-Id: I97c026adc113b4a8834b9b5e978b4084d777328a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133060 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
83c5c8b151
commit
0b9cb101bf
@ -183,6 +183,7 @@ class State {
|
|||||||
return Switch(
|
return Switch(
|
||||||
val, //
|
val, //
|
||||||
[&](const ir::Constant* c) { return ConstExpr(c); },
|
[&](const ir::Constant* c) { return ConstExpr(c); },
|
||||||
|
[&](const ir::Var* v) { return VarExpr(v); },
|
||||||
[&](Default) {
|
[&](Default) {
|
||||||
TINT_UNIMPLEMENTED(IR, b.Diagnostics())
|
TINT_UNIMPLEMENTED(IR, b.Diagnostics())
|
||||||
<< "unhandled case in Switch(): " << val->TypeInfo().name;
|
<< "unhandled case in Switch(): " << val->TypeInfo().name;
|
||||||
@ -205,6 +206,8 @@ class State {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ast::Expression* VarExpr(const ir::Var* v) { return b.Expr(NameOf(v)); }
|
||||||
|
|
||||||
const ast::Type Type(const type::Type* ty) {
|
const ast::Type Type(const type::Type* ty) {
|
||||||
return Switch(
|
return Switch(
|
||||||
ty, //
|
ty, //
|
||||||
|
@ -67,6 +67,14 @@ fn f() {
|
|||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(IRToProgramRoundtripTest, FunctionScopeVar_i32) {
|
||||||
|
Test(R"(
|
||||||
|
fn f() {
|
||||||
|
var i : i32;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(IRToProgramRoundtripTest, FunctionScopeVar_i32_InitLiteral) {
|
TEST_F(IRToProgramRoundtripTest, FunctionScopeVar_i32_InitLiteral) {
|
||||||
Test(R"(
|
Test(R"(
|
||||||
fn f() {
|
fn f() {
|
||||||
@ -75,5 +83,15 @@ fn f() {
|
|||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(IRToProgramRoundtripTest, FunctionScopeVar_Chained) {
|
||||||
|
Test(R"(
|
||||||
|
fn f() {
|
||||||
|
var a : i32 = 42i;
|
||||||
|
var b : i32 = a;
|
||||||
|
var c : i32 = b;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::ir
|
} // namespace tint::ir
|
||||||
|
Loading…
x
Reference in New Issue
Block a user