Debian Codegraph @

cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexLabel.py

raw
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 """Command used to give a line in a test a named psuedonym. Every DexLabel has
8 a line number and Label string component.
9 """
10
11 from dex.command.CommandBase import CommandBase
12
13
14 class DexLabel(CommandBase):
15 def __init__(self, label, **kwargs):
16 if not isinstance(label, str):
17 raise TypeError("invalid argument type")
18
19 try:
20 self.on_line = kwargs.pop("on_line")
21 except KeyError:
22 # We cannot use self.lineno because it hasn't been set yet.
23 pass
24 if kwargs:
25 raise TypeError(f'unexpected named args: {", ".join(kwargs)}')
26
27 self._label = label
28 super(DexLabel, self).__init__()
29
30 def get_line(self):
31 return getattr(self, "on_line", self.lineno)
32
33 def get_as_pair(self):
34 return (self._label, self.get_line())
35
36 @staticmethod
37 def get_name():
38 return __class__.__name__
39
40 def eval(self):
41 return self._label