brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 1dd0e54 Raw
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"""Command used to give a line in a test a named psuedonym. Every DexLabel has8   a line number and Label string component.9"""10 11from dex.command.CommandBase import CommandBase12 13 14class 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            pass24        if kwargs:25            raise TypeError(f'unexpected named args: {", ".join(kwargs)}')26 27        self._label = label28        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    @staticmethod37    def get_name():38        return __class__.__name__39 40    def eval(self):41        return self._label42