| 141 | |
| 142 | @dataclass |
| 143 | class Local: |
| 144 | item: StackItem |
| 145 | memory_offset: PointerOffset | None |
| 146 | in_local: bool |
| 147 | |
| 148 | def __repr__(self) -> str: |
| 149 | return f"Local('{self.item.name}', mem={self.memory_offset}, local={self.in_local}, array={self.is_array()})" |
| 150 | |
| 151 | def compact_str(self) -> str: |
| 152 | mtag = "M" if self.memory_offset else "" |
| 153 | dtag = "L" if self.in_local else "" |
| 154 | atag = "A" if self.is_array() else "" |
| 155 | return f"'{self.item.name}'{mtag}{dtag}{atag}" |
| 156 | |
| 157 | @staticmethod |
| 158 | def unused(defn: StackItem, offset: PointerOffset | None) -> "Local": |
| 159 | return Local(defn, offset, False) |
| 160 | |
| 161 | @staticmethod |
| 162 | def undefined(defn: StackItem) -> "Local": |
| 163 | return Local(defn, None, False) |
| 164 | |
| 165 | @staticmethod |
| 166 | def from_memory(defn: StackItem, offset: PointerOffset) -> "Local": |
| 167 | return Local(defn, offset, True) |
| 168 | |
| 169 | @staticmethod |
| 170 | def register(name: str) -> "Local": |
| 171 | item = StackItem(name, "", False, True) |
| 172 | return Local(item, None, True) |
| 173 | |
| 174 | def kill(self) -> None: |
| 175 | self.in_local = False |
| 176 | self.memory_offset = None |
| 177 | |
| 178 | def in_memory(self) -> bool: |
| 179 | return self.memory_offset is not None or self.is_array() |
| 180 | |
| 181 | def is_dead(self) -> bool: |
| 182 | return not self.in_local and self.memory_offset is None |
| 183 | |
| 184 | def copy(self) -> "Local": |
| 185 | return Local( |
| 186 | self.item, |
| 187 | self.memory_offset, |
| 188 | self.in_local |
| 189 | ) |
| 190 | |
| 191 | @property |
| 192 | def size(self) -> str: |
| 193 | return self.item.size |
| 194 | |
| 195 | @property |
| 196 | def name(self) -> str: |
| 197 | return self.item.name |
| 198 | |
| 199 | def is_array(self) -> bool: |
| 200 | return self.item.is_array() |
no outgoing calls
no test coverage detected
searching dependent graphs…