mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
tint: Add unary-ops to the intrinsic table
• Declare all the unary ops in the intrinsics.def file. • Reimplement the bulk of Resolver::UnaryOp() with the IntrinsicTable. This will simplify maintenance of the operators, and will greatly simplify the [AbstractInt -> i32|u32] [AbstractFloat -> f32|f16] logic. Bug: tint:1504 Change-Id: Ifc646d086fc93cfbe3f3f861b8c447178664c1f7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89028 Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
7378612ca5
commit
b61e0452f8
@@ -72,6 +72,8 @@ func (l *lexer) lex() error {
|
||||
l.tok(1, tok.Modulo)
|
||||
case '^':
|
||||
l.tok(1, tok.Xor)
|
||||
case '~':
|
||||
l.tok(1, tok.Complement)
|
||||
case '"':
|
||||
start := l.loc
|
||||
l.next() // Skip opening quote
|
||||
@@ -105,6 +107,7 @@ func (l *lexer) lex() error {
|
||||
case l.match("||", tok.OrOr):
|
||||
case l.match("|", tok.Or):
|
||||
case l.match("!=", tok.NotEqual):
|
||||
case l.match("!", tok.Not):
|
||||
case l.match("==", tok.Equal):
|
||||
case l.match("=", tok.Assign):
|
||||
case l.match("<<", tok.Shl):
|
||||
|
||||
@@ -91,6 +91,9 @@ func TestLexTokens(t *testing.T) {
|
||||
{"|", tok.Token{Kind: tok.Or, Runes: []rune("|"), Source: tok.Source{
|
||||
S: loc(1, 1, 0), E: loc(1, 2, 1),
|
||||
}}},
|
||||
{"!", tok.Token{Kind: tok.Not, Runes: []rune("!"), Source: tok.Source{
|
||||
S: loc(1, 1, 0), E: loc(1, 2, 1),
|
||||
}}},
|
||||
{"!=", tok.Token{Kind: tok.NotEqual, Runes: []rune("!="), Source: tok.Source{
|
||||
S: loc(1, 1, 0), E: loc(1, 3, 2),
|
||||
}}},
|
||||
|
||||
@@ -32,34 +32,36 @@ const (
|
||||
Operator Kind = "op"
|
||||
Type Kind = "type"
|
||||
Enum Kind = "enum"
|
||||
Colon Kind = ":"
|
||||
Comma Kind = ","
|
||||
Shl Kind = "<<"
|
||||
Shr Kind = ">>"
|
||||
Lt Kind = "<"
|
||||
Le Kind = "<="
|
||||
Gt Kind = ">"
|
||||
Ge Kind = ">="
|
||||
Lbrace Kind = "{"
|
||||
Rbrace Kind = "}"
|
||||
Ldeco Kind = "[["
|
||||
Rdeco Kind = "]]"
|
||||
Lparen Kind = "("
|
||||
Rparen Kind = ")"
|
||||
Or Kind = "|"
|
||||
Arrow Kind = "->"
|
||||
Star Kind = "*"
|
||||
Divide Kind = "/"
|
||||
Modulo Kind = "%"
|
||||
Xor Kind = "^"
|
||||
Plus Kind = "+"
|
||||
Minus Kind = "-"
|
||||
And Kind = "&"
|
||||
AndAnd Kind = "&&"
|
||||
OrOr Kind = "||"
|
||||
NotEqual Kind = "!="
|
||||
Equal Kind = "=="
|
||||
Arrow Kind = "->"
|
||||
Assign Kind = "="
|
||||
Colon Kind = ":"
|
||||
Comma Kind = ","
|
||||
Complement Kind = "~"
|
||||
Divide Kind = "/"
|
||||
Equal Kind = "=="
|
||||
Ge Kind = ">="
|
||||
Gt Kind = ">"
|
||||
Lbrace Kind = "{"
|
||||
Ldeco Kind = "[["
|
||||
Le Kind = "<="
|
||||
Lparen Kind = "("
|
||||
Lt Kind = "<"
|
||||
Minus Kind = "-"
|
||||
Modulo Kind = "%"
|
||||
Not Kind = "!"
|
||||
NotEqual Kind = "!="
|
||||
Or Kind = "|"
|
||||
OrOr Kind = "||"
|
||||
Plus Kind = "+"
|
||||
Rbrace Kind = "}"
|
||||
Rdeco Kind = "]]"
|
||||
Rparen Kind = ")"
|
||||
Shl Kind = "<<"
|
||||
Shr Kind = ">>"
|
||||
Star Kind = "*"
|
||||
Xor Kind = "^"
|
||||
)
|
||||
|
||||
// Invalid represents an invalid token
|
||||
|
||||
Reference in New Issue
Block a user