tint/resolver: Use the intrinsic table for type const dispatch

Use the @const annotations to more efficently dispatch to the right
method of the ConstEval class.

Reduces a whole lot of dynamic casting logic.

Change-Id: I6791aac51b935b46d63af29abd1e577b3306a0ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95950
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton
2022-07-15 22:27:50 +00:00
committed by Dawn LUCI CQ
parent 30d672963c
commit 6a80ce6c66
9 changed files with 493 additions and 380 deletions

View File

@@ -329,7 +329,14 @@ func (r *resolver) intrinsic(
if constEvalFn := a.Attributes.Take("const"); constEvalFn != nil {
switch len(constEvalFn.Values) {
case 0:
overload.ConstEvalFunction = overload.Decl.Name
switch overload.Decl.Kind {
case ast.Builtin, ast.Operator:
overload.ConstEvalFunction = overload.Decl.Name
case ast.Constructor:
overload.ConstEvalFunction = "Ctor"
case ast.Converter:
overload.ConstEvalFunction = "Conv"
}
case 1:
overload.ConstEvalFunction = constEvalFn.Values[0]
default: