The constructor. Initializes the `mlir.Value` stack, the `mlir.Context`, and the `mlir.Module` that we will be building upon. This class keeps track of a symbol table, which maps variable names to constructed `mlir.Values`. As the AST is visited, the kernel signature
(self,
signature: KernelSignature,
defFrame,
*,
uniqueId=None,
kernelModuleName=None,
locationOffset=('', 0),
verbose=False,
cudaqAliases=None)
| 362 | """ |
| 363 | |
| 364 | def __init__(self, |
| 365 | signature: KernelSignature, |
| 366 | defFrame, |
| 367 | *, |
| 368 | uniqueId=None, |
| 369 | kernelModuleName=None, |
| 370 | locationOffset=('', 0), |
| 371 | verbose=False, |
| 372 | cudaqAliases=None): |
| 373 | """The constructor. Initializes the `mlir.Value` stack, the |
| 374 | `mlir.Context`, and the `mlir.Module` that we will be building upon. |
| 375 | This class keeps track of a symbol table, which maps variable names to |
| 376 | constructed `mlir.Values`. |
| 377 | |
| 378 | As the AST is visited, the kernel signature will be extended to capture |
| 379 | variables as required. |
| 380 | """ |
| 381 | |
| 382 | def node_error(msg): |
| 383 | self.emitFatalError(f'processing error - {msg}', self.currentNode) |
| 384 | |
| 385 | self.symbolTable = PyScopedSymbolTable(error_handler=node_error) |
| 386 | self.valueStack = PyStack(error_handler=node_error) |
| 387 | self.signature = signature |
| 388 | self.uniqueId = uniqueId |
| 389 | self.defFrame = defFrame |
| 390 | self.kernelModuleName = kernelModuleName |
| 391 | # Set of names that refer to the cudaq module, including aliases |
| 392 | # from `import cudaq as <alias>`. |
| 393 | self.cudaqAliases = cudaqAliases if cudaqAliases else {'cudaq'} |
| 394 | self.ctx = getMLIRContext() |
| 395 | self.loc = Location.unknown(context=self.ctx) |
| 396 | self.module = Module.create(self.loc) |
| 397 | |
| 398 | self.locationOffset = locationOffset |
| 399 | self.indent_level = 0 |
| 400 | self.indent = 4 * " " |
| 401 | self.buildingFunctionBody = False |
| 402 | self.inForBodyStack = deque() |
| 403 | self.inIfStmtBlockStack = 0 |
| 404 | self.currentAssignVariableName = None |
| 405 | self.walkingReturnNode = False |
| 406 | self.controlNegations = [] |
| 407 | self.pushPointerValue = False |
| 408 | self.isSubscriptRoot = False |
| 409 | self.verbose = verbose |
| 410 | self.currentNode = None |
| 411 | |
| 412 | def isCudaqName(self, name): |
| 413 | """Return True if `name` is 'cudaq' or a known alias for the cudaq |
nothing calls this directly
no test coverage detected