Skip to main content

crashtest.hxsmith.quality

The decompilation-quality ladder.

Every decompiled program lands on exactly one rung, the highest it reaches. Rungs are ordered so a regression is simply new < old.

classify is a pure function of what each pipeline stage observed, so the rules live in one place and are testable without Haxe, HashLink or a bytecode image. The stages themselves are in pipeline.py.

class Observation​

What each pipeline stage saw. A stage that did not run is left at its default.

decompile_error: Optional[str]​

decompile_error = None

decompiled: Dict[str, str]​

decompiled = field(default_factory=dict)

compile_error: Optional[str]​

compile_error = None

behavior: Optional[BehavioralComparison]​

behavior = None

similarity: Optional[float]​

similarity = None

differing: List[tuple]​

differing = field(default_factory=list)

equivalent: Optional[bool]​

equivalent = None

init​

def __init__(decompile_error: Optional[str] = None, decompiled: Dict[str, str] = dict(), compile_error: Optional[str] = None, behavior: Optional[BehavioralComparison] = None, similarity: Optional[float] = None, differing: List[tuple] = list(), equivalent: Optional[bool] = None) -> None

class Quality(IntEnum)​

How far a decompilation got. Higher is better.

CRASH​

CRASH = 0

UNLIFTED​

UNLIFTED = 1

NO_COMPILE​

NO_COMPILE = 2

DIVERGES​

DIVERGES = 3

BEHAVES​

BEHAVES = 4

EQUIVALENT​

EQUIVALENT = 5

IDENTICAL​

IDENTICAL = 6

meaning: str​

class Verdict​

quality: Quality​

stage: str​

detail: str​

detail = ''

signature: str​

signature = ''

similarity: Optional[float]​

similarity = None

differing: List[tuple]​

differing = field(default_factory=list)

to_json​

def to_json() -> dict

from_json​

classmethod

@classmethod
def from_json(data: dict) -> 'Verdict'

init​

def __init__(quality: Quality, stage: str, detail: str = '', signature: str = '', similarity: Optional[float] = None, differing: List[tuple] = list()) -> None

classify​

def classify(obs: Observation) -> Verdict

Place an observation on the ladder, taking the first failing rung from the bottom.

error_kinds​

def error_kinds(detail: str) -> frozenset

The distinct kinds of Haxe error in a compiler report. Haxe reports every error, so a program can have several unrelated ones; the first alone would hide the rest. Positions, numbers and the member named in has no field X are stripped so one bug is one kind.

first_difference​

def first_difference(behavior: BehavioralComparison) -> str

The first output line that differs, for a human looking at a DIVERGES verdict.

normalize​

def normalize(message: str) -> str

Strip what varies between instances of one failure: numbers, positions, generated names.