libqasm 0.6.4__cp311-cp311-macosx_10_10_universal2.whl → 0.6.6__cp311-cp311-macosx_10_10_universal2.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/__init__.py +6 -6
- cqasm/v3x/ast.py +139 -197
- cqasm/v3x/semantic.py +74 -65
- cqasm/v3x/types.py +306 -0
- {libQasm → libqasm}/__init__.py +1 -1
- libqasm/_libqasm.cpython-311-darwin.so +0 -0
- libqasm/libqasm.py +1082 -0
- {libqasm-0.6.4.dist-info → libqasm-0.6.6.dist-info}/METADATA +61 -27
- libqasm-0.6.6.dist-info/RECORD +16 -0
- libqasm-0.6.6.dist-info/top_level.txt +2 -0
- libQasm/_libQasm.cpython-311-darwin.so +0 -0
- libQasm/libQasm.py +0 -1082
- libqasm-0.6.4.dist-info/RECORD +0 -16
- libqasm-0.6.4.dist-info/top_level.txt +0 -2
- {libqasm-0.6.4.dist-info → libqasm-0.6.6.dist-info}/LICENSE.md +0 -0
- {libqasm-0.6.4.dist-info → libqasm-0.6.6.dist-info}/WHEEL +0 -0
cqasm/v3x/__init__.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import cqasm.v3x.ast as ast
|
2
2
|
import cqasm.v3x.semantic as semantic
|
3
|
-
import
|
3
|
+
import libqasm
|
4
4
|
|
5
5
|
|
6
|
-
class Analyzer(
|
6
|
+
class Analyzer(libqasm.V3xAnalyzer):
|
7
7
|
# parse_file and parse_string are static methods because they do not change the status of the analyzer
|
8
8
|
# Instead, they just invoke free functions that create a temporary instance of a parser
|
9
9
|
# analyze_file and analyze_string are not static methods because they change the status of the analyzer
|
@@ -14,7 +14,7 @@ class Analyzer(libQasm.V3xAnalyzer):
|
|
14
14
|
|
15
15
|
@staticmethod
|
16
16
|
def parse_file(*args):
|
17
|
-
ret =
|
17
|
+
ret = libqasm.V3xAnalyzer.parse_file(*args)
|
18
18
|
if len(ret) == 1:
|
19
19
|
serialized_ast_str = str(ret[0])
|
20
20
|
serialized_ast_bytes = serialized_ast_str.encode(encoding='utf-8', errors="surrogateescape")
|
@@ -24,7 +24,7 @@ class Analyzer(libQasm.V3xAnalyzer):
|
|
24
24
|
|
25
25
|
@staticmethod
|
26
26
|
def parse_string(*args):
|
27
|
-
ret =
|
27
|
+
ret = libqasm.V3xAnalyzer.parse_string(*args)
|
28
28
|
if len(ret) == 1:
|
29
29
|
serialized_ast_str = str(ret[0])
|
30
30
|
serialized_ast_bytes = serialized_ast_str.encode(encoding='utf-8', errors="surrogateescape")
|
@@ -52,11 +52,11 @@ class Analyzer(libQasm.V3xAnalyzer):
|
|
52
52
|
|
53
53
|
@staticmethod
|
54
54
|
def parse_file_to_json(*args):
|
55
|
-
return
|
55
|
+
return libqasm.V3xAnalyzer.parse_file_to_json(*args)
|
56
56
|
|
57
57
|
@staticmethod
|
58
58
|
def parse_string_to_json(*args):
|
59
|
-
return
|
59
|
+
return libqasm.V3xAnalyzer.parse_string_to_json(*args)
|
60
60
|
|
61
61
|
def analyze_file_to_json(self, *args):
|
62
62
|
return super().analyze_file_to_json(*args)
|
cqasm/v3x/ast.py
CHANGED
@@ -5331,91 +5331,41 @@ _typemap['Gate'] = Gate
|
|
5331
5331
|
|
5332
5332
|
class GlobalBlock(Block):
|
5333
5333
|
__slots__ = [
|
5334
|
-
'
|
5335
|
-
'_attr_gates',
|
5336
|
-
'_attr_measure_instructions',
|
5334
|
+
'_attr_statements',
|
5337
5335
|
]
|
5338
5336
|
|
5339
5337
|
def __init__(
|
5340
5338
|
self,
|
5341
|
-
|
5342
|
-
gates=None,
|
5343
|
-
measure_instructions=None,
|
5339
|
+
statements=None,
|
5344
5340
|
):
|
5345
5341
|
super().__init__()
|
5346
|
-
self.
|
5347
|
-
self.gates = gates
|
5348
|
-
self.measure_instructions = measure_instructions
|
5342
|
+
self.statements = statements
|
5349
5343
|
|
5350
5344
|
@property
|
5351
|
-
def
|
5352
|
-
return self.
|
5345
|
+
def statements(self):
|
5346
|
+
return self._attr_statements
|
5353
5347
|
|
5354
|
-
@
|
5355
|
-
def
|
5348
|
+
@statements.setter
|
5349
|
+
def statements(self, val):
|
5356
5350
|
if val is None:
|
5357
|
-
del self.
|
5351
|
+
del self.statements
|
5358
5352
|
return
|
5359
|
-
if not isinstance(val,
|
5353
|
+
if not isinstance(val, MultiStatement):
|
5360
5354
|
# Try to "typecast" if this isn't an obvious mistake.
|
5361
5355
|
if isinstance(val, Node):
|
5362
|
-
raise TypeError('
|
5363
|
-
val =
|
5364
|
-
self.
|
5356
|
+
raise TypeError('statements must be of type MultiStatement')
|
5357
|
+
val = MultiStatement(val)
|
5358
|
+
self._attr_statements = val
|
5365
5359
|
|
5366
|
-
@
|
5367
|
-
def
|
5368
|
-
self.
|
5369
|
-
|
5370
|
-
@property
|
5371
|
-
def gates(self):
|
5372
|
-
return self._attr_gates
|
5373
|
-
|
5374
|
-
@gates.setter
|
5375
|
-
def gates(self, val):
|
5376
|
-
if val is None:
|
5377
|
-
del self.gates
|
5378
|
-
return
|
5379
|
-
if not isinstance(val, MultiGate):
|
5380
|
-
# Try to "typecast" if this isn't an obvious mistake.
|
5381
|
-
if isinstance(val, Node):
|
5382
|
-
raise TypeError('gates must be of type MultiGate')
|
5383
|
-
val = MultiGate(val)
|
5384
|
-
self._attr_gates = val
|
5385
|
-
|
5386
|
-
@gates.deleter
|
5387
|
-
def gates(self):
|
5388
|
-
self._attr_gates = MultiGate()
|
5389
|
-
|
5390
|
-
@property
|
5391
|
-
def measure_instructions(self):
|
5392
|
-
return self._attr_measure_instructions
|
5393
|
-
|
5394
|
-
@measure_instructions.setter
|
5395
|
-
def measure_instructions(self, val):
|
5396
|
-
if val is None:
|
5397
|
-
del self.measure_instructions
|
5398
|
-
return
|
5399
|
-
if not isinstance(val, MultiMeasureInstruction):
|
5400
|
-
# Try to "typecast" if this isn't an obvious mistake.
|
5401
|
-
if isinstance(val, Node):
|
5402
|
-
raise TypeError('measure_instructions must be of type MultiMeasureInstruction')
|
5403
|
-
val = MultiMeasureInstruction(val)
|
5404
|
-
self._attr_measure_instructions = val
|
5405
|
-
|
5406
|
-
@measure_instructions.deleter
|
5407
|
-
def measure_instructions(self):
|
5408
|
-
self._attr_measure_instructions = MultiMeasureInstruction()
|
5360
|
+
@statements.deleter
|
5361
|
+
def statements(self):
|
5362
|
+
self._attr_statements = MultiStatement()
|
5409
5363
|
|
5410
5364
|
def __eq__(self, other):
|
5411
5365
|
"""Equality operator. Ignores annotations!"""
|
5412
5366
|
if not isinstance(other, GlobalBlock):
|
5413
5367
|
return False
|
5414
|
-
if self.
|
5415
|
-
return False
|
5416
|
-
if self.gates != other.gates:
|
5417
|
-
return False
|
5418
|
-
if self.measure_instructions != other.measure_instructions:
|
5368
|
+
if self.statements != other.statements:
|
5419
5369
|
return False
|
5420
5370
|
return True
|
5421
5371
|
|
@@ -5435,29 +5385,12 @@ class GlobalBlock(Block):
|
|
5435
5385
|
s.append('\n')
|
5436
5386
|
indent += 1
|
5437
5387
|
s.append(' '*indent)
|
5438
|
-
s.append('
|
5439
|
-
if self.
|
5440
|
-
s.append('!MISSING\n')
|
5441
|
-
else:
|
5442
|
-
s.append('<\n')
|
5443
|
-
s.append(self.qubit_variable_declaration.dump(indent + 1, annotations, links) + '\n')
|
5444
|
-
s.append(' '*indent + '>\n')
|
5445
|
-
s.append(' '*indent)
|
5446
|
-
s.append('gates: ')
|
5447
|
-
if not self.gates:
|
5448
|
-
s.append('-\n')
|
5449
|
-
else:
|
5450
|
-
s.append('[\n')
|
5451
|
-
for child in self.gates:
|
5452
|
-
s.append(child.dump(indent + 1, annotations, links) + '\n')
|
5453
|
-
s.append(' '*indent + ']\n')
|
5454
|
-
s.append(' '*indent)
|
5455
|
-
s.append('measure_instructions: ')
|
5456
|
-
if not self.measure_instructions:
|
5388
|
+
s.append('statements: ')
|
5389
|
+
if not self.statements:
|
5457
5390
|
s.append('-\n')
|
5458
5391
|
else:
|
5459
5392
|
s.append('[\n')
|
5460
|
-
for child in self.
|
5393
|
+
for child in self.statements:
|
5461
5394
|
s.append(child.dump(indent + 1, annotations, links) + '\n')
|
5462
5395
|
s.append(' '*indent + ']\n')
|
5463
5396
|
indent -= 1
|
@@ -5477,11 +5410,7 @@ class GlobalBlock(Block):
|
|
5477
5410
|
if id(self) in id_map:
|
5478
5411
|
raise NotWellFormed('node {!r} with id {} occurs more than once'.format(self, id(self)))
|
5479
5412
|
id_map[id(self)] = len(id_map)
|
5480
|
-
|
5481
|
-
self._attr_qubit_variable_declaration.find_reachable(id_map)
|
5482
|
-
for el in self._attr_gates:
|
5483
|
-
el.find_reachable(id_map)
|
5484
|
-
for el in self._attr_measure_instructions:
|
5413
|
+
for el in self._attr_statements:
|
5485
5414
|
el.find_reachable(id_map)
|
5486
5415
|
return id_map
|
5487
5416
|
|
@@ -5492,21 +5421,13 @@ class GlobalBlock(Block):
|
|
5492
5421
|
id() codes to tree indices for all reachable nodes."""
|
5493
5422
|
if id_map is None:
|
5494
5423
|
id_map = self.find_reachable()
|
5495
|
-
|
5496
|
-
raise NotWellFormed('qubit_variable_declaration is required but not set')
|
5497
|
-
if self._attr_qubit_variable_declaration is not None:
|
5498
|
-
self._attr_qubit_variable_declaration.check_complete(id_map)
|
5499
|
-
for child in self._attr_gates:
|
5500
|
-
child.check_complete(id_map)
|
5501
|
-
for child in self._attr_measure_instructions:
|
5424
|
+
for child in self._attr_statements:
|
5502
5425
|
child.check_complete(id_map)
|
5503
5426
|
|
5504
5427
|
def copy(self):
|
5505
5428
|
"""Returns a shallow copy of this node."""
|
5506
5429
|
return GlobalBlock(
|
5507
|
-
|
5508
|
-
gates=self._attr_gates.copy(),
|
5509
|
-
measure_instructions=self._attr_measure_instructions.copy()
|
5430
|
+
statements=self._attr_statements.copy()
|
5510
5431
|
)
|
5511
5432
|
|
5512
5433
|
def clone(self):
|
@@ -5516,9 +5437,7 @@ class GlobalBlock(Block):
|
|
5516
5437
|
is the desired behavior, you may want to use the copy.deepcopy() from
|
5517
5438
|
the stdlib instead, which should copy links correctly."""
|
5518
5439
|
return GlobalBlock(
|
5519
|
-
|
5520
|
-
gates=_cloned(self._attr_gates),
|
5521
|
-
measure_instructions=_cloned(self._attr_measure_instructions)
|
5440
|
+
statements=_cloned(self._attr_statements)
|
5522
5441
|
)
|
5523
5442
|
|
5524
5443
|
@staticmethod
|
@@ -5537,49 +5456,23 @@ class GlobalBlock(Block):
|
|
5537
5456
|
if typ != 'GlobalBlock':
|
5538
5457
|
raise ValueError('found node serialization for ' + typ + ', but expected GlobalBlock')
|
5539
5458
|
|
5540
|
-
# Deserialize the
|
5541
|
-
field = cbor.get('
|
5542
|
-
if not isinstance(field, dict):
|
5543
|
-
raise ValueError('missing or invalid serialization of field qubit_variable_declaration')
|
5544
|
-
if field.get('@T') != '1':
|
5545
|
-
raise ValueError('unexpected edge type for field qubit_variable_declaration')
|
5546
|
-
if field.get('@t', None) is None:
|
5547
|
-
f_qubit_variable_declaration = None
|
5548
|
-
else:
|
5549
|
-
f_qubit_variable_declaration = Variable._deserialize(field, seq_to_ob, links)
|
5550
|
-
|
5551
|
-
# Deserialize the gates field.
|
5552
|
-
field = cbor.get('gates', None)
|
5459
|
+
# Deserialize the statements field.
|
5460
|
+
field = cbor.get('statements', None)
|
5553
5461
|
if not isinstance(field, dict):
|
5554
|
-
raise ValueError('missing or invalid serialization of field
|
5462
|
+
raise ValueError('missing or invalid serialization of field statements')
|
5555
5463
|
if field.get('@T') != '*':
|
5556
|
-
raise ValueError('unexpected edge type for field
|
5464
|
+
raise ValueError('unexpected edge type for field statements')
|
5557
5465
|
data = field.get('@d', None)
|
5558
5466
|
if not isinstance(data, list):
|
5559
5467
|
raise ValueError('missing serialization of Any/Many contents')
|
5560
|
-
|
5468
|
+
f_statements = MultiStatement()
|
5561
5469
|
for element in data:
|
5562
5470
|
if element.get('@T') != '1':
|
5563
5471
|
raise ValueError('unexpected edge type for Any/Many element')
|
5564
|
-
|
5565
|
-
|
5566
|
-
# Deserialize the measure_instructions field.
|
5567
|
-
field = cbor.get('measure_instructions', None)
|
5568
|
-
if not isinstance(field, dict):
|
5569
|
-
raise ValueError('missing or invalid serialization of field measure_instructions')
|
5570
|
-
if field.get('@T') != '*':
|
5571
|
-
raise ValueError('unexpected edge type for field measure_instructions')
|
5572
|
-
data = field.get('@d', None)
|
5573
|
-
if not isinstance(data, list):
|
5574
|
-
raise ValueError('missing serialization of Any/Many contents')
|
5575
|
-
f_measure_instructions = MultiMeasureInstruction()
|
5576
|
-
for element in data:
|
5577
|
-
if element.get('@T') != '1':
|
5578
|
-
raise ValueError('unexpected edge type for Any/Many element')
|
5579
|
-
f_measure_instructions.append(MeasureInstruction._deserialize(element, seq_to_ob, links))
|
5472
|
+
f_statements.append(Statement._deserialize(element, seq_to_ob, links))
|
5580
5473
|
|
5581
5474
|
# Construct the GlobalBlock node.
|
5582
|
-
node = GlobalBlock(
|
5475
|
+
node = GlobalBlock(f_statements)
|
5583
5476
|
|
5584
5477
|
# Deserialize annotations.
|
5585
5478
|
for key, val in cbor.items():
|
@@ -5605,33 +5498,15 @@ class GlobalBlock(Block):
|
|
5605
5498
|
integers, to use for the sequence number representation of links."""
|
5606
5499
|
cbor = {'@i': id_map[id(self)], '@t': 'GlobalBlock'}
|
5607
5500
|
|
5608
|
-
# Serialize the
|
5609
|
-
field = {'@T': '1'}
|
5610
|
-
if self._attr_qubit_variable_declaration is None:
|
5611
|
-
field['@t'] = None
|
5612
|
-
else:
|
5613
|
-
field.update(self._attr_qubit_variable_declaration._serialize(id_map))
|
5614
|
-
cbor['qubit_variable_declaration'] = field
|
5615
|
-
|
5616
|
-
# Serialize the gates field.
|
5617
|
-
field = {'@T': '*'}
|
5618
|
-
lst = []
|
5619
|
-
for el in self._attr_gates:
|
5620
|
-
el = el._serialize(id_map)
|
5621
|
-
el['@T'] = '1'
|
5622
|
-
lst.append(el)
|
5623
|
-
field['@d'] = lst
|
5624
|
-
cbor['gates'] = field
|
5625
|
-
|
5626
|
-
# Serialize the measure_instructions field.
|
5501
|
+
# Serialize the statements field.
|
5627
5502
|
field = {'@T': '*'}
|
5628
5503
|
lst = []
|
5629
|
-
for el in self.
|
5504
|
+
for el in self._attr_statements:
|
5630
5505
|
el = el._serialize(id_map)
|
5631
5506
|
el['@T'] = '1'
|
5632
5507
|
lst.append(el)
|
5633
5508
|
field['@d'] = lst
|
5634
|
-
cbor['
|
5509
|
+
cbor['statements'] = field
|
5635
5510
|
|
5636
5511
|
# Serialize annotations.
|
5637
5512
|
for key, val in self._annot.items():
|
@@ -7952,20 +7827,28 @@ class MultiLogicalXorExpression(_Multiple):
|
|
7952
7827
|
_typemap['LogicalXorExpression'] = LogicalXorExpression
|
7953
7828
|
|
7954
7829
|
class MeasureInstruction(Instruction):
|
7830
|
+
"""For some instructions, like the measure instruction, we want to
|
7831
|
+
differentiate between left hand side and right and side operands. For a
|
7832
|
+
measure instruction, the right hand side operand should be a qubit, and the
|
7833
|
+
left hand side operand a bit."""
|
7834
|
+
|
7955
7835
|
__slots__ = [
|
7956
7836
|
'_attr_name',
|
7957
|
-
'
|
7837
|
+
'_attr_lhs',
|
7838
|
+
'_attr_rhs',
|
7958
7839
|
]
|
7959
7840
|
|
7960
7841
|
def __init__(
|
7961
7842
|
self,
|
7962
7843
|
name=None,
|
7963
|
-
|
7844
|
+
lhs=None,
|
7845
|
+
rhs=None,
|
7964
7846
|
annotations=None,
|
7965
7847
|
):
|
7966
7848
|
super().__init__(annotations=annotations)
|
7967
7849
|
self.name = name
|
7968
|
-
self.
|
7850
|
+
self.lhs = lhs
|
7851
|
+
self.rhs = rhs
|
7969
7852
|
|
7970
7853
|
@property
|
7971
7854
|
def name(self):
|
@@ -7988,24 +7871,44 @@ class MeasureInstruction(Instruction):
|
|
7988
7871
|
self._attr_name = None
|
7989
7872
|
|
7990
7873
|
@property
|
7991
|
-
def
|
7992
|
-
return self.
|
7874
|
+
def lhs(self):
|
7875
|
+
return self._attr_lhs
|
7993
7876
|
|
7994
|
-
@
|
7995
|
-
def
|
7877
|
+
@lhs.setter
|
7878
|
+
def lhs(self, val):
|
7996
7879
|
if val is None:
|
7997
|
-
del self.
|
7880
|
+
del self.lhs
|
7998
7881
|
return
|
7999
7882
|
if not isinstance(val, Expression):
|
8000
7883
|
# Try to "typecast" if this isn't an obvious mistake.
|
8001
7884
|
if isinstance(val, Node):
|
8002
|
-
raise TypeError('
|
7885
|
+
raise TypeError('lhs must be of type Expression')
|
8003
7886
|
val = Expression(val)
|
8004
|
-
self.
|
7887
|
+
self._attr_lhs = val
|
8005
7888
|
|
8006
|
-
@
|
8007
|
-
def
|
8008
|
-
self.
|
7889
|
+
@lhs.deleter
|
7890
|
+
def lhs(self):
|
7891
|
+
self._attr_lhs = None
|
7892
|
+
|
7893
|
+
@property
|
7894
|
+
def rhs(self):
|
7895
|
+
return self._attr_rhs
|
7896
|
+
|
7897
|
+
@rhs.setter
|
7898
|
+
def rhs(self, val):
|
7899
|
+
if val is None:
|
7900
|
+
del self.rhs
|
7901
|
+
return
|
7902
|
+
if not isinstance(val, Expression):
|
7903
|
+
# Try to "typecast" if this isn't an obvious mistake.
|
7904
|
+
if isinstance(val, Node):
|
7905
|
+
raise TypeError('rhs must be of type Expression')
|
7906
|
+
val = Expression(val)
|
7907
|
+
self._attr_rhs = val
|
7908
|
+
|
7909
|
+
@rhs.deleter
|
7910
|
+
def rhs(self):
|
7911
|
+
self._attr_rhs = None
|
8009
7912
|
|
8010
7913
|
def __eq__(self, other):
|
8011
7914
|
"""Equality operator. Ignores annotations!"""
|
@@ -8013,7 +7916,9 @@ class MeasureInstruction(Instruction):
|
|
8013
7916
|
return False
|
8014
7917
|
if self.name != other.name:
|
8015
7918
|
return False
|
8016
|
-
if self.
|
7919
|
+
if self.lhs != other.lhs:
|
7920
|
+
return False
|
7921
|
+
if self.rhs != other.rhs:
|
8017
7922
|
return False
|
8018
7923
|
if self.annotations != other.annotations:
|
8019
7924
|
return False
|
@@ -8043,12 +7948,20 @@ class MeasureInstruction(Instruction):
|
|
8043
7948
|
s.append(self.name.dump(indent + 1, annotations, links) + '\n')
|
8044
7949
|
s.append(' '*indent + '>\n')
|
8045
7950
|
s.append(' '*indent)
|
8046
|
-
s.append('
|
8047
|
-
if self.
|
7951
|
+
s.append('lhs: ')
|
7952
|
+
if self.lhs is None:
|
8048
7953
|
s.append('!MISSING\n')
|
8049
7954
|
else:
|
8050
7955
|
s.append('<\n')
|
8051
|
-
s.append(self.
|
7956
|
+
s.append(self.lhs.dump(indent + 1, annotations, links) + '\n')
|
7957
|
+
s.append(' '*indent + '>\n')
|
7958
|
+
s.append(' '*indent)
|
7959
|
+
s.append('rhs: ')
|
7960
|
+
if self.rhs is None:
|
7961
|
+
s.append('!MISSING\n')
|
7962
|
+
else:
|
7963
|
+
s.append('<\n')
|
7964
|
+
s.append(self.rhs.dump(indent + 1, annotations, links) + '\n')
|
8052
7965
|
s.append(' '*indent + '>\n')
|
8053
7966
|
s.append(' '*indent)
|
8054
7967
|
s.append('annotations: ')
|
@@ -8078,8 +7991,10 @@ class MeasureInstruction(Instruction):
|
|
8078
7991
|
id_map[id(self)] = len(id_map)
|
8079
7992
|
if self._attr_name is not None:
|
8080
7993
|
self._attr_name.find_reachable(id_map)
|
8081
|
-
if self.
|
8082
|
-
self.
|
7994
|
+
if self._attr_lhs is not None:
|
7995
|
+
self._attr_lhs.find_reachable(id_map)
|
7996
|
+
if self._attr_rhs is not None:
|
7997
|
+
self._attr_rhs.find_reachable(id_map)
|
8083
7998
|
for el in self._attr_annotations:
|
8084
7999
|
el.find_reachable(id_map)
|
8085
8000
|
return id_map
|
@@ -8095,10 +8010,14 @@ class MeasureInstruction(Instruction):
|
|
8095
8010
|
raise NotWellFormed('name is required but not set')
|
8096
8011
|
if self._attr_name is not None:
|
8097
8012
|
self._attr_name.check_complete(id_map)
|
8098
|
-
if self.
|
8099
|
-
raise NotWellFormed('
|
8100
|
-
if self.
|
8101
|
-
self.
|
8013
|
+
if self._attr_lhs is None:
|
8014
|
+
raise NotWellFormed('lhs is required but not set')
|
8015
|
+
if self._attr_lhs is not None:
|
8016
|
+
self._attr_lhs.check_complete(id_map)
|
8017
|
+
if self._attr_rhs is None:
|
8018
|
+
raise NotWellFormed('rhs is required but not set')
|
8019
|
+
if self._attr_rhs is not None:
|
8020
|
+
self._attr_rhs.check_complete(id_map)
|
8102
8021
|
for child in self._attr_annotations:
|
8103
8022
|
child.check_complete(id_map)
|
8104
8023
|
|
@@ -8106,7 +8025,8 @@ class MeasureInstruction(Instruction):
|
|
8106
8025
|
"""Returns a shallow copy of this node."""
|
8107
8026
|
return MeasureInstruction(
|
8108
8027
|
name=self._attr_name,
|
8109
|
-
|
8028
|
+
lhs=self._attr_lhs,
|
8029
|
+
rhs=self._attr_rhs,
|
8110
8030
|
annotations=self._attr_annotations.copy()
|
8111
8031
|
)
|
8112
8032
|
|
@@ -8118,7 +8038,8 @@ class MeasureInstruction(Instruction):
|
|
8118
8038
|
the stdlib instead, which should copy links correctly."""
|
8119
8039
|
return MeasureInstruction(
|
8120
8040
|
name=_cloned(self._attr_name),
|
8121
|
-
|
8041
|
+
lhs=_cloned(self._attr_lhs),
|
8042
|
+
rhs=_cloned(self._attr_rhs),
|
8122
8043
|
annotations=_cloned(self._attr_annotations)
|
8123
8044
|
)
|
8124
8045
|
|
@@ -8149,16 +8070,27 @@ class MeasureInstruction(Instruction):
|
|
8149
8070
|
else:
|
8150
8071
|
f_name = Identifier._deserialize(field, seq_to_ob, links)
|
8151
8072
|
|
8152
|
-
# Deserialize the
|
8153
|
-
field = cbor.get('
|
8073
|
+
# Deserialize the lhs field.
|
8074
|
+
field = cbor.get('lhs', None)
|
8075
|
+
if not isinstance(field, dict):
|
8076
|
+
raise ValueError('missing or invalid serialization of field lhs')
|
8077
|
+
if field.get('@T') != '1':
|
8078
|
+
raise ValueError('unexpected edge type for field lhs')
|
8079
|
+
if field.get('@t', None) is None:
|
8080
|
+
f_lhs = None
|
8081
|
+
else:
|
8082
|
+
f_lhs = Expression._deserialize(field, seq_to_ob, links)
|
8083
|
+
|
8084
|
+
# Deserialize the rhs field.
|
8085
|
+
field = cbor.get('rhs', None)
|
8154
8086
|
if not isinstance(field, dict):
|
8155
|
-
raise ValueError('missing or invalid serialization of field
|
8087
|
+
raise ValueError('missing or invalid serialization of field rhs')
|
8156
8088
|
if field.get('@T') != '1':
|
8157
|
-
raise ValueError('unexpected edge type for field
|
8089
|
+
raise ValueError('unexpected edge type for field rhs')
|
8158
8090
|
if field.get('@t', None) is None:
|
8159
|
-
|
8091
|
+
f_rhs = None
|
8160
8092
|
else:
|
8161
|
-
|
8093
|
+
f_rhs = Expression._deserialize(field, seq_to_ob, links)
|
8162
8094
|
|
8163
8095
|
# Deserialize the annotations field.
|
8164
8096
|
field = cbor.get('annotations', None)
|
@@ -8176,7 +8108,7 @@ class MeasureInstruction(Instruction):
|
|
8176
8108
|
f_annotations.append(AnnotationData._deserialize(element, seq_to_ob, links))
|
8177
8109
|
|
8178
8110
|
# Construct the MeasureInstruction node.
|
8179
|
-
node = MeasureInstruction(f_name,
|
8111
|
+
node = MeasureInstruction(f_name, f_lhs, f_rhs, f_annotations)
|
8180
8112
|
|
8181
8113
|
# Deserialize annotations.
|
8182
8114
|
for key, val in cbor.items():
|
@@ -8210,13 +8142,21 @@ class MeasureInstruction(Instruction):
|
|
8210
8142
|
field.update(self._attr_name._serialize(id_map))
|
8211
8143
|
cbor['name'] = field
|
8212
8144
|
|
8213
|
-
# Serialize the
|
8145
|
+
# Serialize the lhs field.
|
8214
8146
|
field = {'@T': '1'}
|
8215
|
-
if self.
|
8147
|
+
if self._attr_lhs is None:
|
8216
8148
|
field['@t'] = None
|
8217
8149
|
else:
|
8218
|
-
field.update(self.
|
8219
|
-
cbor['
|
8150
|
+
field.update(self._attr_lhs._serialize(id_map))
|
8151
|
+
cbor['lhs'] = field
|
8152
|
+
|
8153
|
+
# Serialize the rhs field.
|
8154
|
+
field = {'@T': '1'}
|
8155
|
+
if self._attr_rhs is None:
|
8156
|
+
field['@t'] = None
|
8157
|
+
else:
|
8158
|
+
field.update(self._attr_rhs._serialize(id_map))
|
8159
|
+
cbor['rhs'] = field
|
8220
8160
|
|
8221
8161
|
# Serialize the annotations field.
|
8222
8162
|
field = {'@T': '*'}
|
@@ -8991,7 +8931,7 @@ class Program(Root):
|
|
8991
8931
|
s.append(' '*indent)
|
8992
8932
|
s.append('block: ')
|
8993
8933
|
if self.block is None:
|
8994
|
-
s.append('
|
8934
|
+
s.append('!MISSING\n')
|
8995
8935
|
else:
|
8996
8936
|
s.append('<\n')
|
8997
8937
|
s.append(self.block.dump(indent + 1, annotations, links) + '\n')
|
@@ -9030,6 +8970,8 @@ class Program(Root):
|
|
9030
8970
|
raise NotWellFormed('version is required but not set')
|
9031
8971
|
if self._attr_version is not None:
|
9032
8972
|
self._attr_version.check_complete(id_map)
|
8973
|
+
if self._attr_block is None:
|
8974
|
+
raise NotWellFormed('block is required but not set')
|
9033
8975
|
if self._attr_block is not None:
|
9034
8976
|
self._attr_block.check_complete(id_map)
|
9035
8977
|
|
@@ -9082,7 +9024,7 @@ class Program(Root):
|
|
9082
9024
|
field = cbor.get('block', None)
|
9083
9025
|
if not isinstance(field, dict):
|
9084
9026
|
raise ValueError('missing or invalid serialization of field block')
|
9085
|
-
if field.get('@T') != '
|
9027
|
+
if field.get('@T') != '1':
|
9086
9028
|
raise ValueError('unexpected edge type for field block')
|
9087
9029
|
if field.get('@t', None) is None:
|
9088
9030
|
f_block = None
|
@@ -9125,7 +9067,7 @@ class Program(Root):
|
|
9125
9067
|
cbor['version'] = field
|
9126
9068
|
|
9127
9069
|
# Serialize the block field.
|
9128
|
-
field = {'@T': '
|
9070
|
+
field = {'@T': '1'}
|
9129
9071
|
if self._attr_block is None:
|
9130
9072
|
field['@t'] = None
|
9131
9073
|
else:
|