ast: fix dump_vlog display of casex/casez
authorMarcelina Kościelnicka <mwk@0x04.net>
Wed, 27 Jan 2021 23:31:50 +0000 (00:31 +0100)
committerMarcelina Kościelnicka <mwk@0x04.net>
Fri, 29 Jan 2021 15:28:15 +0000 (16:28 +0100)
The first child of AST_CASE is the case expression, it's subsequent
childrean that are AST_COND* and can be used to discriminate the type of
the case.

frontends/ast/ast.cc

index 1c0a8b34df463a2a92e9ae887559945806b80cbf..dc47420af05ffc93f4ac8a6c985cf56200f3e8dc 100644 (file)
@@ -548,9 +548,9 @@ void AstNode::dumpVlog(FILE *f, std::string indent) const
                break;
 
        case AST_CASE:
-               if (!children.empty() && children[0]->type == AST_CONDX)
+               if (children.size() > 1 && children[1]->type == AST_CONDX)
                        fprintf(f, "%s" "casex (", indent.c_str());
-               else if (!children.empty() && children[0]->type == AST_CONDZ)
+               else if (children.size() > 1 && children[1]->type == AST_CONDZ)
                        fprintf(f, "%s" "casez (", indent.c_str());
                else
                        fprintf(f, "%s" "case (", indent.c_str());