in sapp/pipeline/mariana_trench_parser.py [0:0]
def from_json(port: str, leaf_kind: str) -> "Port":
elements = port.split(".")
if len(elements) == 0:
raise sapp.ParseError(f"Invalid port: `{port}`.")
elements[0] = elements[0].lower()
if elements[0] == "leaf":
elements[0] = leaf_kind
elif elements[0] == "return":
elements[0] = "result"
elif elements[0] == "anchor":
# Anchor port is of the form Anchor.<MT port, e.g. Argument(0)>
# SAPP/CRTEX expects: "anchor:formal(0)"
canonical_port = Port.from_json(
".".join(elements[1:]), "unreachable_leaf_kind_anchor"
)
return Port(f"{elements[0]}:{Port.to_crtex(canonical_port.value)}")
elif elements[0] == "producer" and len(elements) >= 3:
# Producer port is of the form Producer.<producer_id>.<MT port>.
# SAPP/CRTEX expects: "producer:<producer_id>:<canonical_port>".
root = elements[0]
producer_id = elements[1]
canonical_port = Port.from_json(
".".join(elements[2:]), "unreachable_leaf_kind_producer"
)
return Port(f"{root}:{producer_id}:{Port.to_crtex(canonical_port.value)}")
return Port(".".join(elements))