Commit 2dabec02 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Break the Loop statement handling code into separate helper functions for maintainability



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent bbe27aee
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -236,6 +236,14 @@ class qasm3_visitor : public qasm3::qasm3BaseVisitor {
                                     mlir::Location location,
                                     antlr4::ParserRuleContext* context);

  // Helper to handle range-based for loop
  void createRangeBasedForLoop(qasm3Parser::LoopStatementContext *context);
  // Helper to handle set-based for loop:
  // e.g., for i in {1,4,6,7}:
  void createSetBasedForLoop(qasm3Parser::LoopStatementContext *context);
  // While loop
  void createWhileLoop(qasm3Parser::LoopStatementContext *context);

  // This function serves as a utility for creating a MemRef and
  // corresponding AllocOp of a given 1d shape. It will also store
  // initial values to all elements of the 1d array.
+0 −1
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ print("made it out of the loop");

TEST(qasm3VisitorTester, checkCtrlDirectivesComplex) {
  const std::string uint_index = R"#(OPENQASM 3;
OPENQASM 3;
include "qelib1.inc";

int[64] iterate_value = 0;
+342 −403

File changed.

Preview size limit exceeded, changes collapsed.