libqasm 0.5.2__cp38-cp38-win_amd64.whl → 0.6.1__cp38-cp38-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cqasm/v3x/semantic.py CHANGED
@@ -638,12 +638,10 @@ class Annotated(Node):
638
638
  typ = cbor.get('@t', None)
639
639
  if typ is None:
640
640
  raise ValueError('type (@t) field is missing from node serialization')
641
- if typ == 'Instruction':
642
- return Instruction._deserialize(cbor, seq_to_ob, links)
643
- if typ == 'AssignmentInstruction':
644
- return AssignmentInstruction._deserialize(cbor, seq_to_ob, links)
645
641
  if typ == 'Variable':
646
642
  return Variable._deserialize(cbor, seq_to_ob, links)
643
+ if typ == 'Instruction':
644
+ return Instruction._deserialize(cbor, seq_to_ob, links)
647
645
  raise ValueError('unknown or unexpected type (@t) found in node serialization')
648
646
 
649
647
  def _serialize(self, id_map):
@@ -970,230 +968,43 @@ class MultiAnnotationData(_Multiple):
970
968
 
971
969
  _typemap['AnnotationData'] = AnnotationData
972
970
 
973
- class Statement(Annotated):
974
- __slots__ = []
975
-
976
- def __init__(
977
- self,
978
- annotations=None,
979
- ):
980
- super().__init__(annotations=annotations)
981
-
982
- @staticmethod
983
- def _deserialize(cbor, seq_to_ob, links):
984
- """Attempts to deserialize the given cbor object (in Python primitive
985
- representation) into a node of this type. All (sub)nodes are added to
986
- the seq_to_ob dict, indexed by their cbor sequence number. All links are
987
- registered in the links list by means of a two-tuple of the setter
988
- function for the link field and the sequence number of the target node.
989
- """
990
- if not isinstance(cbor, dict):
991
- raise TypeError('node description object must be a dict')
992
- typ = cbor.get('@t', None)
993
- if typ is None:
994
- raise ValueError('type (@t) field is missing from node serialization')
995
- if typ == 'Instruction':
996
- return Instruction._deserialize(cbor, seq_to_ob, links)
997
- if typ == 'AssignmentInstruction':
998
- return AssignmentInstruction._deserialize(cbor, seq_to_ob, links)
999
- raise ValueError('unknown or unexpected type (@t) found in node serialization')
1000
-
1001
- def _serialize(self, id_map):
1002
- """Serializes this node to the Python primitive representation of its
1003
- CBOR serialization. The tree that the node belongs to must be
1004
- well-formed. id_map must match Python id() calls for all nodes to unique
1005
- integers, to use for the sequence number representation of links."""
1006
- cbor = {'@i': id_map[id(self)], '@t': 'Statement'}
1007
-
1008
- # Serialize the annotations field.
1009
- field = {'@T': '*'}
1010
- lst = []
1011
- for el in self._attr_annotations:
1012
- el = el._serialize(id_map)
1013
- el['@T'] = '1'
1014
- lst.append(el)
1015
- field['@d'] = lst
1016
- cbor['annotations'] = field
1017
-
1018
- # Serialize annotations.
1019
- for key, val in self._annot.items():
1020
- cbor['{%s}' % key] = _py_to_cbor(cqasm.v3x.primitives.serialize(key, val))
1021
-
1022
- return cbor
1023
-
1024
-
1025
- class MultiStatement(_Multiple):
1026
- """Wrapper for an edge with multiple Statement objects."""
1027
-
1028
- _T = Statement
1029
-
1030
-
1031
- _typemap['Statement'] = Statement
1032
-
1033
- class InstructionBase(Statement):
1034
- __slots__ = [
1035
- '_attr_condition',
1036
- ]
1037
-
1038
- def __init__(
1039
- self,
1040
- condition=None,
1041
- annotations=None,
1042
- ):
1043
- super().__init__(annotations=annotations)
1044
- self.condition = condition
1045
-
1046
- @property
1047
- def condition(self):
1048
- """Condition (C- notation). When there is no condition, this is a
1049
- constant boolean set to true."""
1050
- return self._attr_condition
1051
-
1052
- @condition.setter
1053
- def condition(self, val):
1054
- if val is None:
1055
- del self.condition
1056
- return
1057
- if not isinstance(val, cqasm.v3x.values.Node):
1058
- # Try to "typecast" if this isn't an obvious mistake.
1059
- if isinstance(val, Node):
1060
- raise TypeError('condition must be of type cqasm.v3x.values.Node')
1061
- val = cqasm.v3x.values.Node(val)
1062
- self._attr_condition = val
1063
-
1064
- @condition.deleter
1065
- def condition(self):
1066
- self._attr_condition = None
1067
-
1068
- @staticmethod
1069
- def _deserialize(cbor, seq_to_ob, links):
1070
- """Attempts to deserialize the given cbor object (in Python primitive
1071
- representation) into a node of this type. All (sub)nodes are added to
1072
- the seq_to_ob dict, indexed by their cbor sequence number. All links are
1073
- registered in the links list by means of a two-tuple of the setter
1074
- function for the link field and the sequence number of the target node.
1075
- """
1076
- if not isinstance(cbor, dict):
1077
- raise TypeError('node description object must be a dict')
1078
- typ = cbor.get('@t', None)
1079
- if typ is None:
1080
- raise ValueError('type (@t) field is missing from node serialization')
1081
- if typ == 'Instruction':
1082
- return Instruction._deserialize(cbor, seq_to_ob, links)
1083
- if typ == 'AssignmentInstruction':
1084
- return AssignmentInstruction._deserialize(cbor, seq_to_ob, links)
1085
- raise ValueError('unknown or unexpected type (@t) found in node serialization')
1086
-
1087
- def _serialize(self, id_map):
1088
- """Serializes this node to the Python primitive representation of its
1089
- CBOR serialization. The tree that the node belongs to must be
1090
- well-formed. id_map must match Python id() calls for all nodes to unique
1091
- integers, to use for the sequence number representation of links."""
1092
- cbor = {'@i': id_map[id(self)], '@t': 'InstructionBase'}
1093
-
1094
- # Serialize the condition field.
1095
- field = {'@T': '1'}
1096
- if self._attr_condition is None:
1097
- field['@t'] = None
1098
- else:
1099
- field.update(self._attr_condition._serialize(id_map))
1100
- cbor['condition'] = field
1101
-
1102
- # Serialize the annotations field.
1103
- field = {'@T': '*'}
1104
- lst = []
1105
- for el in self._attr_annotations:
1106
- el = el._serialize(id_map)
1107
- el['@T'] = '1'
1108
- lst.append(el)
1109
- field['@d'] = lst
1110
- cbor['annotations'] = field
1111
-
1112
- # Serialize annotations.
1113
- for key, val in self._annot.items():
1114
- cbor['{%s}' % key] = _py_to_cbor(cqasm.v3x.primitives.serialize(key, val))
1115
-
1116
- return cbor
1117
-
1118
-
1119
- class MultiInstructionBase(_Multiple):
1120
- """Wrapper for an edge with multiple InstructionBase objects."""
1121
-
1122
- _T = InstructionBase
1123
-
1124
-
1125
- _typemap['InstructionBase'] = InstructionBase
1126
-
1127
- class AssignmentInstruction(InstructionBase):
971
+ class Block(Node):
1128
972
  __slots__ = [
1129
- '_attr_lhs',
1130
- '_attr_rhs',
973
+ '_attr_statements',
1131
974
  ]
