Loading mlir/parsers/qasm3/utils/symbol_table.hpp +8 −0 Original line number Diff line number Diff line Loading @@ -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, Loading mlir/parsers/qasm3/visitor_handlers/quantum_types_handler.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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()); } } } Loading Loading
mlir/parsers/qasm3/utils/symbol_table.hpp +8 −0 Original line number Diff line number Diff line Loading @@ -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, Loading
mlir/parsers/qasm3/visitor_handlers/quantum_types_handler.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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()); } } } Loading