Files
Akhil G c6600cfc8d add __int__, __hash__, __eq__ methods and missing annotations to Token, Local, and Argument classes (#103)
* add __int__, __hash__, __eq__ methods and missing annotations to Token, Local, and Argument classes

* Removal of redundant cast. Lint checked.
2024-03-20 09:47:25 -06:00

32 lines
1.1 KiB
Python

# Copyright (C) 2022 Mandiant, Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at: [package root]/LICENSE.txt
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
from __future__ import annotations
class Argument:
"""store managed method argument"""
def __init__(self, index: int):
self.index: int = index
def __str__(self) -> str:
return "argument(0x%04X)" % self.index
def __repr__(self) -> str:
return str(self)
def __int__(self) -> int:
return self.index
def __eq__(self, other: object) -> bool:
return isinstance(other, Argument) and self.index == other.index
def __hash__(self) -> int:
return hash(self.index)