1132
975
 
1133
976
  def __init__(
1134
977
  self,
1135
- lhs=None,
1136
- rhs=None,
1137
- condition=None,
1138
- annotations=None,
978
+ statements=None,
1139
979
  ):
1140
- super().__init__(condition=condition, annotations=annotations)
1141
- self.lhs = lhs
1142
- self.rhs = rhs
1143
-
1144
- @property
1145
- def lhs(self):
1146
- """The assignment target."""
1147
- return self._attr_lhs
1148
-
1149
- @lhs.setter
1150
- def lhs(self, val):
1151
- if val is None:
1152
- del self.lhs
1153
- return
1154
- if not isinstance(val, cqasm.v3x.values.Node):
1155
- # Try to "typecast" if this isn't an obvious mistake.
1156
- if isinstance(val, Node):
1157
- raise TypeError('lhs must be of type cqasm.v3x.values.Node')
1158
- val = cqasm.v3x.values.Node(val)
1159
- self._attr_lhs = val
1160
-
1161
- @lhs.deleter
1162
- def lhs(self):
1163
- self._attr_lhs = None
980
+ super().__init__()
981
+ self.statements = statements
1164
982
 
1165
983
  @property
1166
- def rhs(self):
1167
- """The value to assign."""
1168
- return self._attr_rhs
984
+ def statements(self):
985
+ return self._attr_statements
1169
986
 
1170
- @rhs.setter
1171
- def rhs(self, val):
987
+ @statements.setter
988
+ def statements(self, val):
1172
989
  if val is None:
1173
- del self.rhs
990
+ del self.statements
1174
991
  return
1175
- if not isinstance(val, cqasm.v3x.values.Node):
992
+ if not isinstance(val, MultiStatement):
1176
993
  # Try to "typecast" if this isn't an obvious mistake.
1177
994
  if isinstance(val, Node):
1178
- raise TypeError('rhs must be of type cqasm.v3x.values.Node')
1179
- val = cqasm.v3x.values.Node(val)
1180
- self._attr_rhs = val
995
+ raise TypeError('statements must be of type MultiStatement')
996
+ val = MultiStatement(val)
997
+ self._attr_statements = val
1181
998
 
1182
- @rhs.deleter
1183
- def rhs(self):
1184
- self._attr_rhs = None
999
+ @statements.deleter
1000
+ def statements(self):
1001
+ self._attr_statements = MultiStatement()
1185
1002
 
1186
1003
  def __eq__(self, other):
1187
1004
  """Equality operator. Ignores annotations!"""
1188
- if not isinstance(other, AssignmentInstruction):
1189
- return False
1190
- if self.lhs != other.lhs:
1005
+ if not isinstance(other, Block):
1191
1006
  return False
1192
- if self.rhs != other.rhs:
1193
- return False
1194
- if self.condition != other.condition:
1195
- return False
1196
- if self.annotations != other.annotations:
1007
+ if self.statements != other.statements:
1197
1008
  return False
1198
1009
  return True
1199
1010
 
@@ -1204,7 +1015,7 @@ class AssignmentInstruction(InstructionBase):
1204
1015
  strings of the annotations that are to be printed. links specifies the
1205
1016
  maximum link recursion depth."""
1206
1017
  s = [' '*indent]
1207
- s.append('AssignmentInstruction(')
1018
+ s.append('Block(')
1208
1019
  if annotations is None:
1209
1020
  annotations = []
1210
1021
  for key in annotations:
@@ -1213,36 +1024,12 @@ class AssignmentInstruction(InstructionBase):
1213
1024
  s.append('\n')
1214
1025
  indent += 1
1215
1026
  s.append(' '*indent)
1216
- s.append('lhs: ')
1217
- if self.lhs is None:
1218
- s.append('!MISSING\n')
1219
- else:
1220
- s.append('<\n')
1221
- s.append(self.lhs.dump(indent + 1, annotations, links) + '\n')
1222
- s.append(' '*indent + '>\n')
1223
- s.append(' '*indent)
1224
- s.append('rhs: ')
1225
- if self.rhs is None:
1226
- s.append('!MISSING\n')
1227
- else:
1228
- s.append('<\n')
1229
- s.append(self.rhs.dump(indent + 1, annotations, links) + '\n')
1230
- s.append(' '*indent + '>\n')
1231
- s.append(' '*indent)
1232
- s.append('condition: ')
1233
- if self.condition is None:
1234
- s.append('!MISSING\n')
1235
- else:
1236
- s.append('<\n')
1237
- s.append(self.condition.dump(indent + 1, annotations, links) + '\n')
1238
- s.append(' '*indent + '>\n')
1239
- s.append(' '*indent)
1240
- s.append('annotations: ')
1241
- if not self.annotations:
1027
+ s.append('statements: ')
1028
+ if not self.statements:
1242
1029
  s.append('-\n')
1243
1030
  else:
1244
1031
  s.append('[\n')
1245
- for child in self.annotations:
1032
+ for child in self.statements:
1246
1033
  s.append(child.dump(indent + 1, annotations, links) + '\n')
1247
1034
  s.append(' '*indent + ']\n')
1248
1035
  indent -= 1
@@ -1262,13 +1049,7 @@ class AssignmentInstruction(InstructionBase):
1262
1049
  if id(self) in id_map:
1263
1050
  raise NotWellFormed('node {!r} with id {} occurs more than once'.format(self, id(self)))
1264
1051
  id_map[id(self)] = len(id_map)
1265
- if self._attr_lhs is not None:
1266
- self._attr_lhs.find_reachable(id_map)
1267
- if self._attr_rhs is not None:
1268
- self._attr_rhs.find_reachable(id_map)
1269
- if self._attr_condition is not None:
1270
- self._attr_condition.find_reachable(id_map)
1271
- for el in self._attr_annotations:
1052
+ for el in self._attr_statements:
1272
1053
  el.find_reachable(id_map)
1273
1054
  return id_map
1274
1055
 
@@ -1279,28 +1060,13 @@ class AssignmentInstruction(InstructionBase):
1279
1060
  id() codes to tree indices for all reachable nodes."""
