Skip to content

Commit 2bda409

Browse files
committed
USER: add loopcounter to mods; add const-global-variables annotation
1 parent 6c51f50 commit 2bda409

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

chb/userdata/UserHints.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ def arraysize(self) -> Optional[int]:
572572
def ispointer(self) -> bool:
573573
return "ptrto" in self.mods
574574

575+
@property
576+
def is_loopcounter(self) -> bool:
577+
return "loopcounter" in self.mods
578+
575579
def to_xml(self, node: ET.Element) -> None:
576580
xvintro = ET.Element("vintro")
577581
node.append(xvintro)
@@ -583,6 +587,8 @@ def to_xml(self, node: ET.Element) -> None:
583587
xvintro.set("arraysize", str(self.arraysize))
584588
elif self.ispointer:
585589
xvintro.set("ptrto", "yes")
590+
if self.is_loopcounter:
591+
xvintro.set("loopcounter", "yes")
586592

587593
def __str__(self) -> str:
588594
return (
@@ -720,6 +726,10 @@ def remove_reaching_definitions(self) -> List[RemoveReachingDefinitions]:
720726
result.append(rrd)
721727
return result
722728

729+
@property
730+
def const_global_variables(self) -> List[str]:
731+
return self.fnannotation.get("const-global-variables", [])
732+
723733
def has_register_variable_introduction(self, iaddr: str) -> bool:
724734
return iaddr in self.register_variable_introductions
725735

@@ -761,6 +771,13 @@ def to_xml(self, node: ET.Element) -> None:
761771
node.append(xrrds)
762772
for rd in self.remove_reaching_definitions:
763773
rd.to_xml(xrrds)
774+
if len(self.const_global_variables) > 0:
775+
xcgvars = ET.Element("const-global-variables")
776+
node.append(xcgvars)
777+
for name in self.const_global_variables:
778+
xcgvar = ET.Element("gvar")
779+
xcgvar.set("name", name)
780+
xcgvars.append(xcgvar)
764781

765782
def __str__(self) -> str:
766783
lines: List[str] = []

0 commit comments

Comments
 (0)