Skip to content

Commit

Permalink
Handle temp file missing from pyre cache and removed PatchReturns() f…
Browse files Browse the repository at this point in the history
…rom default setup
  • Loading branch information
mad-cat-lon committed Aug 7, 2024
1 parent 840d322 commit f1aaa64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions jargonaut.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def main():
if system == "Windows":
print("[!] Pyre is not currently supported on Windows.")
exit()
# os.system("pyre")
else:
os.system("pyre >> /tmp/out")
start_time = timer()
# Preprocessing step (we need to write to a temp file in order to make pyre play nice)
with open(os.path.join(input_dir, args.in_file), "r", encoding="utf-8") as in_file:
Expand Down Expand Up @@ -130,13 +131,15 @@ def main():
out_file.write(preprocessed)
print("[-] Finished preprocessing.")
# HACK: i will handle pyre server setup and configuration later
if system != "Windows":
if system != "Windows" and do_inference:
# Restart pyre server to make it cache the temp file
os.system("pyre stop >> /tmp/out")
os.system("pyre >> /tmp/out")
with open(os.path.join(input_dir, temp_file), "r", encoding="utf-8") as in_file:
tree = cst.parse_module(in_file.read())
transformations = [
# Patch function return values
control.PatchReturns(),
# control.PatchReturns(),
# Transform expressions to linear MBAs
data.ExprToLinearMBA(
sub_expr_depth=[1, 3],
Expand All @@ -147,7 +150,7 @@ def main():
data.HideBuiltinCalls(),
# Transform integers to linear MBAs
data.ConstIntToLinearMBA(
n_terms_range=[4, 5],
n_terms_range=[5, 8],
inference=do_inference
),
# data.VirtualizeFuncs(
Expand Down Expand Up @@ -196,6 +199,8 @@ def main():
os.path.join(output_dir, args.out_file),
(end_time - start_time)
)
if system != "Windows":
os.system("pyre stop >> /tmp/out")
exit()


Expand Down
1 change: 1 addition & 0 deletions jargonaut/transformations/control/patch_returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def patch_bytecode(y):
def __init__(self, avoid=None):
if sys.version_info.minor > 10:
print("[!] PatchReturns() cannot be used for Python >3.10 due to PEP 659.")
exit()
self.avoid = avoid
self.first_visit = True
self.progress_msg = "Patching function return values..."
Expand Down

0 comments on commit f1aaa64

Please sign in to comment.