xref: /llvm-project/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexDeclareFile.py (revision f98ee40f4b5d7474fc67e82824bf6abbaedb7b1c)
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"""Commmand sets the path for all following commands to 'declared_file'.
8"""
9
10from pathlib import PurePath
11
12from dex.command.CommandBase import CommandBase
13
14
15class DexDeclareFile(CommandBase):
16    def __init__(self, declared_file):
17
18        if not isinstance(declared_file, str):
19            raise TypeError("invalid argument type")
20
21        # Use PurePath to create a cannonical platform path.
22        # TODO: keep paths as PurePath objects for 'longer'
23        self.declared_file = str(PurePath(declared_file))
24        super(DexDeclareFile, self).__init__()
25
26    @staticmethod
27    def get_name():
28        return __class__.__name__
29
30    def eval(self):
31        return self.declared_file
32