File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
backends/p4tools/modules/smith/common Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -673,8 +673,20 @@ IR::Declaration_Variable *DeclarationGenerator::genVariableDeclaration() {
673673 auto *expr = target ().expressionGenerator ().genExpression (tp);
674674 ret = new IR::Declaration_Variable (name, tp, expr);
675675 } else if (tp->is <IR::Type_Array>()) {
676- // header stacks do !have an initializer yet
677- ret = new IR::Declaration_Variable (name, tp);
676+ IR::Vector<IR::Expression> elems;
677+ const IR::Type_Array *arrayTp = dynamic_cast <const IR::Type_Array *>(tp);
678+ for (unsigned i = 0 ; i < arrayTp->getSize (); i++) {
679+ const IR::Expression *elem =
680+ target ().expressionGenerator ().genExpression (arrayTp->elementType );
681+ // To be safe, cast tuple expressions to the element type
682+ if (elem->is <IR::ListExpression>()) {
683+ elems.push_back (new IR::Cast (arrayTp->elementType , elem));
684+ } else {
685+ elems.push_back (elem);
686+ }
687+ }
688+ IR::ListExpression *init = new IR::ListExpression (elems);
689+ ret = new IR::Declaration_Variable (name, tp, init);
678690 } else {
679691 BUG (" Type %s not supported!" , tp->node_type_name ());
680692 }
You can’t perform that action at this time.
0 commit comments