Commit e197af57 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

fixed a bug in creating qreg of size given by global memref

parent 22652cf6
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -41,6 +41,14 @@ class ScopedSymbolTable {
  std::map<std::string, double> global_constants;

 public:

  template<typename T>
  T get_global_constant(const std::string variable_name) {
    if (!global_constants.count(variable_name)) {
      printErrorMessage("Invalid global constant variable name: " + variable_name);
    }
    return (T) global_constants[variable_name];
  }
  void set_op_builder(mlir::OpBuilder& b) { builder = &b; }

  void evaluate_const_global(const std::string variable_name,
+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ antlrcpp::Any qasm3_visitor::visitQuantumDeclaration(
      try {
        size = std::stoi(exp_list->expression(0)->getText());
      } catch (...) {

        
        // check if this is a constant expression
        qasm3_expression_generator exp_generator(builder, symbol_table,
                                                 file_name);
@@ -49,6 +51,8 @@ antlrcpp::Any qasm3_visitor::visitQuantumDeclaration(
            printErrorMessage(
                "This variable qubit size must be a constant integer.");
          }
        } else {
          size = symbol_table.get_global_constant<int64_t>(exp_list->expression(0)->getText());
        }
      }
    }