For the given struct type and member variable name, return the index of the variable in the struct and the specific MLIR type for the variable.
(self, memberName, structTy)
| 957 | return result |
| 958 | |
| 959 | def getStructMemberIdx(self, memberName, structTy): |
| 960 | """For the given struct type and member variable name, return the index |
| 961 | of the variable in the struct and the specific MLIR type for the |
| 962 | variable.""" |
| 963 | if cc.StructType.isinstance(structTy): |
| 964 | structName = cc.StructType.getName(structTy) |
| 965 | else: |
| 966 | structName = quake.StruqType.getName(structTy) |
| 967 | structIdx = None |
| 968 | if structName == 'tuple': |
| 969 | self.emitFatalError('`tuple` does not support attribute access') |
| 970 | if not globalRegisteredTypes.isRegisteredClass(structName): |
| 971 | self.emitFatalError(f'Dataclass is not registered: {structName})') |
| 972 | |
| 973 | _, userType = globalRegisteredTypes.getClassAttributes(structName) |
| 974 | for i, (k, _) in enumerate(userType.items()): |
| 975 | if k == memberName: |
| 976 | structIdx = i |
| 977 | break |
| 978 | if structIdx == None: |
| 979 | self.emitFatalError( |
| 980 | f'Invalid struct member: {structName}.{memberName} ' |
| 981 | f'(members={[k for k,_ in userType.items()]})') |
| 982 | return structIdx, mlirTypeFromPyType(userType[memberName], self.ctx) |
| 983 | |
| 984 | def __copyStructAndConvertElements(self, |
| 985 | struct, |
no test coverage detected