1280
1061
  if id_map is None:
1281
1062
  id_map = self.find_reachable()
1282
- if self._attr_lhs is None:
1283
- raise NotWellFormed('lhs is required but not set')
1284
- if self._attr_lhs is not None:
1285
- self._attr_lhs.check_complete(id_map)
1286
- if self._attr_rhs is None:
1287
- raise NotWellFormed('rhs is required but not set')
1288
- if self._attr_rhs is not None:
1289
- self._attr_rhs.check_complete(id_map)
1290
- if self._attr_condition is None:
1291
- raise NotWellFormed('condition is required but not set')
1292
- if self._attr_condition is not None:
1293
- self._attr_condition.check_complete(id_map)
1294
- for child in self._attr_annotations:
1063
+ for child in self._attr_statements:
1295
1064
  child.check_complete(id_map)
1296
1065
 
1297
1066
  def copy(self):
1298
1067
  """Returns a shallow copy of this node."""
1299
- return AssignmentInstruction(
1300
- lhs=self._attr_lhs,
1301
- rhs=self._attr_rhs,
1302
- condition=self._attr_condition,
1303
- annotations=self._attr_annotations.copy()
1068
+ return Block(
1069
+ statements=self._attr_statements.copy()
1304
1070
  )
1305
1071
 
1306
1072
  def clone(self):
@@ -1309,11 +1075,8 @@ class AssignmentInstruction(InstructionBase):
1309
1075
  original tree. If you're not cloning a subtree in a context where this
1310
1076
  is the desired behavior, you may want to use the copy.deepcopy() from
1311
1077
  the stdlib instead, which should copy links correctly."""
1312
- return AssignmentInstruction(
1313
- lhs=_cloned(self._attr_lhs),
1314
- rhs=_cloned(self._attr_rhs),
1315
- condition=_cloned(self._attr_condition),
1316
- annotations=_cloned(self._attr_annotations)
1078
+ return Block(
1079
+ statements=_cloned(self._attr_statements)
1317
1080
  )
1318
1081
 
1319
1082
  @staticmethod
@@ -1329,59 +1092,26 @@ class AssignmentInstruction(InstructionBase):
1329
1092
  typ = cbor.get('@t', None)
1330
1093
  if typ is None:
1331
1094
  raise ValueError('type (@t) field is missing from node serialization')
1332
- if typ != 'AssignmentInstruction':
1333
- raise ValueError('found node serialization for ' + typ + ', but expected AssignmentInstruction')
1095
+ if typ != 'Block':
1096
+ raise ValueError('found node serialization for ' + typ + ', but expected Block')
1334
1097
 
1335
- # Deserialize the lhs field.
1336
- field = cbor.get('lhs', None)
1337
- if not isinstance(field, dict):
1338
- raise ValueError('missing or invalid serialization of field lhs')
1339
- if field.get('@T') != '1':
1340
- raise ValueError('unexpected edge type for field lhs')
1341
- if field.get('@t', None) is None:
1342
- f_lhs = None
1343
- else:
1344
- f_lhs = cqasm.v3x.values.Node._deserialize(field, seq_to_ob, links)
1345
-
1346
- # Deserialize the rhs field.
1347
- field = cbor.get('rhs', None)
1348
- if not isinstance(field, dict):
1349
- raise ValueError('missing or invalid serialization of field rhs')
1350
- if field.get('@T') != '1':
1351
- raise ValueError('unexpected edge type for field rhs')
1352
- if field.get('@t', None) is None:
1353
- f_rhs = None
1354
- else:
1355
- f_rhs = cqasm.v3x.values.Node._deserialize(field, seq_to_ob, links)
1356
-
1357
- # Deserialize the condition field.
1358
- field = cbor.get('condition', None)
1359
- if not isinstance(field, dict):
1360
- raise ValueError('missing or invalid serialization of field condition')
1361
- if field.get('@T') != '1':
1362
- raise ValueError('unexpected edge type for field condition')
1363
- if field.get('@t', None) is None:
1364
- f_condition = None
1365
- else:
1366
- f_condition = cqasm.v3x.values.Node._deserialize(field, seq_to_ob, links)
1367
-
1368
- # Deserialize the annotations field.
1369
- field = cbor.get('annotations', None)
1098
+ # Deserialize the statements field.
1099
+ field = cbor.get('statements', None)
1370
1100
  if not isinstance(field, dict):
1371
- raise ValueError('missing or invalid serialization of field annotations')
1101
+ raise ValueError('missing or invalid serialization of field statements')
1372
1102
  if field.get('@T') != '*':
1373
- raise ValueError('unexpected edge type for field annotations')
1103
+ raise ValueError('unexpected edge type for field statements')
1374
1104
  data = field.get('@d', None)
1375
1105
  if not isinstance(data, list):
1376
1106
  raise ValueError('missing serialization of Any/Many contents')
1377
- f_annotations = MultiAnnotationData()
1107
+ f_statements = MultiStatement()
1378
1108
  for element in data:
1379
1109
  if element.get('@T') != '1':
1380
1110
  raise ValueError('unexpected edge type for Any/Many element')
1381
- f_annotations.append(AnnotationData._deserialize(element, seq_to_ob, links))
1111
+ f_statements.append(Statement._deserialize(element, seq_to_ob, links))
1382
1112
 
1383
- # Construct the AssignmentInstruction node.
1384
- node = AssignmentInstruction(f_lhs, f_rhs, f_condition, f_annotations)
1113
+ # Construct the Block node.
1114
+ node = Block(f_statements)
1385
1115
 
1386
1116
  # Deserialize annotations.
1387
1117
  for key, val in cbor.items():
@@ -1405,31 +1135,65 @@ class AssignmentInstruction(InstructionBase):
1405
1135
  CBOR serialization. The tree that the node belongs to must be
1406
1136
  well-formed. id_map must match Python id() calls for all nodes to unique
1407
1137
  integers, to use for the sequence number representation of links."""
1408
- cbor = {'@i': id_map[id(self)], '@t': 'AssignmentInstruction'}
1138
+ cbor = {'@i': id_map[id(self)], '@t': 'Block'}
1409
1139
 
1410
- # Serialize the lhs field.
1411
- field = {'@T': '1'}
1412
- if self._attr_lhs is None:
1413
- field['@t'] = None
1414
- else:
1415
- field.update(self._attr_lhs._serialize(id_map))
1416
- cbor['lhs'] = field
1140
+ # Serialize the statements field.
1141
+ field = {'@T': '*'}
1142
+ lst = []
1143
+ for el in self._attr_statements:
1144
+ el = el._serialize(id_map)
1145
+ el['@T'] = '1'
1146
+ lst.append(el)
1147
+ field['@d'] = lst
1148
+ cbor['statements'] = field
1417
1149
 
1418
- # Serialize the rhs field.
1419
- field = {'@T': '1'}
1420
- if self._attr_rhs is None:
1421
- field['@t'] = None
1422
- else:
1423
- field.update(self._attr_rhs._serialize(id_map))
1424
- cbor['rhs'] = field
1150
+ # Serialize annotations.
1151
+ for key, val in self._annot.items():
1152
+ cbor['{%s}' % key] = _py_to_cbor(cqasm.v3x.primitives.serialize(key, val))
1425
1153
 
1426
- # Serialize the condition field.
1427
- field = {'@T': '1'}
1428
- if self._attr_condition is None:
1429
- field['@t'] = None
1430
- else:
1431
- field.update(self._attr_condition._serialize(id_map))
1432
- cbor['condition'] = field
1154
+ return cbor
1155
+
1156
+
1157
+ class MultiBlock(_Multiple):
1158
+ """Wrapper for an edge with multiple Block objects."""
1159
+
1160
+ _T = Block
1161
+
1162
+
1163
+ _typemap['Block'] = Block
1164
+
1165
+ class Statement(Annotated):
1166
+ __slots__ = []
1167
+
1168
+ def __init__(
1169
+ self,
1170
+ annotations=None,
1171
+ ):
1172
+ super().__init__(annotations=annotations)
1173
+
1174
+ @staticmethod
1175
+ def _deserialize(cbor, seq_to_ob, links):
1176
+ """Attempts to deserialize the given cbor object (in Python primitive
1177
+ representation) into a node of this type. All (sub)nodes are added to
1178
+ the seq_to_ob dict, indexed by their cbor sequence number. All links are
1179
+ registered in the links list by means of a two-tuple of the setter
1180
+ function for the link field and the sequence number of the target node.
1181
+ """
1182
+ if not isinstance(cbor, dict):
1183
+ raise TypeError('node description object must be a dict')
1184
+ typ = cbor.get('@t', None)
1185
+ if typ is None:
1186
+ raise ValueError('type (@t) field is missing from node serialization')
1187
+ if typ == 'Instruction':
1188
+ return Instruction._deserialize(cbor, seq_to_ob, links)
1189
+ raise ValueError('unknown or unexpected type (@t) found in node serialization')
1190
+
1191
+ def _serialize(self, id_map):
1192
+ """Serializes this node to the Python primitive representation of its
1193
+ CBOR serialization. The tree that the node belongs to must be
1194
+ well-formed. id_map must match Python id() calls for all nodes to unique
1195
+ integers, to use for the sequence number representation of links."""
1196
+ cbor = {'@i': id_map[id(self)], '@t': 'Statement'}
1433
1197
 
1434
1198
  # Serialize the annotations field.
1435
1199
  field = {'@T': '*'}
@@ -1448,60 +1212,57 @@ class AssignmentInstruction(InstructionBase):
1448
1212
  return cbor
1449
1213
 
1450
1214
 
1451
- class MultiAssignmentInstruction(_Multiple):
1452
- """Wrapper for an edge with multiple AssignmentInstruction objects."""
1215
+ class MultiStatement(_Multiple):
1216
+ """Wrapper for an edge with multiple Statement objects."""
1453
1217
 
1454
- _T = AssignmentInstruction
1218
+ _T = Statement
1455
1219
 
1456
1220
 
1457
- _typemap['AssignmentInstruction'] = AssignmentInstruction
1221
+ _typemap['Statement'] = Statement
1458
1222
 
1459
- class Instruction(InstructionBase):
1460
- """A regular instruction (gate)."""
1223
+ class Instruction(Statement):
1224
+ """Regular instruction (a gate, or a measure instruction)."""
1461
1225
 
1462
1226
  __slots__ = [
1463
- '_attr_instruction',
1227
+ '_attr_instruction_ref',
1464
1228
  '_attr_name',
1465
1229
  '_attr_operands',
1466
1230
  ]
1467
1231
 
1468
1232
  def __init__(
1469
1233
  self,
1470
- instruction=None,
1234
+ instruction_ref=None,
1471
1235
  name=None,
1472
1236
  operands=None,
1473
- condition=None,
1474
1237
  annotations=None,
1475
1238
  ):
1476
- super().__init__(condition=condition, annotations=annotations)
1477
- self.instruction = instruction
1239
+ super().__init__(annotations=annotations)
1240
+ self.instruction_ref = instruction_ref
1478
1241
  self.name = name
1479
1242
  self.operands = operands
1480
1243
 
1481
1244
  @property
1482
- def instruction(self):
1483
- """Instruction type as registered through the API."""
1484
- return self._attr_instruction
1245
+ def instruction_ref(self):
1246
+ return self._attr_instruction_ref
1485
1247
 
1486
- @instruction.setter
1487
- def instruction(self, val):
1248
+ @instruction_ref.setter
1249
+ def instruction_ref(self, val):
1488
1250
  if val is None:
1489
- del self.instruction
1251
+ del self.instruction_ref
1490
1252
  return
1491
1253
  if not isinstance(val, cqasm.v3x.instruction.InstructionRef):
1492
1254
  # Try to "typecast" if this isn't an obvious mistake.
1493
1255
  if isinstance(val, Node):
1494
- raise TypeError('instruction must be of type cqasm.v3x.instruction.InstructionRef')
1256
+ raise TypeError('instruction_ref must be of type cqasm.v3x.instruction.InstructionRef')
1495
1257
  val = cqasm.v3x.instruction.InstructionRef(val)
1496
- self._attr_instruction = val
1258
+ self._attr_instruction_ref = val
1497
1259
 
1498
- @instruction.deleter
1499
- def instruction(self):
1500
- self._attr_instruction = cqasm.v3x.instruction.InstructionRef()
1260
+ @instruction_ref.deleter
1261
+ def instruction_ref(self):
1262
+ self._attr_instruction_ref = cqasm.v3x.instruction.InstructionRef()
1501
1263
 
1502
1264
  @property
1503
1265
  def name(self):
1504
- """Name as it appears in the cQASM file."""
1505
1266
  return self._attr_name
1506
1267
 
1507
1268
  @name.setter
@@ -1522,7 +1283,6 @@ class Instruction(InstructionBase):
1522
1283
 
1523
1284
  @property
1524
1285
  def operands(self):
1525
- """Operands for the instruction."""
1526
1286
  return self._attr_operands
1527
1287
 
1528
1288
  @operands.setter
@@ -1530,29 +1290,27 @@ class Instruction(InstructionBase):
1530
1290
  if val is None:
1531
1291
  del self.operands
1532
1292
  return
1533
- if not isinstance(val, cqasm.v3x.values.MultiNode):
1293
+ if not isinstance(val, cqasm.v3x.values.MultiValueBase):
1534
1294
  # Try to "typecast" if this isn't an obvious mistake.
1535
1295
  if isinstance(val, Node):
1536
- raise TypeError('operands must be of type cqasm.v3x.values.MultiNode')
1537
- val = cqasm.v3x.values.MultiNode(val)
1296
+ raise TypeError('operands must be of type cqasm.v3x.values.MultiValueBase')
1297
+ val = cqasm.v3x.values.MultiValueBase(val)
1538
1298
  self._attr_operands = val
1539
1299
 
1540
1300
  @operands.deleter
1541
1301
  def operands(self):
1542
- self._attr_operands = cqasm.v3x.values.MultiNode()
1302
+ self._attr_operands = cqasm.v3x.values.MultiValueBase()
1543
1303
 
1544
1304
  def __eq__(self, other):
1545
1305
  """Equality operator. Ignores annotations!"""
1546
1306
  if not isinstance(other, Instruction):
1547
1307
  return False
1548
- if self.instruction != other.instruction:
1308
+ if self.instruction_ref != other.instruction_ref:
1549
1309
  return False
1550
1310
  if self.name != other.name:
1551
1311
  return False
1552
1312
  if self.operands != other.operands:
1553
1313
  return False
1554
- if self.condition != other.condition:
1555
- return False
1556
1314
  if self.annotations != other.annotations:
1557
1315
  return False
1558
1316
  return True
@@ -1573,8 +1331,8 @@ class Instruction(InstructionBase):
1573
1331
  s.append('\n')
1574
1332
  indent += 1
1575
1333
  s.append(' '*indent)
1576
- s.append('instruction: ')
1577
- s.append(str(self.instruction) + '\n')
1334
+ s.append('instruction_ref: ')
1335
+ s.append(str(self.instruction_ref) + '\n')
1578
1336
  s.append(' '*indent)
1579
1337
  s.append('name: ')
1580
1338
  s.append(str(self.name) + '\n')
@@ -1588,14 +1346,6 @@ class Instruction(InstructionBase):
1588
1346
  s.append(child.dump(indent + 1, annotations, links) + '\n')
1589
1347
  s.append(' '*indent + ']\n')
1590
1348
  s.append(' '*indent)
1591
- s.append('condition: ')
1592
- if self.condition is None:
1593
- s.append('!MISSING\n')
1594
- else:
1595
- s.append('<\n')
1596
- s.append(self.condition.dump(indent + 1, annotations, links) + '\n')
1597
- s.append(' '*indent + '>\n')
1598
- s.append(' '*indent)
1599
1349
  s.append('annotations: ')
1600
1350
  if not self.annotations:
1601
1351
  s.append('-\n')
@@ -1623,8 +1373,6 @@ class Instruction(InstructionBase):
1623
1373
  id_map[id(self)] = len(id_map)
1624
1374
  for el in self._attr_operands:
1625
1375
  el.find_reachable(id_map)
1626
- if self._attr_condition is not None:
1627
- self._attr_condition.find_reachable(id_map)
1628
1376
  for el in self._attr_annotations:
1629
1377
  el.find_reachable(id_map)
1630
1378
  return id_map
@@ -1638,20 +1386,15 @@ class Instruction(InstructionBase):
1638
1386
  id_map = self.find_reachable()
1639
1387
  for child in self._attr_operands:
1640
1388
  child.check_complete(id_map)
1641
- if self._attr_condition is None:
1642
- raise NotWellFormed('condition is required but not set')
1643
- if self._attr_condition is not None:
1644
- self._attr_condition.check_complete(id_map)
1645
1389
  for child in self._attr_annotations:
1646
1390
  child.check_complete(id_map)
1647
1391
 
1648
1392
  def copy(self):
1649
1393
  """Returns a shallow copy of this node."""
1650
1394
  return Instruction(
1651
- instruction=self._attr_instruction,
1395
+ instruction_ref=self._attr_instruction_ref,
1652
1396
  name=self._attr_name,
1653
1397
  operands=self._attr_operands.copy(),
1654
- condition=self._attr_condition,
1655
1398
  annotations=self._attr_annotations.copy()
1656
1399
  )
1657
1400
 
@@ -1662,10 +1405,9 @@ class Instruction(InstructionBase):
1662
1405
  is the desired behavior, you may want to use the copy.deepcopy() from
1663
1406
  the stdlib instead, which should copy links correctly."""
1664
1407
  return Instruction(
1665
- instruction=_cloned(self._attr_instruction),
1408
+ instruction_ref=_cloned(self._attr_instruction_ref),
1666
1409
  name=_cloned(self._attr_name),
1667
1410
  operands=_cloned(self._attr_operands),
1668
- condition=_cloned(self._attr_condition),
1669
1411
  annotations=_cloned(self._attr_annotations)
1670
1412
  )
1671
1413
 
@@ -1685,14 +1427,14 @@ class Instruction(InstructionBase):
1685
1427
  if typ != 'Instruction':
1686
1428
  raise ValueError('found node serialization for ' + typ + ', but expected Instruction')
1687
1429
 
1688
- # Deserialize the instruction field.
1689
- field = cbor.get('instruction', None)
1430
+ # Deserialize the instruction_ref field.
1431
+ field = cbor.get('instruction_ref', None)
1690
1432
  if not isinstance(field, dict):
1691
- raise ValueError('missing or invalid serialization of field instruction')
1433
+ raise ValueError('missing or invalid serialization of field instruction_ref')
1692
1434
  if hasattr(cqasm.v3x.instruction.InstructionRef, 'deserialize_cbor'):
1693
- f_instruction = cqasm.v3x.instruction.InstructionRef.deserialize_cbor(field)
1435
+ f_instruction_ref = cqasm.v3x.instruction.InstructionRef.deserialize_cbor(field)
1694
1436
  else:
1695
- f_instruction = cqasm.v3x.primitives.deserialize(cqasm.v3x.instruction.InstructionRef, field)
1437
+ f_instruction_ref = cqasm.v3x.primitives.deserialize(cqasm.v3x.instruction.InstructionRef, field)
1696
1438
 
1697
1439
  # Deserialize the name field.
1698
1440
  field = cbor.get('name', None)
@@ -1712,22 +1454,11 @@ class Instruction(InstructionBase):
1712
1454
  data = field.get('@d', None)
1713
1455
  if not isinstance(data, list):
1714
1456
  raise ValueError('missing serialization of Any/Many contents')
1715
- f_operands = cqasm.v3x.values.MultiNode()
1457
+ f_operands = cqasm.v3x.values.MultiValueBase()
1716
1458
  for element in data:
1717
1459
  if element.get('@T') != '1':
1718
1460
  raise ValueError('unexpected edge type for Any/Many element')
1719
- f_operands.append(cqasm.v3x.values.Node._deserialize(element, seq_to_ob, links))
1720
-
1721
- # Deserialize the condition field.
1722
- field = cbor.get('condition', None)
1723
- if not isinstance(field, dict):
1724
- raise ValueError('missing or invalid serialization of field condition')
1725
- if field.get('@T') != '1':
1726
- raise ValueError('unexpected edge type for field condition')
1727
- if field.get('@t', None) is None:
1728
- f_condition = None
1729
- else:
1730
- f_condition = cqasm.v3x.values.Node._deserialize(field, seq_to_ob, links)
1461
+ f_operands.append(cqasm.v3x.values.ValueBase._deserialize(element, seq_to_ob, links))
1731
1462
 
1732
1463
  # Deserialize the annotations field.
1733
1464
  field = cbor.get('annotations', None)
@@ -1745,7 +1476,7 @@ class Instruction(InstructionBase):
1745
1476
  f_annotations.append(AnnotationData._deserialize(element, seq_to_ob, links))
1746
1477
 
1747
1478
  # Construct the Instruction node.
1748
- node = Instruction(f_instruction, f_name, f_operands, f_condition, f_annotations)
1479
+ node = Instruction(f_instruction_ref, f_name, f_operands, f_annotations)
1749
1480
 
1750
1481
  # Deserialize annotations.
1751
1482
  for key, val in cbor.items():
@@ -1771,11 +1502,11 @@ class Instruction(InstructionBase):
1771
1502
  integers, to use for the sequence number representation of links."""
1772
1503
  cbor = {'@i': id_map[id(self)], '@t': 'Instruction'}
1773
1504
 
1774
- # Serialize the instruction field.
1775
- if hasattr(self._attr_instruction, 'serialize_cbor'):
1776
- cbor['instruction'] = self._attr_instruction.serialize_cbor()
1505
+ # Serialize the instruction_ref field.
1506
+ if hasattr(self._attr_instruction_ref, 'serialize_cbor'):
1507
+ cbor['instruction_ref'] = self._attr_instruction_ref.serialize_cbor()
1777
1508
  else:
1778
- cbor['instruction'] = cqasm.v3x.primitives.serialize(cqasm.v3x.instruction.InstructionRef, self._attr_instruction)
1509
+ cbor['instruction_ref'] = cqasm.v3x.primitives.serialize(cqasm.v3x.instruction.InstructionRef, self._attr_instruction_ref)
1779
1510
 
1780
1511
  # Serialize the name field.
1781
1512
  if hasattr(self._attr_name, 'serialize_cbor'):
@@ -1793,14 +1524,6 @@ class Instruction(InstructionBase):
1793
1524
  field['@d'] = lst
1794
1525
  cbor['operands'] = field
1795
1526
 
1796
- # Serialize the condition field.
1797
- field = {'@T': '1'}
1798
- if self._attr_condition is None:
1799
- field['@t'] = None
1800
- else:
1801
- field.update(self._attr_condition._serialize(id_map))
1802
- cbor['condition'] = field
1803
-
1804
1527
  # Serialize the annotations field.
1805
1528
  field = {'@T': '*'}
1806
1529
  lst = []
@@ -1830,22 +1553,22 @@ class Program(Node):
1830
1553
  __slots__ = [
1831
1554
  '_attr_api_version',
1832
1555
  '_attr_version',
1833
- '_attr_statements',
1834
- '_attr_variables',
1556
+ '_attr_qubit_variable_declaration',
1557
+ '_attr_block',
1835
1558
  ]
1836
1559
 
1837
1560
  def __init__(
1838
1561
  self,
1839
1562
  api_version=None,
1840
1563
  version=None,
1841
- statements=None,
1842
- variables=None,
1564
+ qubit_variable_declaration=None,
1565
+ block=None,
1843
1566
  ):
1844
1567
  super().__init__()
1845
1568
  self.api_version = api_version
1846
1569
  self.version = version
1847
- self.statements = statements
1848
- self.variables = variables
1570
+ self.qubit_variable_declaration = qubit_variable_declaration
1571
+ self.block = block
1849
1572
 
1850
1573
  @property
1851
1574
  def api_version(self):
@@ -1892,46 +1615,46 @@ class Program(Node):
1892
1615
  self._attr_version = None
1893
1616
 
1894
1617
  @property
1895
- def statements(self):
1896
- """The list of statements."""
1897
- return self._attr_statements
1618
+ def qubit_variable_declaration(self):
1619
+ """Qubit variable."""
1620
+ return self._attr_qubit_variable_declaration
1898
1621
 
1899
- @statements.setter
1900
- def statements(self, val):
1622
+ @qubit_variable_declaration.setter
1623
+ def qubit_variable_declaration(self, val):
1901
1624
  if val is None:
1902
- del self.statements
1625
+ del self.qubit_variable_declaration
1903
1626
  return
1904
- if not isinstance(val, MultiStatement):
1627
+ if not isinstance(val, Variable):
1905
1628
  # Try to "typecast" if this isn't an obvious mistake.
1906
1629
  if isinstance(val, Node):
1907
- raise TypeError('statements must be of type MultiStatement')
1908
- val = MultiStatement(val)
1909
- self._attr_statements = val
1630
+ raise TypeError('qubit_variable_declaration must be of type Variable')
1631
+ val = Variable(val)
1632
+ self._attr_qubit_variable_declaration = val
1910
1633
 
1911
- @statements.deleter
1912
- def statements(self):
1913
- self._attr_statements = MultiStatement()
1634
+ @qubit_variable_declaration.deleter
1635
+ def qubit_variable_declaration(self):
1636
+ self._attr_qubit_variable_declaration = None
1914
1637
 
1915
1638
  @property
1916
- def variables(self):
1917
- """The list of variables."""
1918
- return self._attr_variables
1639
+ def block(self):
1640
+ """Global scope block."""
1641
+ return self._attr_block
1919
1642
 
1920
- @variables.setter
1921
- def variables(self, val):
1643
+ @block.setter
1644
+ def block(self, val):
1922
1645
  if val is None:
1923
- del self.variables
1646
+ del self.block
1924
1647
  return
1925
- if not isinstance(val, MultiVariable):
1648
+ if not isinstance(val, Block):
1926
1649
  # Try to "typecast" if this isn't an obvious mistake.
1927
1650
  if isinstance(val, Node):
1928
- raise TypeError('variables must be of type MultiVariable')
1929
- val = MultiVariable(val)
1930
- self._attr_variables = val
1651
+ raise TypeError('block must be of type Block')
1652
+ val = Block(val)
1653
+ self._attr_block = val
1931
1654
 
1932
- @variables.deleter
1933
- def variables(self):
1934
- self._attr_variables = MultiVariable()
1655
+ @block.deleter
1656
+ def block(self):
1657
+ self._attr_block = None
1935
1658
 
1936
1659
  def __eq__(self, other):
1937
1660
  """Equality operator. Ignores annotations!"""
@@ -1941,9 +1664,9 @@ class Program(Node):
1941
1664
  return False
1942
1665
  if self.version != other.version:
1943
1666
  return False
1944
- if self.statements != other.statements:
1667
+ if self.qubit_variable_declaration != other.qubit_variable_declaration:
1945
1668
  return False
1946
- if self.variables != other.variables:
1669
+ if self.block != other.block:
1947
1670
  return False
1948
1671
  return True
1949
1672
 
@@ -1974,23 +1697,21 @@ class Program(Node):
1974
1697
  s.append(self.version.dump(indent + 1, annotations, links) + '\n')
1975
1698
  s.append(' '*indent + '>\n')
1976
1699
  s.append(' '*indent)
1977
- s.append('statements: ')
1978
- if not self.statements:
1700
+ s.append('qubit_variable_declaration: ')
1701
+ if self.qubit_variable_declaration is None:
1979
1702
  s.append('-\n')
1980
1703
  else:
1981
- s.append('[\n')
1982
- for child in self.statements:
1983
- s.append(child.dump(indent + 1, annotations, links) + '\n')
1984
- s.append(' '*indent + ']\n')
1704
+ s.append('<\n')
1705
+ s.append(self.qubit_variable_declaration.dump(indent + 1, annotations, links) + '\n')
1706
+ s.append(' '*indent + '>\n')
1985
1707
  s.append(' '*indent)
1986
- s.append('variables: ')
1987
- if not self.variables:
1708
+ s.append('block: ')
1709
+ if self.block is None:
1988
1710
  s.append('-\n')
1989
1711
  else:
1990
- s.append('[\n')
1991
- for child in self.variables:
1992
- s.append(child.dump(indent + 1, annotations, links) + '\n')
1993
- s.append(' '*indent + ']\n')
1712
+ s.append('<\n')
1713
+ s.append(self.block.dump(indent + 1, annotations, links) + '\n')
1714
+ s.append(' '*indent + '>\n')
1994
1715
  indent -= 1
1995
1716
  s.append(' '*indent)
1996
1717
  s.append(')')
@@ -2010,10 +1731,10 @@ class Program(Node):
2010
1731
  id_map[id(self)] = len(id_map)
2011
1732
  if self._attr_version is not None:
2012
1733
  self._attr_version.find_reachable(id_map)
2013
- for el in self._attr_statements:
2014
- el.find_reachable(id_map)
2015
- for el in self._attr_variables:
2016
- el.find_reachable(id_map)
1734
+ if self._attr_qubit_variable_declaration is not None:
1735
+ self._attr_qubit_variable_declaration.find_reachable(id_map)
1736
+ if self._attr_block is not None:
1737
+ self._attr_block.find_reachable(id_map)
2017
1738
  return id_map
2018
1739
 
2019
1740
  def check_complete(self, id_map=None):
@@ -2027,18 +1748,18 @@ class Program(Node):
2027
1748
  raise NotWellFormed('version is required but not set')
2028
1749
  if self._attr_version is not None:
2029
1750
  self._attr_version.check_complete(id_map)
2030
- for child in self._attr_statements:
2031
- child.check_complete(id_map)
2032
- for child in self._attr_variables:
2033
- child.check_complete(id_map)
1751
+ if self._attr_qubit_variable_declaration is not None:
1752
+ self._attr_qubit_variable_declaration.check_complete(id_map)
1753
+ if self._attr_block is not None:
1754
+ self._attr_block.check_complete(id_map)
2034
1755
 
2035
1756
  def copy(self):
2036
1757
  """Returns a shallow copy of this node."""
2037
1758
  return Program(
2038
1759
  api_version=self._attr_api_version,
2039
1760
  version=self._attr_version,
2040
- statements=self._attr_statements.copy(),
2041
- variables=self._attr_variables.copy()
1761
+ qubit_variable_declaration=self._attr_qubit_variable_declaration,
1762
+ block=self._attr_block
2042
1763
  )
2043
1764
 
2044
1765
  def clone(self):
@@ -2050,8 +1771,8 @@ class Program(Node):
2050
1771
  return Program(
2051
1772
  api_version=_cloned(self._attr_api_version),
2052
1773
  version=_cloned(self._attr_version),
2053
- statements=_cloned(self._attr_statements),
2054
- variables=_cloned(self._attr_variables)
1774
+ qubit_variable_declaration=_cloned(self._attr_qubit_variable_declaration),
1775
+ block=_cloned(self._attr_block)
2055
1776
  )
2056
1777
 
2057
1778
  @staticmethod
@@ -2090,38 +1811,30 @@ class Program(Node):
2090
1811
  else:
2091
1812
  f_version = Version._deserialize(field, seq_to_ob, links)
2092
1813
 
2093
- # Deserialize the statements field.
2094
- field = cbor.get('statements', None)
1814
+ # Deserialize the qubit_variable_declaration field.
1815
+ field = cbor.get('qubit_variable_declaration', None)
2095
1816
  if not isinstance(field, dict):
2096
- raise ValueError('missing or invalid serialization of field statements')
2097
- if field.get('@T') != '*':
2098
- raise ValueError('unexpected edge type for field statements')
2099
- data = field.get('@d', None)
2100
- if not isinstance(data, list):
2101
- raise ValueError('missing serialization of Any/Many contents')
2102
- f_statements = MultiStatement()
2103
- for element in data:
2104
- if element.get('@T') != '1':
2105
- raise ValueError('unexpected edge type for Any/Many element')
2106
- f_statements.append(Statement._deserialize(element, seq_to_ob, links))
1817
+ raise ValueError('missing or invalid serialization of field qubit_variable_declaration')
1818
+ if field.get('@T') != '?':
1819
+ raise ValueError('unexpected edge type for field qubit_variable_declaration')
1820
+ if field.get('@t', None) is None:
1821
+ f_qubit_variable_declaration = None
1822
+ else:
1823
+ f_qubit_variable_declaration = Variable._deserialize(field, seq_to_ob, links)
2107
1824
 
2108
- # Deserialize the variables field.
2109
- field = cbor.get('variables', None)
1825
+ # Deserialize the block field.
1826
+ field = cbor.get('block', None)
2110
1827
  if not isinstance(field, dict):
2111
- raise ValueError('missing or invalid serialization of field variables')
2112
- if field.get('@T') != '*':
2113
- raise ValueError('unexpected edge type for field variables')
2114
- data = field.get('@d', None)
2115
- if not isinstance(data, list):
2116
- raise ValueError('missing serialization of Any/Many contents')
2117
- f_variables = MultiVariable()
2118
- for element in data:
2119
- if element.get('@T') != '1':
2120
- raise ValueError('unexpected edge type for Any/Many element')
2121
- f_variables.append(Variable._deserialize(element, seq_to_ob, links))
1828
+ raise ValueError('missing or invalid serialization of field block')
1829
+ if field.get('@T') != '?':
1830
+ raise ValueError('unexpected edge type for field block')
1831
+ if field.get('@t', None) is None:
1832
+ f_block = None
1833
+ else:
1834
+ f_block = Block._deserialize(field, seq_to_ob, links)
2122
1835
 
2123
1836
  # Construct the Program node.
2124
- node = Program(f_api_version, f_version, f_statements, f_variables)
1837
+ node = Program(f_api_version, f_version, f_qubit_variable_declaration, f_block)
2125
1838
 
2126
1839
  # Deserialize annotations.
2127
1840
  for key, val in cbor.items():
@@ -2161,25 +1874,21 @@ class Program(Node):
2161
1874
  field.update(self._attr_version._serialize(id_map))
2162
1875
  cbor['version'] = field
2163
1876
 
2164
- # Serialize the statements field.
2165
- field = {'@T': '*'}
2166
- lst = []
2167
- for el in self._attr_statements:
2168
- el = el._serialize(id_map)
2169
- el['@T'] = '1'
2170
- lst.append(el)
2171
- field['@d'] = lst
2172
- cbor['statements'] = field
1877
+ # Serialize the qubit_variable_declaration field.
1878
+ field = {'@T': '?'}
1879
+ if self._attr_qubit_variable_declaration is None:
1880
+ field['@t'] = None
1881
+ else:
1882
+ field.update(self._attr_qubit_variable_declaration._serialize(id_map))
1883
+ cbor['qubit_variable_declaration'] = field
2173
1884
 
2174
- # Serialize the variables field.
2175
- field = {'@T': '*'}
2176
- lst = []
2177
- for el in self._attr_variables:
2178
- el = el._serialize(id_map)
2179
- el['@T'] = '1'
2180
- lst.append(el)
2181
- field['@d'] = lst
2182
- cbor['variables'] = field
1885
+ # Serialize the block field.
1886
+ field = {'@T': '?'}
1887
+ if self._attr_block is None:
1888
+ field['@t'] = None
1889
+ else:
1890
+ field.update(self._attr_block._serialize(id_map))
1891
+ cbor['block'] = field
2183
1892
 
2184
1893
  # Serialize annotations.
2185
1894
  for key, val in self._annot.items():
@@ -2241,11 +1950,11 @@ class Variable(Annotated):
2241
1950
  if val is None:
2242
1951
  del self.typ
2243
1952
  return
2244
- if not isinstance(val, cqasm.v3x.types.Node):
1953
+ if not isinstance(val, cqasm.v3x.types.TypeBase):
2245
1954
  # Try to "typecast" if this isn't an obvious mistake.
2246
1955
  if isinstance(val, Node):
2247
- raise TypeError('typ must be of type cqasm.v3x.types.Node')
2248
- val = cqasm.v3x.types.Node(val)
1956
+ raise TypeError('typ must be of type cqasm.v3x.types.TypeBase')
1957
+ val = cqasm.v3x.types.TypeBase(val)
2249
1958
  self._attr_typ = val
2250
1959
 
2251
1960
  @typ.deleter
@@ -2390,7 +2099,7 @@ class Variable(Annotated):
2390
2099
  if field.get('@t', None) is None:
2391
2100
  f_typ = None
2392
2101
  else:
2393
- f_typ = cqasm.v3x.types.Node._deserialize(field, seq_to_ob, links)
2102
+ f_typ = cqasm.v3x.types.TypeBase._deserialize(field, seq_to_ob, links)
2394
2103
 
2395
2104
  # Deserialize the annotations field.
2396
2105
  field = cbor.get('annotations', None)