• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# DExTer : Debugging Experience Tester
2# ~~~~~~   ~         ~~         ~   ~~
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-exception
7
8
9class ValueIR:
10    """Data class to store the result of an expression evaluation."""
11
12    def __init__(self,
13                 expression: str,
14                 value: str,
15                 type_name: str,
16                 could_evaluate: bool,
17                 error_string: str = None,
18                 is_optimized_away: bool = False,
19                 is_irretrievable: bool = False):
20        self.expression = expression
21        self.value = value
22        self.type_name = type_name
23        self.could_evaluate = could_evaluate
24        self.error_string = error_string
25        self.is_optimized_away = is_optimized_away
26        self.is_irretrievable = is_irretrievable
27
28    def __str__(self):
29        prefix = '"{}": '.format(self.expression)
30        if self.error_string is not None:
31            return prefix + self.error_string
32        if self.value is not None:
33            return prefix + '({}) {}'.format(self.type_name, self.value)
34        return (prefix +
35                'could_evaluate: {}; irretrievable: {}; optimized_away: {};'
36                    .format(self.could_evaluate, self.is_irretrievable,
37                            self.is_optimized_away))
38
39