tint: Add a negation operator to Number

Use this for expressing negative i32s.
Replacing `i32(-123)` with `-123_i` is more readable as the former looks
like it should be generating a WGSL cast, which it does not.

Bug: tint:1504
Change-Id: Iead3885b903e1f707b8a7e6b9090d65930df118e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89401
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-05-10 16:02:06 +00:00
committed by Dawn LUCI CQ
parent 17fa42d527
commit 636e3d0111
11 changed files with 26 additions and 22 deletions

View File

@@ -991,7 +991,7 @@ TEST_F(InspectorGetConstantIDsTest, U32) {
TEST_F(InspectorGetConstantIDsTest, I32) {
AddOverridableConstantWithID("foo", 1, ty.i32(), nullptr);
AddOverridableConstantWithID("bar", 20, ty.i32(), Expr(i32(-42)));
AddOverridableConstantWithID("bar", 20, ty.i32(), Expr(-42_i));
AddOverridableConstantWithID("baz", 300, ty.i32(), Expr(42_i));
Inspector& inspector = Build();