xref: /llvm-project/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexDeclareFile.py (revision 45a40c163932d12b72b33bd1d8a84519392b5d39)
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        if not isinstance(declared_file, str):
18            raise TypeError("invalid argument type")
19
20        # Use PurePath to create a cannonical platform path.
21        # TODO: keep paths as PurePath objects for 'longer'
22        self.declared_file = str(PurePath(declared_file))
23        super(DexDeclareFile, self).__init__()
24
25    @staticmethod
26    def get_name():
27        return __class__.__name__
28
29    def eval(self):
30        return self.declared_file
31