natvis: add support for more ast types, and improve existing

Bug: tint:1331
Change-Id: I3195cf3d16ed66875f4bac5cac4922af802e4087
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/83202
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano 2022-03-15 13:38:29 +00:00 committed by Tint LUCI CQ
parent 400c59ae0c
commit 383e9b7b86
1 changed files with 76 additions and 7 deletions

View File

@ -23,13 +23,45 @@
<Type Name="tint::ast::AssignmentStatement"> <Type Name="tint::ast::AssignmentStatement">
<DisplayString>{*lhs} = {*rhs};</DisplayString> <DisplayString>{*lhs} = {*rhs};</DisplayString>
<DisplayString>{AstNodeToString(this)}</DisplayString>
<Expand> <Expand>
<Item Name="lhs">*lhs</Item> <Item Name="lhs">*lhs</Item>
<Item Name="rhs">*rhs</Item> <Item Name="rhs">*rhs</Item>
</Expand> </Expand>
</Type> </Type>
<Type Name="tint::ast::IfStatement">
<DisplayString Condition="else_statements.size() == 0">if ({*condition}) {*body}</DisplayString>
<DisplayString Condition="else_statements.size() == 1">if ({*condition}) {*body} {*else_statements[0]} </DisplayString>
<DisplayString Condition="else_statements.size() == 2">if ({*condition}) {*body} {*else_statements[0]} {*else_statements[1]} </DisplayString>
<DisplayString Condition="else_statements.size() == 3">if ({*condition}) {*body} {*else_statements[0]} {*else_statements[1]} {*else_statements[2]}</DisplayString>
<DisplayString Condition="else_statements.size() > 3">if ({*condition}) {*body} {*else_statements[0]} {*else_statements[1]} {*else_statements[2]} else {else_statements.size()-3} more...</DisplayString>
</Type>
<Type Name="tint::ast::ElseStatement">
<DisplayString Condition="!condition">else {*body}</DisplayString>
<DisplayString Condition="!!condition">else if ({*condition}) {*body}</DisplayString>
</Type>
<Type Name="tint::ast::BlockStatement">
<DisplayString Condition="statements.size() == 1">{{ {*statements[0]} }} </DisplayString>
<DisplayString Condition="statements.size() == 2">{{ {*statements[0]} {*statements[1]} }} </DisplayString>
<DisplayString Condition="statements.size() == 3">{{ {*statements[0]} {*statements[1]} {*statements[2]} }} </DisplayString>
<DisplayString Condition="statements.size() > 3">{{ {*statements[0]} {*statements[1]} {*statements[2]} {statements.size()-3} more... }} </DisplayString>
</Type>
<Type Name="tint::ast::ReturnStatement">
<DisplayString Condition="!value">return;</DisplayString>
<DisplayString Condition="!!value">return {*value};</DisplayString>
</Type>
<Type Name="tint::ast::Function">
<DisplayString Condition="params.size() == 0">fn {symbol}() -> {*return_type} {*body}</DisplayString>
<DisplayString Condition="params.size() == 1">fn {symbol}({*params[0]}) -> {*return_type} {*body}</DisplayString>
<DisplayString Condition="params.size() == 2">fn {symbol}({*params[0]} {*params[1]}) -> {*return_type} {*body}</DisplayString>
<DisplayString Condition="params.size() == 3">fn {symbol}({*params[0]} {*params[1]} {*params[2]}) -> {*return_type} {*body}</DisplayString>
<DisplayString Condition="params.size() > 3">fn {symbol}({*params[0]} {*params[1]} {*params[2]} {params.size()-3} more...) -> {*return_type} {*body}</DisplayString>
</Type>
<Type Name="tint::ast::IdentifierExpression"> <Type Name="tint::ast::IdentifierExpression">
<!--the ",sb" specifier removes the double quotes on the displayed string --> <!--the ",sb" specifier removes the double quotes on the displayed string -->
<DisplayString>{symbol}</DisplayString> <DisplayString>{symbol}</DisplayString>
@ -55,11 +87,14 @@
</Type> </Type>
<Type Name="tint::ast::Variable"> <Type Name="tint::ast::Variable">
<DisplayString Condition="is_const &amp; !!type">let {symbol} : {*type} = {*constructor}</DisplayString> <!-- Hack: we can deduce that this variable is a parameter if it's const with a type but no constructor, which is illegal for a let -->
<DisplayString Condition="is_const &amp; !type">let {symbol} = {*constructor}</DisplayString> <DisplayString Condition=" is_const &amp; !!type &amp; !constructor">{symbol} : {*type}</DisplayString>
<DisplayString Condition="!is_const &amp; !type">var {symbol} = {*constructor}</DisplayString>
<DisplayString Condition="!is_const &amp; !!type &amp; !constructor">var {symbol} : {*type}</DisplayString> <DisplayString Condition=" is_const &amp; !!type &amp; !!constructor">let {symbol} : {*type} = {*constructor}</DisplayString>
<DisplayString Condition=" is_const &amp; !type &amp; !constructor">let {symbol} = {*constructor}</DisplayString>
<DisplayString Condition="!is_const &amp; !!type &amp; !!constructor">var {symbol} : {*type} = {*constructor}</DisplayString> <DisplayString Condition="!is_const &amp; !!type &amp; !!constructor">var {symbol} : {*type} = {*constructor}</DisplayString>
<DisplayString Condition="!is_const &amp; !type &amp; !!constructor">var {symbol} = {*constructor}</DisplayString>
<DisplayString Condition="!is_const &amp; !!type &amp; !constructor">var {symbol}</DisplayString>
</Type> </Type>
<Type Name="tint::ast::VariableDeclStatement"> <Type Name="tint::ast::VariableDeclStatement">
@ -74,8 +109,42 @@
<DisplayString>{value}</DisplayString> <DisplayString>{value}</DisplayString>
</Type> </Type>
<Type Name="tint::ast::BoolLiteralExpression">
<DisplayString>{value}</DisplayString>
</Type>
<Type Name="tint::ast::Void">
<DisplayString>void</DisplayString>
</Type>
<Type Name="tint::ast::UnaryOpExpression">
<DisplayString Condition="op==tint::ast::UnaryOp::kAddressOf">&amp;({expr})</DisplayString>
<DisplayString Condition="op==tint::ast::UnaryOp::kComplement">~({expr})</DisplayString>
<DisplayString Condition="op==tint::ast::UnaryOp::kIndirection">*({expr})</DisplayString>
<DisplayString Condition="op==tint::ast::UnaryOp::kNegation">-({expr})</DisplayString>
<DisplayString Condition="op==tint::ast::UnaryOp::kNot">!({expr})</DisplayString>
</Type>
<Type Name="tint::ast::BinaryExpression"> <Type Name="tint::ast::BinaryExpression">
<DisplayString>({*lhs} {op,en} {*rhs})</DisplayString> <DisplayString Condition="op==tint::ast::BinaryOp::kNone">({*lhs} NONE {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kAnd">({*lhs} &amp; {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kOr">({*lhs} | {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kXor">({*lhs} ^ {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kLogicalAnd">({*lhs} &amp;&amp; {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kLogicalOr">({*lhs} || {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kEqual">({*lhs} == {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kNotEqual">({*lhs} != {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kLessThan">({*lhs} &lt; {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kGreaterThan">({*lhs} &gt; {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kLessThanEqual">({*lhs} &lt;= {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kGreaterThanEqual">({*lhs} &gt;= {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kShiftLeft">({*lhs} &lt;&lt; {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kShiftRight">({*lhs} >> {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kAdd">({*lhs} + {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kSubtract">({*lhs} - {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kMultiply">({*lhs} * {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kDivide">({*lhs} / {*rhs})</DisplayString>
<DisplayString Condition="op==tint::ast::BinaryOp::kModulo">({*lhs} % {*rhs})</DisplayString>
</Type> </Type>
<Type Name="tint::ast::CallExpression"> <Type Name="tint::ast::CallExpression">
@ -83,7 +152,7 @@
<DisplayString Condition="args.size() == 1">{target}({*args[0]})</DisplayString> <DisplayString Condition="args.size() == 1">{target}({*args[0]})</DisplayString>
<DisplayString Condition="args.size() == 2">{target}({*args[0]}, {*args[1]})</DisplayString> <DisplayString Condition="args.size() == 2">{target}({*args[0]}, {*args[1]})</DisplayString>
<DisplayString Condition="args.size() == 3">{target}({*args[0]}, {*args[1]}, {*args[2]})</DisplayString> <DisplayString Condition="args.size() == 3">{target}({*args[0]}, {*args[1]}, {*args[2]})</DisplayString>
<DisplayString Condition="args.size() > 3">{target}({*args[0]}, {*args[1]}, {*args[2]}, ...)</DisplayString> <DisplayString Condition="args.size() > 3">{target}({*args[0]}, {*args[1]}, {*args[2]}, {args.size()-3} more...)</DisplayString>
<!-- TODO: add more overloads --> <!-- TODO: add more overloads -->
</Type> </Type>