python-cc 0.0.7__py3-none-any.whl → 0.0.8__py3-none-any.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.
pcc/ast/ast.py CHANGED
@@ -140,7 +140,8 @@ class PrototypeAST(ASTNode):
140
140
  return self.isoperator and len(self.argnames) == 2
141
141
 
142
142
  def get_op_name(self):
143
- assert self.isoperator
143
+ if not self.isoperator:
144
+ raise ValueError(f"get_op_name called on non-operator '{self.name}'")
144
145
  return self.name[-1]
145
146
 
146
147
  def dump(self, indent=0):
pcc/ast/ast_transforms.py CHANGED
@@ -61,7 +61,10 @@ def fix_switch_cases(switch_node):
61
61
 
62
62
  A fixed AST node is returned. The argument may be modified.
63
63
  """
64
- assert isinstance(switch_node, c_ast.Switch)
64
+ if not isinstance(switch_node, c_ast.Switch):
65
+ raise TypeError(
66
+ f"fix_switch_cases expects a Switch node, got {type(switch_node).__name__}"
67
+ )
65
68
  if not isinstance(switch_node.stmt, c_ast.Compound):
66
69
  return switch_node
67
70
 
pcc/ast/c_ast.py CHANGED
@@ -457,6 +457,37 @@ class For(Node):
457
457
 
458
458
  attr_names = ()
459
459
 
460
+ class GenericAssociation(Node):
461
+ __slots__ = ('type', 'expr', 'coord', '__weakref__')
462
+ def __init__(self, type, expr, coord=None):
463
+ self.type = type
464
+ self.expr = expr
465
+ self.coord = coord
466
+
467
+ def children(self):
468
+ nodelist = []
469
+ if self.type is not None: nodelist.append(("type", self.type))
470
+ if self.expr is not None: nodelist.append(("expr", self.expr))
471
+ return tuple(nodelist)
472
+
473
+ attr_names = ()
474
+
475
+ class GenericSelection(Node):
476
+ __slots__ = ('expr', 'associations', 'coord', '__weakref__')
477
+ def __init__(self, expr, associations, coord=None):
478
+ self.expr = expr
479
+ self.associations = associations
480
+ self.coord = coord
481
+
482
+ def children(self):
483
+ nodelist = []
484
+ if self.expr is not None: nodelist.append(("expr", self.expr))
485
+ for i, child in enumerate(self.associations or []):
486
+ nodelist.append(("associations[%d]" % i, child))
487
+ return tuple(nodelist)
488
+
489
+ attr_names = ()
490
+
460
491
  class FuncCall(Node):
461
492
  __slots__ = ('name', 'args', 'coord', '__weakref__')
462
493
  def __init__(self, name, args, coord=None):
@@ -517,6 +548,19 @@ class Goto(Node):
517
548
 
518
549
  attr_names = ('name', )
519
550
 
551
+ class ComputedGoto(Node):
552
+ __slots__ = ('expr', 'coord', '__weakref__')
553
+ def __init__(self, expr, coord=None):
554
+ self.expr = expr
555
+ self.coord = coord
556
+
557
+ def children(self):
558
+ nodelist = []
559
+ if self.expr is not None: nodelist.append(("expr", self.expr))
560
+ return tuple(nodelist)
561
+
562
+ attr_names = ()
563
+
520
564
  class ID(Node):
521
565
  __slots__ = ('name', 'coord', '__weakref__', "ir_type")
522
566
  def __init__(self, name, coord=None):
@@ -587,6 +631,17 @@ class Label(Node):
587
631
 
588
632
  attr_names = ('name', )
589
633
 
634
+ class LabelAddress(Node):
635
+ __slots__ = ('name', 'coord', '__weakref__')
636
+ def __init__(self, name, coord=None):
637
+ self.name = name
638
+ self.coord = coord
639
+
640
+ def children(self):
641
+ return tuple()
642
+
643
+ attr_names = ('name', )
644
+
590
645
  class NamedInitializer(Node):
591
646
  __slots__ = ('name', 'expr', 'coord', '__weakref__')
592
647
  def __init__(self, name, expr, coord=None):
@@ -603,6 +658,21 @@ class NamedInitializer(Node):
603
658
 
604
659
  attr_names = ()
605
660
 
661
+ class RangeDesignator(Node):
662
+ __slots__ = ('start', 'end', 'coord', '__weakref__')
663
+ def __init__(self, start, end, coord=None):
664
+ self.start = start
665
+ self.end = end
666
+ self.coord = coord
667
+
668
+ def children(self):
669
+ nodelist = []
670
+ if self.start is not None: nodelist.append(("start", self.start))
671
+ if self.end is not None: nodelist.append(("end", self.end))
672
+ return tuple(nodelist)
673
+
674
+ attr_names = ()
675
+
606
676
  class ParamList(Node):
607
677
  __slots__ = ('params', 'coord', '__weakref__')
608
678
  def __init__(self, params, coord=None):
@@ -659,6 +729,19 @@ class Struct(Node):
659
729
 
660
730
  attr_names = ('name', )
661
731
 
732
+ class StmtExpr(Node):
733
+ __slots__ = ('stmt', 'coord', '__weakref__')
734
+ def __init__(self, stmt, coord=None):
735
+ self.stmt = stmt
736
+ self.coord = coord
737
+
738
+ def children(self):
739
+ nodelist = []
740
+ if self.stmt is not None: nodelist.append(("stmt", self.stmt))
741
+ return tuple(nodelist)
742
+
743
+ attr_names = ()
744
+
662
745
  class StructRef(Node):
663
746
  __slots__ = ('name', 'type', 'field', 'coord', '__weakref__')
664
747
  def __init__(self, name, type, field, coord=None):
@@ -796,5 +879,3 @@ class While(Node):
796
879
  return tuple(nodelist)
797
880
 
798
881
  attr_names = ()
799
-
800
-