Skip to content

Commit

Permalink
Adjusting the pyk scripts to conform with recent changes (#63)
Browse files Browse the repository at this point in the history
* Adjusting the pyk scripts to conform with recent changes

* Update Makefile

Removing outdated code section.

* Undoing misplaced change

* Adjusting functions to have proper naming and operations
  • Loading branch information
ACassimiro authored Aug 27, 2024
1 parent 625a499 commit 959c38c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ preprocessing-test: $(PREPROCESSING_OUTPUTS)
execution-test: $(EXECUTION_OUTPUTS)

$(RUST_PREPROCESSING_TIMESTAMP): $(SEMANTICS_FILES)
$$(which kompile) rust-semantics/targets/preprocessing/rust.md -o $(RUST_PREPROCESSING_KOMPILED)
$$(which kompile) rust-semantics/targets/preprocessing/rust.md --emit-json -o $(RUST_PREPROCESSING_KOMPILED)

$(RUST_EXECUTION_TIMESTAMP): $(SEMANTICS_FILES)
$$(which kompile) rust-semantics/targets/execution/rust.md -o $(RUST_EXECUTION_KOMPILED)
$$(which kompile) rust-semantics/targets/execution/rust.md --emit-json -o $(RUST_EXECUTION_KOMPILED)

$(SYNTAX_OUTPUT_DIR)/%.rs-parsed: $(SYNTAX_INPUT_DIR)/%.rs $(RUST_PREPROCESSING_TIMESTAMP)
mkdir -p $(SYNTAX_OUTPUT_DIR)
Expand Down
4 changes: 2 additions & 2 deletions rust-lite/src/rust_lite/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def exec_run(options: RunOptions) -> None:

print('Performed all possible rewriting operations; Trying to fetch the content of the K cell.')

module_manager.fetch_k_cell_content()
module_manager.print_k_top_element()

def trigger_exec_run(stripped_args):
options = generate_options(stripped_args)
Expand All @@ -68,7 +68,7 @@ def trigger_exec_run(stripped_args):
execute(options)

def exec_empty() -> None:
stripped_args = {'command': 'run', 'input_file': Path('../tests/execution/empty.rs')}
stripped_args = {'command': 'run', 'input_file': Path('../tests/preprocessing/empty.rs')}
trigger_exec_run(stripped_args)

def exec_erc20() -> None:
Expand Down
24 changes: 16 additions & 8 deletions rust-lite/src/rust_lite/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pprint
from collections.abc import Iterable
from collections import deque
from typing import TYPE_CHECKING, Mapping, Any
from pathlib import Path

Expand All @@ -20,7 +21,7 @@ class RustLiteManager():
cterm: CTerm

def __init__(self) -> None:
dir_path = Path(f'../.build/rust-kompiled')
dir_path = Path(f'../.build/rust-execution-kompiled')
self.krun = KRun(dir_path)
self._init_cterm()

Expand All @@ -31,7 +32,7 @@ def _init_cterm(self) -> None:

def load_program(self, program_path: str) -> None:

returned_process = _kast(file=program_path, definition_dir=f'../.build/rust-kompiled')
returned_process = _kast(file=program_path, definition_dir=f'../.build/rust-execution-kompiled')

program = returned_process.stdout

Expand All @@ -43,11 +44,18 @@ def load_program(self, program_path: str) -> None:
output_kore = self.krun.run_pattern(pattern, pipe_stderr=False)
self.cterm = CTerm.from_kast(self.krun.kore_to_kast(output_kore))


def fetch_k_cell_content(self):
print('--------------------------------------------------')
print('K CELL CONTENTS: ')
def fetch_k_cell_content(self) -> KToken:
cell = self.cterm.cell('K_CELL')
_PPRINT.pprint(cell)
return cell


def print_k_top_element(self) -> None:
cell = self.fetch_k_cell_content()
queue: deque[KInner] = deque(cell)

print('--------------------------------------------------')
print('K CELL TOP ELEMENT: ')
if(len(queue) > 0):
top_cell = queue.popleft()
_PPRINT.pprint(top_cell)
else:
print('Cell is empty.')

0 comments on commit 959c38c

Please sign in to comment.