Skip to content

Commit

Permalink
Rename variables for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonievonMann committed Feb 20, 2024
1 parent 2dec04c commit ca46968
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions varats/varats/data/reports/blame_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,33 @@
class BlameInstruction():
"""Collection of debug blame and VaRA blame."""

def __init__(self, dbghash: str, varahash: str) -> None:
self.__dbghash = dbghash
self.__varahash = varahash
def __init__(self, dbg_hash: str, vara_computed_hash: str) -> None:
self.__dbg_hash = dbg_hash
self.__vara_computed_hash = vara_computed_hash

@staticmethod
def create_blame_instruction(
raw_entry: tp.Dict[str, tp.Any]
) -> 'BlameInstruction':
"""Creates a :class`BlameInstrucion`from the corresponding yaml document
section."""
dbghash = str(raw_entry['dbghash'])
varahash = str(raw_entry['varahash'])
return BlameInstruction(dbghash, varahash)
dbg_hash = str(raw_entry['dbghash'])
vara_computed_hash = str(raw_entry['varahash'])
return BlameInstruction(dbg_hash, vara_computed_hash)

@property
def dbghash(self) -> str:
def dbg_hash(self) -> str:
"""Blame based on debug information."""
return self.__dbghash
return self.__dbg_hash

@property
def varahash(self) -> str:
"""Blame based on IRegion."""
return self.__varahash
def vara_computed_hash(self) -> str:
"""
Blame based on IRegion.
Can be produced in different ways, based on which flag is used.
"""
return self.__vara_computed_hash


class BlameFunctionAnnotations():
Expand Down Expand Up @@ -154,18 +158,20 @@ def compare_blame_annotations(

for func in ast_ba.functions:
for entry in func.blame_annotations.values():
if entry.dbghash and entry.varahash:
ast_report.update_dbg_ast(entry.dbghash != entry.varahash)
if entry.dbg_hash and entry.vara_computed_hash:
ast_report.update_dbg_ast(
entry.dbg_hash != entry.vara_computed_hash
)

for line_func, ast_func in zip(line_ba.functions, ast_ba.functions):
line_annotations = line_func.blame_annotations
ast_annotations = ast_func.blame_annotations
for inst in ast_annotations:
if line_annotations[inst].varahash and ast_annotations[inst
].varahash:
if line_annotations[inst].vara_computed_hash and ast_annotations[
inst].vara_computed_hash:
ast_report.update_line_ast(
line_annotations[inst].varahash !=
ast_annotations[inst].varahash
line_annotations[inst].vara_computed_hash !=
ast_annotations[inst].vara_computed_hash
)

return ast_report

0 comments on commit ca46968

Please sign in to comment.