-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bytes hooks #151
Merged
Merged
Bytes hooks #151
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ DEMOS_TESTING_OUTPUT_DIR ::= .build/demos/output | |
DEMOS_TESTING_INPUTS ::= $(wildcard $(DEMOS_TESTING_INPUT_DIR)/*.run) | ||
DEMOS_TESTING_OUTPUTS ::= $(patsubst $(DEMOS_TESTING_INPUT_DIR)/%,$(DEMOS_TESTING_OUTPUT_DIR)/%.executed.kore,$(DEMOS_TESTING_INPUTS)) | ||
|
||
UKM_SEMANTICS_FILES ::= $(shell find mx-rust-semantics/ -type f -a '(' -name '*.md' -or -name '*.k' ')') | ||
UKM_SEMANTICS_FILES ::= $(shell find ukm-semantics/ -type f -a '(' -name '*.md' -or -name '*.k' ')') | ||
|
||
UKM_EXECUTION_KOMPILED ::= .build/ukm-execution-kompiled | ||
UKM_EXECUTION_TIMESTAMP ::= $(UKM_EXECUTION_KOMPILED)/timestamp | ||
|
@@ -75,7 +75,14 @@ UKM_PREPROCESSING_TIMESTAMP ::= $(UKM_PREPROCESSING_KOMPILED)/timestamp | |
UKM_TESTING_KOMPILED ::= .build/ukm-testing-kompiled | ||
UKM_TESTING_TIMESTAMP ::= $(UKM_TESTING_KOMPILED)/timestamp | ||
|
||
.PHONY: clean build build-legacy test test-legacy syntax-test preprocessing-test execution-test mx-test mx-rust-test mx-rust-contract-test mx-rust-two-contracts-test demos-test | ||
UKM_CONTRACTS_TESTING_INPUT_DIR ::= tests/ukm-contracts | ||
|
||
UKM_NO_CONTRACT_TESTING_INPUT_DIR ::= tests/ukm-no-contract | ||
UKM_NO_CONTRACT_TESTING_OUTPUT_DIR ::= .build/ukm-no-contract/output | ||
UKM_NO_CONTRACT_TESTING_INPUTS ::= $(wildcard $(UKM_NO_CONTRACT_TESTING_INPUT_DIR)/*.run) | ||
UKM_NO_CONTRACT_TESTING_OUTPUTS ::= $(patsubst $(UKM_NO_CONTRACT_TESTING_INPUT_DIR)/%,$(UKM_NO_CONTRACT_TESTING_OUTPUT_DIR)/%.executed.kore,$(UKM_NO_CONTRACT_TESTING_INPUTS)) | ||
|
||
.PHONY: clean build build-legacy test test-legacy syntax-test preprocessing-test execution-test mx-test mx-rust-test mx-rust-contract-test mx-rust-two-contracts-test demos-test ukm-no-contracts-test | ||
|
||
all: build test | ||
|
||
|
@@ -96,7 +103,7 @@ build-legacy: \ | |
$(MX_RUST_TWO_CONTRACTS_TESTING_TIMESTAMP) | ||
|
||
|
||
test: build syntax-test preprocessing-test execution-test crates-test | ||
test: build syntax-test preprocessing-test execution-test crates-test ukm-no-contracts-test | ||
|
||
test-legacy: mx-test mx-rust-test mx-rust-contract-test mx-rust-two-contracts-test demos-test | ||
|
||
|
@@ -118,6 +125,8 @@ mx-rust-two-contracts-test: $(MX_RUST_TWO_CONTRACTS_TESTING_OUTPUTS) | |
|
||
demos-test: $(DEMOS_TESTING_OUTPUTS) | ||
|
||
ukm-no-contracts-test: $(UKM_NO_CONTRACT_TESTING_OUTPUTS) | ||
|
||
$(RUST_PREPROCESSING_TIMESTAMP): $(RUST_SEMANTICS_FILES) | ||
# Workaround for https://github.com/runtimeverification/k/issues/4141 | ||
-rm -r $(RUST_PREPROCESSING_KOMPILED) | ||
|
@@ -373,3 +382,45 @@ $(CRATES_TESTING_OUTPUT_DIR)/%.run.executed.kore: \ | |
-pTEST=$(CURDIR)/parsers/test-rust.sh | ||
cat [email protected] | grep -q "Lbl'-LT-'k'-GT-'{}(dotk{}())" | ||
mv -f [email protected] $@ | ||
|
||
|
||
# TODO: Add $(shell echo "$<" | sed 's/\.[^.]*.run$$//').rs | ||
# as a dependency | ||
$(UKM_NO_CONTRACT_TESTING_OUTPUT_DIR)/%.run.executed.kore: \ | ||
$(UKM_NO_CONTRACT_TESTING_INPUT_DIR)/%.run \ | ||
$(UKM_CONTRACTS_TESTING_INPUT_DIR)/bytes_hooks.rs \ | ||
$(UKM_CONTRACTS_TESTING_INPUT_DIR)/ukm.rs \ | ||
$(UKM_TESTING_TIMESTAMP) \ | ||
$(wildcard parsers/inc-*.sh) \ | ||
parsers/crates-ukm-testing-execution.sh \ | ||
parsers/test-ukm-testing-execution.sh | ||
mkdir -p $(UKM_NO_CONTRACT_TESTING_OUTPUT_DIR) | ||
|
||
echo "<(<" > [email protected] | ||
echo "::bytes_hooks" >> [email protected] | ||
echo "<|>" >> [email protected] | ||
cat $(UKM_CONTRACTS_TESTING_INPUT_DIR)/bytes_hooks.rs >> [email protected] | ||
echo ">)>" >> [email protected] | ||
|
||
# echo "<(<" > [email protected] | ||
# echo "::ukm" >> [email protected] | ||
# echo "<|>" >> [email protected] | ||
# cat $(UKM_CONTRACTS_TESTING_INPUT_DIR)/ukm.rs >> [email protected] | ||
# echo ">)>" >> [email protected] | ||
|
||
echo "<(<" >> [email protected] | ||
echo "$<" | sed 's%^.*/%%' | sed 's/\..*//' | sed 's/^/::/' >> [email protected] | ||
echo "<|>" >> [email protected] | ||
cat "$(shell echo "$<" | sed 's/\.[^.]*.run$$//').rs" >> [email protected] | ||
echo ">)>" >> [email protected] | ||
|
||
krun \ | ||
[email protected] \ | ||
--parser $(CURDIR)/parsers/crates-ukm-testing-execution.sh \ | ||
--definition $(UKM_TESTING_KOMPILED) \ | ||
--output kore \ | ||
--output-file [email protected] \ | ||
-cTEST='$(shell cat $<)' \ | ||
-pTEST=$(CURDIR)/parsers/test-ukm-testing-execution.sh | ||
cat [email protected] | grep -q "Lbl'-LT-'k'-GT-'{}(dotk{}())" | ||
mv -f [email protected] $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! /bin/bash | ||
|
||
source ${BASH_SOURCE%/*}/inc-crates.sh | ||
|
||
parse_crates .build/ukm-testing-kompiled $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#! /bin/bash | ||
|
||
kast \ | ||
--output kore \ | ||
--definition .build/ukm-testing-kompiled \ | ||
--module UKM-TARGET-SYNTAX \ | ||
--sort ExecutionTest \ | ||
$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
extern "C" { | ||
fn empty() -> u64; | ||
fn length(bytes_id: u64) -> u32; | ||
|
||
fn append_u128(bytes_id: u64, value: u128) -> u64; | ||
fn append_u64(bytes_id: u64, value: u64) -> u64; | ||
fn append_u32(bytes_id: u64, value: u32) -> u64; | ||
fn append_u16(bytes_id: u64, value: u16) -> u64; | ||
fn append_u7(bytes_id: u64, value: u8) -> u64; | ||
fn append_str(bytes_id: u64, value: &str) -> u64; | ||
|
||
fn decode_u128(bytes_id: u64) -> (u64, u128); | ||
fn decode_u64(bytes_id: u64) -> (u64, u64); | ||
fn decode_u32(bytes_id: u64) -> (u64, u32); | ||
fn decode_u16(bytes_id: u64) -> (u64, u16); | ||
fn decode_u8(bytes_id: u64) -> (u64, u8); | ||
fn decode_str(bytes_id: u64) -> (u64, str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
push 10_u32; | ||
call :: test_bytes_hooks :: append_u32; | ||
return_value_to_arg; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 3_u32; | ||
|
||
push 1000_u32; | ||
call :: test_bytes_hooks :: append_u32; | ||
return_value_to_arg; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 4_u32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
push 10_u64; | ||
call :: test_bytes_hooks :: append_u64; | ||
return_value_to_arg; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 3_u32; | ||
|
||
push 1000_u64; | ||
call :: test_bytes_hooks :: append_u64; | ||
return_value_to_arg; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 4_u32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
push 10_u32; | ||
call :: test_bytes_hooks :: append_decode_u32; | ||
return_value; | ||
check_eq(2_u64, 10_u32); | ||
|
||
push 2_u64; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 0_u32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
push 10_u64; | ||
call :: test_bytes_hooks :: append_decode_u64; | ||
return_value; | ||
check_eq(2_u64, 10_u32); | ||
|
||
push 2_u64; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 0_u32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
push "Hello"; | ||
call :: test_bytes_hooks :: append_decode_str; | ||
return_value; | ||
check_eq(2_u64, "Hello"); | ||
|
||
push 2_u64; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 0_u32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
push "Hello"; | ||
call :: test_bytes_hooks :: append_str; | ||
return_value_to_arg; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 7_u32; | ||
|
||
push "Everyone"; | ||
call :: test_bytes_hooks :: append_str; | ||
return_value_to_arg; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 10_u32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
call :: test_bytes_hooks :: empty; | ||
return_value_to_arg; | ||
call :: bytes_hooks :: length; | ||
return_value; | ||
check_eq 0_u32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#![no_std] | ||
|
||
fn empty() -> u64 { | ||
::bytes_hooks::empty() | ||
} | ||
|
||
fn append_u64(v:u64) -> u64 { | ||
let id = ::bytes_hooks::empty(); | ||
::bytes_hooks::append_u64(id, v) | ||
} | ||
|
||
fn append_decode_u64(v:u64) -> (u64, u32) { | ||
let id = ::bytes_hooks::empty(); | ||
let id = ::bytes_hooks::append_u64(id, v); | ||
::bytes_hooks::decode_u32(id) | ||
} | ||
|
||
fn append_u32(v:u32) -> u64 { | ||
let id = ::bytes_hooks::empty(); | ||
::bytes_hooks::append_u32(id, v) | ||
} | ||
|
||
fn append_decode_u32(v:u32) -> (u64, u32) { | ||
let id = ::bytes_hooks::empty(); | ||
let id = ::bytes_hooks::append_u32(id, v); | ||
::bytes_hooks::decode_u32(id) | ||
} | ||
|
||
fn append_str(v:&str) -> u64 { | ||
let id = ::bytes_hooks::empty(); | ||
::bytes_hooks::append_str(id, v) | ||
} | ||
|
||
fn append_decode_str(v:&str) -> (u64, str) { | ||
let id = ::bytes_hooks::empty(); | ||
let id = ::bytes_hooks::append_str(id, v); | ||
::bytes_hooks::decode_str(id) | ||
} | ||
|
||
fn append_decode_multi_1(v1:u32, v2:str) -> (u64, u32, str) { | ||
let id = ::bytes_hooks::empty(); | ||
let id = ::bytes_hooks::append_u32(id, v); | ||
let (id, v32) = ::bytes_hooks::decode_u32(id); | ||
let (id, vstr) = ::bytes_hooks::decode_str(id); | ||
(id, v32, vstr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
```k | ||
|
||
requires "hooks/bytes.md" | ||
|
||
module UKM-CONFIGURATION | ||
imports UKM-HOOKS-BYTES-CONFIGURATION | ||
configuration | ||
<ukm> .K </ukm> | ||
<ukm> | ||
<ukm-bytes/> | ||
</ukm> | ||
endmodule | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
```k | ||
|
||
requires "execution/syntax.md" | ||
requires "hooks.md" | ||
|
||
module UKM-EXECUTION | ||
imports private UKM-HOOKS | ||
endmodule | ||
|
||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
```k | ||
|
||
requires "hooks/bytes.md" | ||
|
||
module UKM-HOOKS | ||
imports private UKM-HOOKS-BYTES | ||
endmodule | ||
|
||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to uncomment this as soon as we can parse ukm.rs.