42 lines · python
1# DExTer : Debugging Experience Tester2# ~~~~~~ ~ ~~ ~ ~~3#4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5# See https://llvm.org/LICENSE.txt for license information.6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7 8 9class ValueIR:10 """Data class to store the result of an expression evaluation."""11 12 def __init__(13 self,14 expression: str,15 value: str,16 type_name: str,17 could_evaluate: bool,18 error_string: str = None,19 is_optimized_away: bool = False,20 is_irretrievable: bool = False,21 ):22 self.expression = expression23 self.value = value24 self.type_name = type_name25 self.could_evaluate = could_evaluate26 self.error_string = error_string27 self.is_optimized_away = is_optimized_away28 self.is_irretrievable = is_irretrievable29 30 def __str__(self):31 prefix = '"{}": '.format(self.expression)32 if self.error_string is not None:33 return prefix + self.error_string34 if self.value is not None:35 return prefix + "({}) {}".format(self.type_name, self.value)36 return (37 prefix38 + "could_evaluate: {}; irretrievable: {}; optimized_away: {};".format(39 self.could_evaluate, self.is_irretrievable, self.is_optimized_away40 )41 )42