3232
3333from chc .app .CDictionaryRecord import CDictionaryRecord , cdregistry
3434
35+ import chc .util .fileutil as UF
3536import chc .util .IndexedTable as IT
3637
3738if TYPE_CHECKING :
@@ -148,15 +149,15 @@ def get_strings(self) -> List[str]:
148149 def get_variable_uses (self , vid : int ) -> int :
149150 return 0
150151
151- def accept (self , visitor : "CVisitor" ) -> None :
152- raise Exception ("CExp.accept: " + str (self ))
153-
154152 def to_dict (self ) -> Dict [str , Any ]:
155153 return {"base" : "exp" }
156154
157155 def to_idict (self ) -> Dict [str , Any ]:
158156 return {"t" : self .tags , "a" : self .args }
159157
158+ def accept (self , visitor : "CVisitor" ) -> None :
159+ raise UF .CHCError ("visitor not yet implemented for: " + str (self ))
160+
160161 def __str__ (self ) -> str :
161162 return "baseexp:" + self .tags [0 ]
162163
@@ -223,6 +224,9 @@ def get_variable_uses(self, vid: int) -> int:
223224 def to_dict (self ) -> Dict [str , Any ]:
224225 return {"base" : "lval" , "lval" : self .lval .to_dict ()}
225226
227+ def accept (self , visitor : "CVisitor" ) -> None :
228+ visitor .visit_explval (self )
229+
226230 def __str__ (self ) -> str :
227231 return str (self .lval )
228232
@@ -248,6 +252,9 @@ def is_sizeof(self) -> bool:
248252 def to_dict (self ) -> Dict [str , Any ]:
249253 return {"base" : "sizeof" , "type" : self .typ .to_dict ()}
250254
255+ def accept (self , visitor : "CVisitor" ) -> None :
256+ visitor .visit_sizeof (self )
257+
251258 def __str__ (self ) -> str :
252259 return "sizeof(" + str (self .typ ) + ")"
253260
@@ -279,6 +286,9 @@ def get_variable_uses(self, vid: int) -> int:
279286 def to_dict (self ) -> Dict [str , Any ]:
280287 return {"base" : "sizeofe" , "exp" : self .exp .to_dict ()}
281288
289+ def accept (self , visitor : "CVisitor" ) -> None :
290+ visitor .visit_sizeofe (self )
291+
282292 def __str__ (self ) -> str :
283293 return "sizeofe(" + str (self .exp ) + ")"
284294
@@ -307,6 +317,9 @@ def is_sizeofstr(self) -> bool:
307317 def to_dict (self ) -> Dict [str , Any ]:
308318 return {"base" : "sizeofstr" , "string" : self .stringvalue }
309319
320+ def accept (self , visitor : "CVisitor" ) -> None :
321+ visitor .visit_size_of_str (self )
322+
310323 def __str__ (self ) -> str :
311324 return "sizeofstr(" + str (self .stringvalue ) + ")"
312325
@@ -332,6 +345,9 @@ def is_alignof(self) -> bool:
332345 def to_dict (self ) -> Dict [str , Any ]:
333346 return {"base" : "alignof" , "type" : self .typ .to_dict ()}
334347
348+ def accept (self , visitor : "CVisitor" ) -> None :
349+ visitor .visit_alignof (self )
350+
335351 def __str__ (self ) -> str :
336352 return "alignof(" + str (self .typ ) + ")"
337353
@@ -366,6 +382,9 @@ def get_variable_uses(self, vid: int) -> int:
366382 def to_dict (self ) -> Dict [str , Any ]:
367383 return {"base" : "alignofe" , "exp" : self .exp .to_dict ()}
368384
385+ def accept (self , visitor : "CVisitor" ) -> None :
386+ visitor .visit_alignofe (self )
387+
369388 def __str__ (self ) -> str :
370389 return "alignofe(" + str (self .exp ) + ")"
371390
@@ -411,6 +430,9 @@ def get_variable_uses(self, vid: int) -> int:
411430 def to_dict (self ) -> Dict [str , Any ]:
412431 return {"base" : "unop" , "op" : self .op , "exp" : self .exp .to_dict ()}
413432
433+ def accept (self , visitor : "CVisitor" ) -> None :
434+ visitor .visit_unop (self )
435+
414436 def __str__ (self ) -> str :
415437 return "(" + unoperatorstrings [self .op ] + " " + str (self .exp ) + ")"
416438
@@ -474,6 +496,9 @@ def to_dict(self) -> Dict[str, Any]:
474496 "exp2" : self .exp2 .to_dict (),
475497 }
476498
499+ def accept (self , visitor : "CVisitor" ) -> None :
500+ visitor .visit_binop (self )
501+
477502 def __str__ (self ) -> str :
478503 return (
479504 "("
@@ -549,6 +574,9 @@ def to_dict(self) -> Dict[str, object]:
549574 "type" : self .typ .to_dict (),
550575 }
551576
577+ def accept (self , visitor : "CVisitor" ) -> None :
578+ visitor .visit_question (self )
579+
552580 def __str__ (self ) -> str :
553581 return (
554582 "("
@@ -600,6 +628,9 @@ def to_dict(self) -> Dict[str, object]:
600628 "type" : self .typ .to_dict (),
601629 }
602630
631+ def accept (self , visitor : "CVisitor" ) -> None :
632+ visitor .visit_cast (self )
633+
603634 def __str__ (self ) -> str :
604635 return "caste(" + str (self .typ ) + "," + str (self .exp ) + ")"
605636
@@ -634,6 +665,9 @@ def get_variable_uses(self, vid: int) -> int:
634665 def to_dict (self ) -> Dict [str , object ]:
635666 return {"base" : "addrof" , "lval" : self .lval .to_dict ()}
636667
668+ def accept (self , visitor : "CVisitor" ) -> None :
669+ visitor .visit_addrof (self )
670+
637671 def __str__ (self ) -> str :
638672 return "&(" + str (self .lval ) + ")"
639673
@@ -655,6 +689,9 @@ def label_sid(self) -> int:
655689 def to_dict (self ) -> Dict [str , object ]:
656690 return {"base" : "addroflabel" , "label" : self .label_sid }
657691
692+ def accept (self , visitor : "CVisitor" ) -> None :
693+ visitor .visit_addr_of_label (self )
694+
658695 def __str__ (self ) -> str :
659696 return "addroflabel(" + str (self .label_sid ) + ")"
660697
@@ -689,6 +726,9 @@ def get_variable_uses(self, vid: int) -> int:
689726 def to_dict (self ) -> Dict [str , Any ]:
690727 return {"base" : "startof" , "lval" : self .lval .to_dict ()}
691728
729+ def accept (self , visitor : "CVisitor" ) -> None :
730+ visitor .visit_startof (self )
731+
692732 def __str__ (self ) -> str :
693733 return "&(" + str (self .lval ) + ")"
694734
@@ -722,6 +762,9 @@ def arguments(self) -> List[Optional[CExp]]:
722762 def has_variable (self , vid : int ) -> bool :
723763 return any ([a .has_variable (vid ) for a in self .arguments if a ])
724764
765+ def accept (self , visitor : "CVisitor" ) -> None :
766+ visitor .visit_fn_app (self )
767+
725768 def __str__ (self ) -> str :
726769 return (
727770 "fnapp("
@@ -762,6 +805,9 @@ def arguments(self) -> List[Optional[CExp]]:
762805 def has_variable (self , vid : int ) -> bool :
763806 return any ([a .has_variable (vid ) for a in self .arguments if a ])
764807
808+ def accept (self , visitor : "CVisitor" ) -> None :
809+ visitor .visit_cn_app (self )
810+
765811 def __str__ (self ) -> str :
766812 return (
767813 "cnapp("
0 commit comments