Compare commits
7 Commits
main
...
0af4079832
Author | SHA1 | Date | |
---|---|---|---|
|
0af4079832 | ||
|
f4ab3acfd6 | ||
|
8686bd5154 | ||
|
a1f0557fa0 | ||
|
136b2d733d | ||
|
cf36dd20fd | ||
|
9c1b30cad7 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,5 +7,3 @@ target/
|
||||
|
||||
data_*_flex.json
|
||||
data_*_haveranswer.f64
|
||||
.direnv/
|
||||
result
|
||||
|
@@ -1,4 +1,4 @@
|
||||
steps:
|
||||
pipeline:
|
||||
echo:
|
||||
image: alpine
|
||||
commands:
|
@@ -1,18 +1,17 @@
|
||||
steps:
|
||||
pipeline:
|
||||
build:
|
||||
image: nixos/nix:2.28.5
|
||||
image: nixos/nix
|
||||
commands:
|
||||
- echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf
|
||||
# Lint
|
||||
- nix develop --command cargo -- fmt --all -- --check
|
||||
- nix develop --command cargo -- clippy -- -D warnings -W clippy::must_use_candidate
|
||||
- nix develop .#ci --command nixpkgs-fmt --check .
|
||||
- nix develop .#ci --command alejandra -- --check .
|
||||
- nix develop .#ci --command markdown-link-check README.md
|
||||
# Test
|
||||
- nix develop --command cargo test --verbose --release
|
||||
- nix develop --command cargo test --verbose
|
||||
# Run through Nix
|
||||
- nix flake check
|
||||
- nix build
|
||||
- nix run . -- computer_enhance/perfaware/part1/listing_0038_many_register_mov computer_enhance/perfaware/part1/listing_0038_many_register_mov.asm
|
||||
- nix run . -- computer_enhance/perfaware/part1/listing_0055_challenge_rectangle computer_enhance/perfaware/part1/listing_0055_challenge_rectangle.asm
|
||||
@@ -20,7 +19,5 @@ steps:
|
||||
- nix develop . --command cargo run --release --bin generator --package generator -- 12345 100
|
||||
- nix develop . --command cargo run --release --bin haversine-app --package haversine-app -- data_100_flex.json data_100_haveranswer.f64
|
||||
|
||||
when:
|
||||
- event: "push"
|
||||
evaluate: 'CI_COMMIT_BRANCH == CI_REPO_DEFAULT_BRANCH'
|
||||
- event: "pull_request"
|
||||
when:
|
||||
evaluate: '(CI_BUILD_EVENT == "push" && CI_COMMIT_BRANCH == CI_REPO_DEFAULT_BRANCH) || (CI_BUILD_EVENT == "pull_request")'
|
282
Cargo.lock
generated
282
Cargo.lock
generated
@@ -1,62 +1,61 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.20"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192"
|
||||
checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"is-terminal",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.11"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
|
||||
checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.7"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
||||
checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.4"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
|
||||
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.10"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
|
||||
checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.4.2"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1"
|
||||
checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e"
|
||||
dependencies = [
|
||||
"derive_arbitrary",
|
||||
]
|
||||
@@ -71,44 +70,58 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.3"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.47"
|
||||
version = "4.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7eac00902d9d136acd712710d71823fb8ac8004ca445a89e73a41d45aa712931"
|
||||
checksum = "b4ed2379f8603fa2b7509891660e802b88c70a79a6427a70abb5968054de2c28"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.47"
|
||||
version = "4.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ad9bbf750e73b5884fb8a211a9424a1906c1e156724260fdae972f31d70e1d6"
|
||||
checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.47"
|
||||
version = "4.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
|
||||
checksum = "59e9ef9a08ee1c0e1f2e162121665ac45ac3783b0f897db7244ae75ad9a8f65b"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@@ -118,36 +131,57 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.5"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
|
||||
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.4"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "const_panic"
|
||||
version = "0.2.14"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb8a602185c3c95b52f86dc78e55a6df9a287a7a93ddbcf012509930880cf879"
|
||||
checksum = "6051f239ecec86fde3410901ab7860d458d160371533842974fc61f96d15879b"
|
||||
dependencies = [
|
||||
"typewit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_arbitrary"
|
||||
version = "1.4.2"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a"
|
||||
checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
|
||||
dependencies = [
|
||||
"errno-dragonfly",
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno-dragonfly"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generator"
|
||||
version = "0.1.0"
|
||||
@@ -161,9 +195,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.16"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||
checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@@ -187,15 +221,38 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
name = "hermit-abi"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"io-lifetimes",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json"
|
||||
@@ -203,15 +260,21 @@ version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.175"
|
||||
version = "0.2.144"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
|
||||
checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.5"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
@@ -230,34 +293,31 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.1"
|
||||
name = "once_cell"
|
||||
version = "1.17.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
|
||||
checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.21"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||
dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.101"
|
||||
version = "1.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
||||
checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.40"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -292,6 +352,20 @@ dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.37.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sim-wrapper"
|
||||
version = "0.1.0"
|
||||
@@ -312,15 +386,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.106"
|
||||
version = "2.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
||||
checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -329,15 +403,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "typewit"
|
||||
version = "1.14.1"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c98488b93df24b7c794d6a58c4198d7a2abde676324beaca84f7fb5b39c0811"
|
||||
checksum = "7c52b4cb7830f995903b2fcff3f523d21efc1c11f6c1596dd544b7925a64ff56"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
|
||||
|
||||
[[package]]
|
||||
name = "utf8-read"
|
||||
@@ -347,42 +421,34 @@ checksum = "fb566ac06e11c3f13872ebcb0e72ea5f97f0f65a16f45048d0adea21edc28018"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.60.2"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.53.3"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91"
|
||||
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
@@ -391,68 +457,42 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.53.0"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764"
|
||||
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.53.0"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c"
|
||||
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.53.0"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.53.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11"
|
||||
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.53.0"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d"
|
||||
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.53.0"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba"
|
||||
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.53.0"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57"
|
||||
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.53.0"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
||||
|
@@ -7,14 +7,6 @@ members = [
|
||||
"json",
|
||||
"haversine-app"
|
||||
]
|
||||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
edition = "2024"
|
||||
|
||||
[workspace.metadata.crane]
|
||||
name = "performance_aware_programming"
|
||||
version = "0.1.0"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
@@ -9,3 +9,4 @@ It does, however, conform to all Casey's provided test cases except the "complet
|
||||
The code in this repo is MIT-licensed.
|
||||
|
||||
However, note that the included submodule is licensed *very* restrictively, and you might not even be permitted to clone it.
|
||||
askldfjl
|
||||
|
98
flake.lock
generated
98
flake.lock
generated
@@ -1,30 +1,44 @@
|
||||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"crate2nix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1757183466,
|
||||
"narHash": "sha256-kTdCCMuRE+/HNHES5JYsbRHmgtr+l9mOtf5dpcMppVc=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "d599ae4847e7f87603e7082d73ca673aa93c916d",
|
||||
"lastModified": 1678820090,
|
||||
"narHash": "sha256-4FFeonajXNqiSP0PqUlC1wmTyPC8SX6SthEvgRjMupw=",
|
||||
"owner": "kolloch",
|
||||
"repo": "crate2nix",
|
||||
"rev": "4fd826e37bec90dfe26ca16cb6e632c617cc7c0d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"owner": "kolloch",
|
||||
"repo": "crate2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -35,11 +49,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1757068644,
|
||||
"narHash": "sha256-NOrUtIhTkIIumj1E/Rsv1J37Yi3xGStISEo8tZm3KW4=",
|
||||
"lastModified": 1679705136,
|
||||
"narHash": "sha256-MDlZUR7wJ3PlPtqwwoGQr3euNOe0vdSSteVVOef7tBY=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9",
|
||||
"rev": "8f40f2f90b9c9032d1b824442cfbbe0dbabd0dbd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -49,26 +63,42 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1679734080,
|
||||
"narHash": "sha256-z846xfGLlon6t9lqUzlNtBOmsgQLQIZvR6Lt2dImk1M=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dbf5322e93bcc6cfc52268367a8ad21c09d76fea",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-utils": "flake-utils",
|
||||
"crate2nix": "crate2nix",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1757298987,
|
||||
"narHash": "sha256-yuFSw6fpfjPtVMmym51ozHYpJQ7SzVOTkk7tUv2JA0U=",
|
||||
"lastModified": 1679106165,
|
||||
"narHash": "sha256-03Opt2yu4E/AIFjvlgib0/nhMn6B4B/t/nvwS2bzOGw=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "cfd63776bde44438ff2936f0c9194c79dd407a5f",
|
||||
"rev": "7313c06ac334d6262ddfe30a38b3abc3da6bd565",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -77,18 +107,18 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"lastModified": 1678901627,
|
||||
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
|
187
flake.nix
187
flake.nix
@@ -2,121 +2,110 @@
|
||||
description = "Coursework for Performance-Aware Programming";
|
||||
|
||||
inputs = {
|
||||
self.submodules = true;
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
crate2nix = {
|
||||
url = "github:kolloch/crate2nix";
|
||||
flake = false;
|
||||
};
|
||||
flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
crane.url = "github:ipetkov/crane";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
utils,
|
||||
rust-overlay,
|
||||
crate2nix,
|
||||
...
|
||||
}: let
|
||||
name = "sim-wrapper";
|
||||
in
|
||||
utils.lib.eachDefaultSystem
|
||||
(
|
||||
system: let
|
||||
# Imports
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
(self: super: {
|
||||
# Because rust-overlay bundles multiple rust packages into one
|
||||
# derivation, specify that mega-bundle here, so that crate2nix
|
||||
# will use them automatically.
|
||||
rustc = self.rust-bin.nightly.latest.default;
|
||||
cargo = self.rust-bin.nightly.latest.default;
|
||||
})
|
||||
];
|
||||
};
|
||||
inherit
|
||||
(import "${crate2nix}/tools.nix" {inherit pkgs;})
|
||||
generatedCargoNix
|
||||
;
|
||||
|
||||
rustToolchain = pkgs.rust-bin.nightly.latest.default;
|
||||
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
||||
|
||||
# Common build inputs for all derivations
|
||||
commonArgs = {
|
||||
version = "0.1.0"; # Set explicitly to avoid warnings
|
||||
src = pkgs.lib.cleanSourceWith {
|
||||
# Create the cargo2nix project
|
||||
project =
|
||||
pkgs.callPackage
|
||||
(generatedCargoNix {
|
||||
inherit name;
|
||||
src = ./.;
|
||||
name = "source";
|
||||
filter = path: type: (builtins.match ".*json$" path != null || pkgs.lib.hasInfix "/computer_enhance" path || craneLib.filterCargoSources path type);
|
||||
})
|
||||
{
|
||||
# Individual crate overrides go here
|
||||
# Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50
|
||||
defaultCrateOverrides =
|
||||
pkgs.defaultCrateOverrides
|
||||
// {
|
||||
# The app crate itself is overriden here. Typically we
|
||||
# configure non-Rust dependencies (see below) here.
|
||||
${name} = oldAttrs:
|
||||
{
|
||||
inherit buildInputs nativeBuildInputs;
|
||||
}
|
||||
// buildEnvVars;
|
||||
};
|
||||
};
|
||||
strictDeps = true;
|
||||
|
||||
buildInputs = [
|
||||
pkgs.openssl
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.pkg-config
|
||||
];
|
||||
# Configuration for the non-Rust dependencies
|
||||
buildInputs = with pkgs; [openssl.dev];
|
||||
nativeBuildInputs = with pkgs; [rustc cargo pkgconfig];
|
||||
buildEnvVars = {
|
||||
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
||||
};
|
||||
in rec {
|
||||
packages.${name} = project.workspaceMembers.${name}.build;
|
||||
|
||||
# Build just the cargo dependencies
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
# `nix build`
|
||||
defaultPackage = packages.${name};
|
||||
|
||||
# Build the actual package
|
||||
sim-wrapper = craneLib.buildPackage (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
default = sim-wrapper;
|
||||
sim-wrapper = sim-wrapper;
|
||||
};
|
||||
|
||||
apps = {
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${sim-wrapper}/bin/sim-wrapper";
|
||||
meta = sim-wrapper.meta;
|
||||
};
|
||||
sim-wrapper = {
|
||||
type = "app";
|
||||
program = "${sim-wrapper}/bin/sim-wrapper";
|
||||
meta = sim-wrapper.meta;
|
||||
};
|
||||
# `nix run`
|
||||
apps.${name} = utils.lib.mkApp {
|
||||
inherit name;
|
||||
drv = packages.${name};
|
||||
};
|
||||
defaultApp = apps.${name};
|
||||
|
||||
# `nix develop`
|
||||
devShells = {
|
||||
default = craneLib.devShell {
|
||||
# Inherit the build inputs from commonArgs
|
||||
buildInputs = commonArgs.buildInputs;
|
||||
nativeBuildInputs = commonArgs.nativeBuildInputs;
|
||||
|
||||
# Additional dev tools
|
||||
packages = [
|
||||
rustToolchain
|
||||
pkgs.rust-analyzer
|
||||
];
|
||||
|
||||
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
|
||||
};
|
||||
|
||||
ci = pkgs.mkShell {
|
||||
buildInputs = commonArgs.buildInputs ++ [
|
||||
pkgs.nodePackages.markdown-link-check
|
||||
pkgs.nixpkgs-fmt
|
||||
rustToolchain
|
||||
];
|
||||
|
||||
nativeBuildInputs = commonArgs.nativeBuildInputs;
|
||||
|
||||
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
|
||||
};
|
||||
ci =
|
||||
pkgs.mkShell {
|
||||
inherit nativeBuildInputs;
|
||||
buildInputs = [pkgs.nodePackages.markdown-link-check pkgs.alejandra] ++ buildInputs;
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
}
|
||||
// buildEnvVars;
|
||||
default =
|
||||
pkgs.mkShell
|
||||
{
|
||||
inherit buildInputs nativeBuildInputs;
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
}
|
||||
// buildEnvVars;
|
||||
};
|
||||
|
||||
# Optional: add checks for CI
|
||||
checks = {
|
||||
inherit sim-wrapper;
|
||||
|
||||
# Run cargo fmt check
|
||||
fmt = craneLib.cargoFmt {
|
||||
inherit (commonArgs) src;
|
||||
};
|
||||
|
||||
# Run clippy
|
||||
clippy = craneLib.cargoClippy (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||
});
|
||||
|
||||
# Run tests
|
||||
tests = craneLib.cargoTest (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "generator"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use clap::{Parser, ValueEnum, builder::PossibleValue};
|
||||
use clap::{builder::PossibleValue, Parser, ValueEnum};
|
||||
use haversine::haversine::{CoordinatePair, HaversineData};
|
||||
use haversine::{distance, earth};
|
||||
use json::json_object::JsonValue;
|
||||
@@ -69,9 +69,9 @@ fn write_json(data: &HaversineData, json_filename: &str) {
|
||||
let mut is_first = true;
|
||||
for point in data.pairs.iter() {
|
||||
if !is_first {
|
||||
writer.write_all(b",").unwrap();
|
||||
writer.write_all(&[b',']).unwrap();
|
||||
}
|
||||
writer.write_all(b"{").unwrap();
|
||||
writer.write_all(&[b'{']).unwrap();
|
||||
writer
|
||||
.write_all(
|
||||
format!(
|
||||
@@ -81,7 +81,7 @@ fn write_json(data: &HaversineData, json_filename: &str) {
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
writer.write_all(b"}").unwrap();
|
||||
writer.write_all(&[b'}']).unwrap();
|
||||
is_first = false;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,11 @@ where
|
||||
let x1 = range.sample(rng);
|
||||
let x2 = range.sample(rng);
|
||||
|
||||
if x1 < x2 { (x1, x2) } else { (x2, x1) }
|
||||
if x1 < x2 {
|
||||
(x1, x2)
|
||||
} else {
|
||||
(x2, x1)
|
||||
}
|
||||
}
|
||||
|
||||
fn sample_point<R, D1, D2>(rng: &mut R, x_range: D1, y_range: D2) -> CoordinatePair
|
||||
|
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "haversine-app"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@@ -18,7 +18,7 @@ struct Args {
|
||||
fn read_answer(binary_filename: &str) -> (Vec<f64>, f64) {
|
||||
let mut file = File::open(binary_filename).unwrap();
|
||||
let file_size = file.metadata().unwrap().len();
|
||||
if !file_size.is_multiple_of(8) {
|
||||
if file_size % 8 != 0 {
|
||||
panic!(
|
||||
"Malformed input file of size {} is not a multiple of 8",
|
||||
file_size
|
||||
@@ -82,10 +82,7 @@ fn haversine_sum(v: &[CoordinatePair], reference: &[f64]) -> f64 {
|
||||
for (count, pair) in v.iter().enumerate() {
|
||||
let computed = distance::naive(pair, earth::RADIUS);
|
||||
if computed != reference[count] {
|
||||
println!(
|
||||
"Different! At index {}, received pair: {:?}, computed distance {computed}, expected {}",
|
||||
count, pair, reference[count]
|
||||
)
|
||||
println!("Different! At index {}, received pair: {:?}, computed distance {computed}, expected {}", count, pair, reference[count])
|
||||
}
|
||||
answer =
|
||||
((1.0 - (1.0 / (count as f64 + 1.0))) * answer) + (computed / (count as f64 + 1.0));
|
||||
|
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "haversine"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "json"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
|
||||
|
@@ -603,7 +603,7 @@ mod test {
|
||||
panic!("oh no")
|
||||
}
|
||||
if let JsonValue::Boolean(is_student) = obj.values.get("isStudent").unwrap() {
|
||||
assert!(!(*is_student))
|
||||
assert_eq!(*is_student, false)
|
||||
} else {
|
||||
panic!("oh no")
|
||||
}
|
||||
@@ -821,7 +821,7 @@ mod test {
|
||||
// Rust chose the float immediately above 1.23e-6; my computation
|
||||
// chose the float immediately below.
|
||||
let delta = expected - *actual;
|
||||
assert_eq!(delta, 2.117_582_368_135_751E-22);
|
||||
assert_eq!(delta, 2.1175823681357508E-22);
|
||||
}
|
||||
e => {
|
||||
panic!("bad value: {:?}", e)
|
||||
@@ -900,7 +900,7 @@ mod test {
|
||||
fn borderline_example() {
|
||||
let (parsed, remaining) = JsonValue::parse(&mut "-28.5175025263690110".chars()).unwrap();
|
||||
assert_eq!(remaining, None);
|
||||
let expected = -28.517_502_526_369_01;
|
||||
let expected = -28.5175025263690110;
|
||||
let actual = parsed.as_number();
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
@@ -920,7 +920,7 @@ mod test {
|
||||
#[test]
|
||||
fn haversine_example() {
|
||||
let s = include_str!("example.json");
|
||||
let parsed = parse_object(s);
|
||||
let parsed = parse_object(&s);
|
||||
let o = parsed.values.get("pairs").unwrap().as_array();
|
||||
assert_eq!(o.len(), 20);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "sim-wrapper"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@@ -43,10 +43,10 @@ where
|
||||
.filter(|i| !matches!(i, Instruction::Trivia(_)));
|
||||
|
||||
for i1 in without_trivia_1 {
|
||||
if let Some(i2) = without_trivia_2.next()
|
||||
&& i1 != i2
|
||||
{
|
||||
return false;
|
||||
if let Some(i2) = without_trivia_2.next() {
|
||||
if i1 != i2 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,18 +90,12 @@ fn verify_consistency(pre_compiled: &Vec<u8>, asm: &str) {
|
||||
let disassembled = Program::of_bytes(pre_compiled.iter().cloned());
|
||||
|
||||
if disassembled != compiled {
|
||||
println!(
|
||||
"Disassembled and compiled versions do not produce the same bytes. From disassembly:\n{}\nFrom assembling the input asm:\n{}",
|
||||
disassembled, compiled
|
||||
);
|
||||
println!("Disassembled and compiled versions do not produce the same bytes. From disassembly:\n{}\nFrom assembling the input asm:\n{}", disassembled, compiled);
|
||||
std::process::exit(3)
|
||||
}
|
||||
|
||||
if !program_equal_ignoring_labels(&disassembled, &compiled) {
|
||||
println!(
|
||||
"Program failed to disassemble back to the compiled version. Compiled:\n{}\nDisassembled again:\n{}",
|
||||
compiled, disassembled
|
||||
);
|
||||
println!("Program failed to disassemble back to the compiled version. Compiled:\n{}\nDisassembled again:\n{}", compiled, disassembled);
|
||||
std::process::exit(4)
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "sim_8086"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
use nom::{
|
||||
IResult,
|
||||
branch::alt,
|
||||
bytes::complete::{is_not, tag},
|
||||
character::complete::{
|
||||
@@ -9,6 +8,7 @@ use nom::{
|
||||
error::FromExternalError,
|
||||
multi::{many0, many1},
|
||||
sequence::{delimited, preceded, separated_pair, terminated, tuple},
|
||||
IResult,
|
||||
};
|
||||
|
||||
use crate::boolean_instruction::{
|
||||
@@ -62,11 +62,12 @@ enum OffsetTag {
|
||||
None,
|
||||
}
|
||||
|
||||
fn bracketed<'a, F, O, E>(inner: F) -> impl FnMut(&'a str) -> IResult<&'a str, (OffsetTag, O), E>
|
||||
fn bracketed<'a, F, O, E: nom::error::ParseError<&'a str>>(
|
||||
inner: F,
|
||||
) -> impl FnMut(&'a str) -> IResult<&'a str, (OffsetTag, O), E>
|
||||
where
|
||||
F: FnMut(&'a str) -> IResult<&'a str, O, E>,
|
||||
E: FromExternalError<&'a str, ()>,
|
||||
E: nom::error::ParseError<&'a str>,
|
||||
{
|
||||
map_res(
|
||||
tuple((
|
||||
@@ -202,9 +203,10 @@ fn literal_absolute_u8(input: &str) -> IResult<&str, u8> {
|
||||
Err(())
|
||||
}
|
||||
})
|
||||
.try_fold(0u8, |acc, new| match (acc, new) {
|
||||
.fold(Ok(0u8), |acc, new| match (acc, new) {
|
||||
(Ok(acc), Ok(new)) => Ok(acc * 16 + new),
|
||||
(_, Err(())) => Err(()),
|
||||
(acc, Ok(new)) => Ok(acc * 16 + new),
|
||||
(Err(()), _) => Err(()),
|
||||
})
|
||||
}),
|
||||
map_res(digit1, str::parse::<u8>),
|
||||
@@ -225,9 +227,10 @@ fn literal_absolute_u16(input: &str) -> IResult<&str, u16> {
|
||||
Err(())
|
||||
}
|
||||
})
|
||||
.try_fold(0u16, |acc, new| match (acc, new) {
|
||||
.fold(Ok(0u16), |acc, new| match (acc, new) {
|
||||
(Ok(acc), Ok(new)) => Ok(acc * 16 + new),
|
||||
(_, Err(())) => Err(()),
|
||||
(acc, Ok(new)) => Ok(acc * 16 + new),
|
||||
(Err(()), _) => Err(()),
|
||||
})
|
||||
}),
|
||||
map_res(digit1, str::parse::<u16>),
|
||||
|
@@ -111,12 +111,12 @@ impl EffectiveAddress {
|
||||
if mode == 3 {
|
||||
panic!("we don't handle this case, you need to do it manually to get a register")
|
||||
}
|
||||
let source_dest = if rm.is_multiple_of(2) {
|
||||
let source_dest = if rm % 2 == 0 {
|
||||
SourceDest::Source
|
||||
} else {
|
||||
SourceDest::Dest
|
||||
};
|
||||
let base = if (rm / 2).is_multiple_of(2) {
|
||||
let base = if (rm / 2) % 2 == 0 {
|
||||
Base::Bx
|
||||
} else {
|
||||
Base::Bp
|
||||
|
@@ -59,7 +59,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl Instruction<&str> {
|
||||
impl<'a> Instruction<&'a str> {
|
||||
#[must_use]
|
||||
pub fn to_bytes(&self) -> Vec<u8> {
|
||||
match self {
|
||||
|
@@ -37,10 +37,10 @@ where
|
||||
}
|
||||
let mut labels = HashMap::new();
|
||||
for (counter, instruction) in self.instructions.as_ref().iter().enumerate() {
|
||||
if let Instruction::Trivia(TriviaInstruction::Label(s)) = instruction
|
||||
&& let Some(s) = labels.insert(s.trim(), counter)
|
||||
{
|
||||
panic!("same label twice: {}", s)
|
||||
if let Instruction::Trivia(TriviaInstruction::Label(s)) = instruction {
|
||||
if let Some(s) = labels.insert(s.trim(), counter) {
|
||||
panic!("same label twice: {}", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -94,17 +94,17 @@ mod test_program {
|
||||
{
|
||||
let disassembled = Program::of_bytes(input_bytecode.as_ref().iter().cloned());
|
||||
|
||||
let (remaining, pre_compiled) = assembly::program(input_asm).unwrap();
|
||||
let (remaining, pre_compiled) = assembly::program(&input_asm).unwrap();
|
||||
assert_eq!(remaining.trim(), "");
|
||||
|
||||
let disassembled = disassembled
|
||||
.instructions
|
||||
.iter()
|
||||
.filter(|i| !matches!(i, Instruction::Trivia(_)));
|
||||
let mut compiled = pre_compiled
|
||||
.instructions
|
||||
.iter()
|
||||
.filter(|i| !matches!(i, Instruction::Trivia(_)));
|
||||
let disassembled = disassembled.instructions.iter().filter(|i| match i {
|
||||
Instruction::Trivia(_) => false,
|
||||
_ => true,
|
||||
});
|
||||
let mut compiled = pre_compiled.instructions.iter().filter(|i| match i {
|
||||
Instruction::Trivia(_) => false,
|
||||
_ => true,
|
||||
});
|
||||
|
||||
let mut is_different = false;
|
||||
|
||||
@@ -119,7 +119,8 @@ mod test_program {
|
||||
{
|
||||
println!(
|
||||
"Different instruction. From disassembly: {dis} ({:?}). From our compilation: {compiled} ({:?}).",
|
||||
dis_bytes, compiled_bytes
|
||||
dis_bytes,
|
||||
compiled_bytes
|
||||
);
|
||||
is_different = true;
|
||||
}
|
||||
@@ -133,7 +134,7 @@ mod test_program {
|
||||
}
|
||||
}
|
||||
|
||||
for compiled in compiled {
|
||||
while let Some(compiled) = compiled.next() {
|
||||
println!(
|
||||
"Extra instruction from compilation: {compiled} ({:?})",
|
||||
compiled.to_bytes()
|
||||
@@ -142,9 +143,7 @@ mod test_program {
|
||||
}
|
||||
|
||||
if is_different {
|
||||
panic!(
|
||||
"Disassembling input bytecode produced a different program from compiling the input asm."
|
||||
)
|
||||
panic!("Disassembling input bytecode produced a different program from compiling the input asm.")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user