Rotth is a stack based concatenative language highly inspired by Porth
0

Configure Feed

Select the types of activity you want to include in your feed.

Maxi reproducible example

Ivan Chinenov (Mar 21, 2022, 11:11 PM +0300) 6f4def00 8d94f284

+420 -2622
output.txt

This is a binary file and will not be displayed.

-987
rotth-lsp/Cargo.lock
··· 1 - # This file is automatically @generated by Cargo. 2 - # It is not intended for manual editing. 3 - version = 3 4 - 5 - [[package]] 6 - name = "ahash" 7 - version = "0.7.6" 8 - source = "registry+https://github.com/rust-lang/crates.io-index" 9 - checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 10 - dependencies = [ 11 - "getrandom", 12 - "once_cell", 13 - "version_check", 14 - ] 15 - 16 - [[package]] 17 - name = "ariadne" 18 - version = "0.1.5" 19 - source = "registry+https://github.com/rust-lang/crates.io-index" 20 - checksum = "f1cb2a2046bea8ce5e875551f5772024882de0b540c7f93dfc5d6cf1ca8b030c" 21 - dependencies = [ 22 - "yansi", 23 - ] 24 - 25 - [[package]] 26 - name = "async-trait" 27 - version = "0.1.52" 28 - source = "registry+https://github.com/rust-lang/crates.io-index" 29 - checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" 30 - dependencies = [ 31 - "proc-macro2", 32 - "quote", 33 - "syn", 34 - ] 35 - 36 - [[package]] 37 - name = "atty" 38 - version = "0.2.14" 39 - source = "registry+https://github.com/rust-lang/crates.io-index" 40 - checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 41 - dependencies = [ 42 - "hermit-abi", 43 - "libc", 44 - "winapi", 45 - ] 46 - 47 - [[package]] 48 - name = "auto_impl" 49 - version = "0.5.0" 50 - source = "registry+https://github.com/rust-lang/crates.io-index" 51 - checksum = "7862e21c893d65a1650125d157eaeec691439379a1cee17ee49031b79236ada4" 52 - dependencies = [ 53 - "proc-macro-error", 54 - "proc-macro2", 55 - "quote", 56 - "syn", 57 - ] 58 - 59 - [[package]] 60 - name = "autocfg" 61 - version = "1.1.0" 62 - source = "registry+https://github.com/rust-lang/crates.io-index" 63 - checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 64 - 65 - [[package]] 66 - name = "bitflags" 67 - version = "1.3.2" 68 - source = "registry+https://github.com/rust-lang/crates.io-index" 69 - checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 70 - 71 - [[package]] 72 - name = "bytes" 73 - version = "1.1.0" 74 - source = "registry+https://github.com/rust-lang/crates.io-index" 75 - checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" 76 - 77 - [[package]] 78 - name = "cc" 79 - version = "1.0.73" 80 - source = "registry+https://github.com/rust-lang/crates.io-index" 81 - checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" 82 - 83 - [[package]] 84 - name = "cfg-if" 85 - version = "1.0.0" 86 - source = "registry+https://github.com/rust-lang/crates.io-index" 87 - checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 88 - 89 - [[package]] 90 - name = "chumsky" 91 - version = "0.8.0" 92 - source = "git+https://github.com/zesterer/chumsky.git#96d246a93f182bff6bb89caaba35d357e92bbd0f" 93 - dependencies = [ 94 - "hashbrown", 95 - "stacker", 96 - ] 97 - 98 - [[package]] 99 - name = "clap" 100 - version = "3.1.6" 101 - source = "registry+https://github.com/rust-lang/crates.io-index" 102 - checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123" 103 - dependencies = [ 104 - "atty", 105 - "bitflags", 106 - "clap_derive", 107 - "indexmap", 108 - "lazy_static", 109 - "os_str_bytes", 110 - "strsim", 111 - "termcolor", 112 - "textwrap", 113 - ] 114 - 115 - [[package]] 116 - name = "clap_derive" 117 - version = "3.1.4" 118 - source = "registry+https://github.com/rust-lang/crates.io-index" 119 - checksum = "da95d038ede1a964ce99f49cbe27a7fb538d1da595e4b4f70b8c8f338d17bf16" 120 - dependencies = [ 121 - "heck", 122 - "proc-macro-error", 123 - "proc-macro2", 124 - "quote", 125 - "syn", 126 - ] 127 - 128 - [[package]] 129 - name = "dashmap" 130 - version = "5.1.0" 131 - source = "registry+https://github.com/rust-lang/crates.io-index" 132 - checksum = "c0834a35a3fce649144119e18da2a4d8ed12ef3862f47183fd46f625d072d96c" 133 - dependencies = [ 134 - "cfg-if", 135 - "num_cpus", 136 - "parking_lot", 137 - ] 138 - 139 - [[package]] 140 - name = "fnv" 141 - version = "1.0.7" 142 - source = "registry+https://github.com/rust-lang/crates.io-index" 143 - checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 144 - 145 - [[package]] 146 - name = "form_urlencoded" 147 - version = "1.0.1" 148 - source = "registry+https://github.com/rust-lang/crates.io-index" 149 - checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 150 - dependencies = [ 151 - "matches", 152 - "percent-encoding", 153 - ] 154 - 155 - [[package]] 156 - name = "futures" 157 - version = "0.3.21" 158 - source = "registry+https://github.com/rust-lang/crates.io-index" 159 - checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" 160 - dependencies = [ 161 - "futures-channel", 162 - "futures-core", 163 - "futures-io", 164 - "futures-sink", 165 - "futures-task", 166 - "futures-util", 167 - ] 168 - 169 - [[package]] 170 - name = "futures-channel" 171 - version = "0.3.21" 172 - source = "registry+https://github.com/rust-lang/crates.io-index" 173 - checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" 174 - dependencies = [ 175 - "futures-core", 176 - "futures-sink", 177 - ] 178 - 179 - [[package]] 180 - name = "futures-core" 181 - version = "0.3.21" 182 - source = "registry+https://github.com/rust-lang/crates.io-index" 183 - checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" 184 - 185 - [[package]] 186 - name = "futures-io" 187 - version = "0.3.21" 188 - source = "registry+https://github.com/rust-lang/crates.io-index" 189 - checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" 190 - 191 - [[package]] 192 - name = "futures-macro" 193 - version = "0.3.21" 194 - source = "registry+https://github.com/rust-lang/crates.io-index" 195 - checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" 196 - dependencies = [ 197 - "proc-macro2", 198 - "quote", 199 - "syn", 200 - ] 201 - 202 - [[package]] 203 - name = "futures-sink" 204 - version = "0.3.21" 205 - source = "registry+https://github.com/rust-lang/crates.io-index" 206 - checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" 207 - 208 - [[package]] 209 - name = "futures-task" 210 - version = "0.3.21" 211 - source = "registry+https://github.com/rust-lang/crates.io-index" 212 - checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" 213 - 214 - [[package]] 215 - name = "futures-util" 216 - version = "0.3.21" 217 - source = "registry+https://github.com/rust-lang/crates.io-index" 218 - checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" 219 - dependencies = [ 220 - "futures-channel", 221 - "futures-core", 222 - "futures-io", 223 - "futures-macro", 224 - "futures-sink", 225 - "futures-task", 226 - "memchr", 227 - "pin-project-lite", 228 - "pin-utils", 229 - "slab", 230 - ] 231 - 232 - [[package]] 233 - name = "getrandom" 234 - version = "0.2.5" 235 - source = "registry+https://github.com/rust-lang/crates.io-index" 236 - checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" 237 - dependencies = [ 238 - "cfg-if", 239 - "libc", 240 - "wasi", 241 - ] 242 - 243 - [[package]] 244 - name = "hashbrown" 245 - version = "0.11.2" 246 - source = "registry+https://github.com/rust-lang/crates.io-index" 247 - checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 248 - dependencies = [ 249 - "ahash", 250 - ] 251 - 252 - [[package]] 253 - name = "heck" 254 - version = "0.4.0" 255 - source = "registry+https://github.com/rust-lang/crates.io-index" 256 - checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 257 - 258 - [[package]] 259 - name = "hermit-abi" 260 - version = "0.1.19" 261 - source = "registry+https://github.com/rust-lang/crates.io-index" 262 - checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 263 - dependencies = [ 264 - "libc", 265 - ] 266 - 267 - [[package]] 268 - name = "httparse" 269 - version = "1.6.0" 270 - source = "registry+https://github.com/rust-lang/crates.io-index" 271 - checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" 272 - 273 - [[package]] 274 - name = "idna" 275 - version = "0.2.3" 276 - source = "registry+https://github.com/rust-lang/crates.io-index" 277 - checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 278 - dependencies = [ 279 - "matches", 280 - "unicode-bidi", 281 - "unicode-normalization", 282 - ] 283 - 284 - [[package]] 285 - name = "indexmap" 286 - version = "1.8.0" 287 - source = "registry+https://github.com/rust-lang/crates.io-index" 288 - checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" 289 - dependencies = [ 290 - "autocfg", 291 - "hashbrown", 292 - ] 293 - 294 - [[package]] 295 - name = "indoc" 296 - version = "1.0.4" 297 - source = "registry+https://github.com/rust-lang/crates.io-index" 298 - checksum = "e7906a9fababaeacb774f72410e497a1d18de916322e33797bb2cd29baa23c9e" 299 - dependencies = [ 300 - "unindent", 301 - ] 302 - 303 - [[package]] 304 - name = "itoa" 305 - version = "1.0.1" 306 - source = "registry+https://github.com/rust-lang/crates.io-index" 307 - checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" 308 - 309 - [[package]] 310 - name = "lazy_static" 311 - version = "1.4.0" 312 - source = "registry+https://github.com/rust-lang/crates.io-index" 313 - checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 314 - 315 - [[package]] 316 - name = "libc" 317 - version = "0.2.119" 318 - source = "registry+https://github.com/rust-lang/crates.io-index" 319 - checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" 320 - 321 - [[package]] 322 - name = "lock_api" 323 - version = "0.4.6" 324 - source = "registry+https://github.com/rust-lang/crates.io-index" 325 - checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" 326 - dependencies = [ 327 - "scopeguard", 328 - ] 329 - 330 - [[package]] 331 - name = "log" 332 - version = "0.4.14" 333 - source = "registry+https://github.com/rust-lang/crates.io-index" 334 - checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 335 - dependencies = [ 336 - "cfg-if", 337 - ] 338 - 339 - [[package]] 340 - name = "lsp-types" 341 - version = "0.92.0" 342 - source = "registry+https://github.com/rust-lang/crates.io-index" 343 - checksum = "e8a69d4142d51b208c9fc3cea68b1a7fcef30354e7aa6ccad07250fd8430fc76" 344 - dependencies = [ 345 - "bitflags", 346 - "serde", 347 - "serde_json", 348 - "serde_repr", 349 - "url", 350 - ] 351 - 352 - [[package]] 353 - name = "matches" 354 - version = "0.1.9" 355 - source = "registry+https://github.com/rust-lang/crates.io-index" 356 - checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" 357 - 358 - [[package]] 359 - name = "memchr" 360 - version = "2.4.1" 361 - source = "registry+https://github.com/rust-lang/crates.io-index" 362 - checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 363 - 364 - [[package]] 365 - name = "mio" 366 - version = "0.8.0" 367 - source = "registry+https://github.com/rust-lang/crates.io-index" 368 - checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" 369 - dependencies = [ 370 - "libc", 371 - "log", 372 - "miow", 373 - "ntapi", 374 - "winapi", 375 - ] 376 - 377 - [[package]] 378 - name = "miow" 379 - version = "0.3.7" 380 - source = "registry+https://github.com/rust-lang/crates.io-index" 381 - checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" 382 - dependencies = [ 383 - "winapi", 384 - ] 385 - 386 - [[package]] 387 - name = "ntapi" 388 - version = "0.3.7" 389 - source = "registry+https://github.com/rust-lang/crates.io-index" 390 - checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" 391 - dependencies = [ 392 - "winapi", 393 - ] 394 - 395 - [[package]] 396 - name = "num_cpus" 397 - version = "1.13.1" 398 - source = "registry+https://github.com/rust-lang/crates.io-index" 399 - checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" 400 - dependencies = [ 401 - "hermit-abi", 402 - "libc", 403 - ] 404 - 405 - [[package]] 406 - name = "once_cell" 407 - version = "1.10.0" 408 - source = "registry+https://github.com/rust-lang/crates.io-index" 409 - checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" 410 - 411 - [[package]] 412 - name = "os_str_bytes" 413 - version = "6.0.0" 414 - source = "registry+https://github.com/rust-lang/crates.io-index" 415 - checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" 416 - dependencies = [ 417 - "memchr", 418 - ] 419 - 420 - [[package]] 421 - name = "parking_lot" 422 - version = "0.12.0" 423 - source = "registry+https://github.com/rust-lang/crates.io-index" 424 - checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" 425 - dependencies = [ 426 - "lock_api", 427 - "parking_lot_core", 428 - ] 429 - 430 - [[package]] 431 - name = "parking_lot_core" 432 - version = "0.9.1" 433 - source = "registry+https://github.com/rust-lang/crates.io-index" 434 - checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" 435 - dependencies = [ 436 - "cfg-if", 437 - "libc", 438 - "redox_syscall", 439 - "smallvec", 440 - "windows-sys", 441 - ] 442 - 443 - [[package]] 444 - name = "percent-encoding" 445 - version = "2.1.0" 446 - source = "registry+https://github.com/rust-lang/crates.io-index" 447 - checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 448 - 449 - [[package]] 450 - name = "pin-project" 451 - version = "1.0.10" 452 - source = "registry+https://github.com/rust-lang/crates.io-index" 453 - checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" 454 - dependencies = [ 455 - "pin-project-internal", 456 - ] 457 - 458 - [[package]] 459 - name = "pin-project-internal" 460 - version = "1.0.10" 461 - source = "registry+https://github.com/rust-lang/crates.io-index" 462 - checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" 463 - dependencies = [ 464 - "proc-macro2", 465 - "quote", 466 - "syn", 467 - ] 468 - 469 - [[package]] 470 - name = "pin-project-lite" 471 - version = "0.2.8" 472 - source = "registry+https://github.com/rust-lang/crates.io-index" 473 - checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" 474 - 475 - [[package]] 476 - name = "pin-utils" 477 - version = "0.1.0" 478 - source = "registry+https://github.com/rust-lang/crates.io-index" 479 - checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 480 - 481 - [[package]] 482 - name = "proc-macro-error" 483 - version = "1.0.4" 484 - source = "registry+https://github.com/rust-lang/crates.io-index" 485 - checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 486 - dependencies = [ 487 - "proc-macro-error-attr", 488 - "proc-macro2", 489 - "quote", 490 - "syn", 491 - "version_check", 492 - ] 493 - 494 - [[package]] 495 - name = "proc-macro-error-attr" 496 - version = "1.0.4" 497 - source = "registry+https://github.com/rust-lang/crates.io-index" 498 - checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 499 - dependencies = [ 500 - "proc-macro2", 501 - "quote", 502 - "version_check", 503 - ] 504 - 505 - [[package]] 506 - name = "proc-macro2" 507 - version = "1.0.36" 508 - source = "registry+https://github.com/rust-lang/crates.io-index" 509 - checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" 510 - dependencies = [ 511 - "unicode-xid", 512 - ] 513 - 514 - [[package]] 515 - name = "psm" 516 - version = "0.1.17" 517 - source = "registry+https://github.com/rust-lang/crates.io-index" 518 - checksum = "6eca0fa5dd7c4c96e184cec588f0b1db1ee3165e678db21c09793105acb17e6f" 519 - dependencies = [ 520 - "cc", 521 - ] 522 - 523 - [[package]] 524 - name = "quote" 525 - version = "1.0.15" 526 - source = "registry+https://github.com/rust-lang/crates.io-index" 527 - checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" 528 - dependencies = [ 529 - "proc-macro2", 530 - ] 531 - 532 - [[package]] 533 - name = "redox_syscall" 534 - version = "0.2.11" 535 - source = "registry+https://github.com/rust-lang/crates.io-index" 536 - checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" 537 - dependencies = [ 538 - "bitflags", 539 - ] 540 - 541 - [[package]] 542 - name = "ropey" 543 - version = "1.3.2" 544 - source = "registry+https://github.com/rust-lang/crates.io-index" 545 - checksum = "e6b9aa65bcd9f308d37c7158b4a1afaaa32b8450213e20c9b98e7d5b3cc2fec3" 546 - dependencies = [ 547 - "smallvec", 548 - ] 549 - 550 - [[package]] 551 - name = "rotth" 552 - version = "0.1.0" 553 - dependencies = [ 554 - "ariadne", 555 - "chumsky", 556 - "clap", 557 - "fnv", 558 - "indoc", 559 - "simplearena", 560 - "somok", 561 - "thiserror", 562 - ] 563 - 564 - [[package]] 565 - name = "rotth-lsp" 566 - version = "0.1.0" 567 - dependencies = [ 568 - "chumsky", 569 - "dashmap", 570 - "ropey", 571 - "rotth", 572 - "somok", 573 - "tokio", 574 - "tower-lsp", 575 - ] 576 - 577 - [[package]] 578 - name = "ryu" 579 - version = "1.0.9" 580 - source = "registry+https://github.com/rust-lang/crates.io-index" 581 - checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" 582 - 583 - [[package]] 584 - name = "scopeguard" 585 - version = "1.1.0" 586 - source = "registry+https://github.com/rust-lang/crates.io-index" 587 - checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 588 - 589 - [[package]] 590 - name = "serde" 591 - version = "1.0.136" 592 - source = "registry+https://github.com/rust-lang/crates.io-index" 593 - checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" 594 - dependencies = [ 595 - "serde_derive", 596 - ] 597 - 598 - [[package]] 599 - name = "serde_derive" 600 - version = "1.0.136" 601 - source = "registry+https://github.com/rust-lang/crates.io-index" 602 - checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" 603 - dependencies = [ 604 - "proc-macro2", 605 - "quote", 606 - "syn", 607 - ] 608 - 609 - [[package]] 610 - name = "serde_json" 611 - version = "1.0.79" 612 - source = "registry+https://github.com/rust-lang/crates.io-index" 613 - checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" 614 - dependencies = [ 615 - "itoa", 616 - "ryu", 617 - "serde", 618 - ] 619 - 620 - [[package]] 621 - name = "serde_repr" 622 - version = "0.1.7" 623 - source = "registry+https://github.com/rust-lang/crates.io-index" 624 - checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5" 625 - dependencies = [ 626 - "proc-macro2", 627 - "quote", 628 - "syn", 629 - ] 630 - 631 - [[package]] 632 - name = "signal-hook-registry" 633 - version = "1.4.0" 634 - source = "registry+https://github.com/rust-lang/crates.io-index" 635 - checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" 636 - dependencies = [ 637 - "libc", 638 - ] 639 - 640 - [[package]] 641 - name = "simplearena" 642 - version = "0.1.0" 643 - 644 - [[package]] 645 - name = "slab" 646 - version = "0.4.5" 647 - source = "registry+https://github.com/rust-lang/crates.io-index" 648 - checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" 649 - 650 - [[package]] 651 - name = "smallvec" 652 - version = "1.8.0" 653 - source = "registry+https://github.com/rust-lang/crates.io-index" 654 - checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" 655 - 656 - [[package]] 657 - name = "socket2" 658 - version = "0.4.4" 659 - source = "registry+https://github.com/rust-lang/crates.io-index" 660 - checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" 661 - dependencies = [ 662 - "libc", 663 - "winapi", 664 - ] 665 - 666 - [[package]] 667 - name = "somok" 668 - version = "1.5.0" 669 - source = "registry+https://github.com/rust-lang/crates.io-index" 670 - checksum = "c761262ff91894bf387ba89f6e8a7ea5adfa1bc643dbeb69b762be391355f1ff" 671 - 672 - [[package]] 673 - name = "stacker" 674 - version = "0.1.14" 675 - source = "registry+https://github.com/rust-lang/crates.io-index" 676 - checksum = "90939d5171a4420b3ff5fbc8954d641e7377335454c259dcb80786f3f21dc9b4" 677 - dependencies = [ 678 - "cc", 679 - "cfg-if", 680 - "libc", 681 - "psm", 682 - "winapi", 683 - ] 684 - 685 - [[package]] 686 - name = "strsim" 687 - version = "0.10.0" 688 - source = "registry+https://github.com/rust-lang/crates.io-index" 689 - checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 690 - 691 - [[package]] 692 - name = "syn" 693 - version = "1.0.86" 694 - source = "registry+https://github.com/rust-lang/crates.io-index" 695 - checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" 696 - dependencies = [ 697 - "proc-macro2", 698 - "quote", 699 - "unicode-xid", 700 - ] 701 - 702 - [[package]] 703 - name = "termcolor" 704 - version = "1.1.3" 705 - source = "registry+https://github.com/rust-lang/crates.io-index" 706 - checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 707 - dependencies = [ 708 - "winapi-util", 709 - ] 710 - 711 - [[package]] 712 - name = "textwrap" 713 - version = "0.15.0" 714 - source = "registry+https://github.com/rust-lang/crates.io-index" 715 - checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" 716 - 717 - [[package]] 718 - name = "thiserror" 719 - version = "1.0.30" 720 - source = "registry+https://github.com/rust-lang/crates.io-index" 721 - checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" 722 - dependencies = [ 723 - "thiserror-impl", 724 - ] 725 - 726 - [[package]] 727 - name = "thiserror-impl" 728 - version = "1.0.30" 729 - source = "registry+https://github.com/rust-lang/crates.io-index" 730 - checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" 731 - dependencies = [ 732 - "proc-macro2", 733 - "quote", 734 - "syn", 735 - ] 736 - 737 - [[package]] 738 - name = "tinyvec" 739 - version = "1.5.1" 740 - source = "registry+https://github.com/rust-lang/crates.io-index" 741 - checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" 742 - dependencies = [ 743 - "tinyvec_macros", 744 - ] 745 - 746 - [[package]] 747 - name = "tinyvec_macros" 748 - version = "0.1.0" 749 - source = "registry+https://github.com/rust-lang/crates.io-index" 750 - checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 751 - 752 - [[package]] 753 - name = "tokio" 754 - version = "1.17.0" 755 - source = "registry+https://github.com/rust-lang/crates.io-index" 756 - checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" 757 - dependencies = [ 758 - "bytes", 759 - "libc", 760 - "memchr", 761 - "mio", 762 - "num_cpus", 763 - "once_cell", 764 - "parking_lot", 765 - "pin-project-lite", 766 - "signal-hook-registry", 767 - "socket2", 768 - "tokio-macros", 769 - "winapi", 770 - ] 771 - 772 - [[package]] 773 - name = "tokio-macros" 774 - version = "1.7.0" 775 - source = "registry+https://github.com/rust-lang/crates.io-index" 776 - checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" 777 - dependencies = [ 778 - "proc-macro2", 779 - "quote", 780 - "syn", 781 - ] 782 - 783 - [[package]] 784 - name = "tokio-util" 785 - version = "0.7.0" 786 - source = "registry+https://github.com/rust-lang/crates.io-index" 787 - checksum = "64910e1b9c1901aaf5375561e35b9c057d95ff41a44ede043a03e09279eabaf1" 788 - dependencies = [ 789 - "bytes", 790 - "futures-core", 791 - "futures-sink", 792 - "log", 793 - "pin-project-lite", 794 - "tokio", 795 - ] 796 - 797 - [[package]] 798 - name = "tower" 799 - version = "0.4.12" 800 - source = "registry+https://github.com/rust-lang/crates.io-index" 801 - checksum = "9a89fd63ad6adf737582df5db40d286574513c69a11dac5214dc3b5603d6713e" 802 - dependencies = [ 803 - "futures-core", 804 - "futures-util", 805 - "pin-project", 806 - "pin-project-lite", 807 - "tower-layer", 808 - "tower-service", 809 - ] 810 - 811 - [[package]] 812 - name = "tower-layer" 813 - version = "0.3.1" 814 - source = "registry+https://github.com/rust-lang/crates.io-index" 815 - checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62" 816 - 817 - [[package]] 818 - name = "tower-lsp" 819 - version = "0.16.0" 820 - source = "registry+https://github.com/rust-lang/crates.io-index" 821 - checksum = "835e69c995865ed116986d68f74044393c21606c65e25e570031e6e793f21a7b" 822 - dependencies = [ 823 - "async-trait", 824 - "auto_impl", 825 - "bytes", 826 - "dashmap", 827 - "futures", 828 - "httparse", 829 - "log", 830 - "lsp-types", 831 - "memchr", 832 - "serde", 833 - "serde_json", 834 - "tokio", 835 - "tokio-util", 836 - "tower", 837 - "tower-lsp-macros", 838 - ] 839 - 840 - [[package]] 841 - name = "tower-lsp-macros" 842 - version = "0.6.0" 843 - source = "registry+https://github.com/rust-lang/crates.io-index" 844 - checksum = "7ebd99eec668d0a450c177acbc4d05e0d0d13b1f8d3db13cd706c52cbec4ac04" 845 - dependencies = [ 846 - "proc-macro2", 847 - "quote", 848 - "syn", 849 - ] 850 - 851 - [[package]] 852 - name = "tower-service" 853 - version = "0.3.1" 854 - source = "registry+https://github.com/rust-lang/crates.io-index" 855 - checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" 856 - 857 - [[package]] 858 - name = "unicode-bidi" 859 - version = "0.3.7" 860 - source = "registry+https://github.com/rust-lang/crates.io-index" 861 - checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" 862 - 863 - [[package]] 864 - name = "unicode-normalization" 865 - version = "0.1.19" 866 - source = "registry+https://github.com/rust-lang/crates.io-index" 867 - checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" 868 - dependencies = [ 869 - "tinyvec", 870 - ] 871 - 872 - [[package]] 873 - name = "unicode-xid" 874 - version = "0.2.2" 875 - source = "registry+https://github.com/rust-lang/crates.io-index" 876 - checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 877 - 878 - [[package]] 879 - name = "unindent" 880 - version = "0.1.8" 881 - source = "registry+https://github.com/rust-lang/crates.io-index" 882 - checksum = "514672a55d7380da379785a4d70ca8386c8883ff7eaae877be4d2081cebe73d8" 883 - 884 - [[package]] 885 - name = "url" 886 - version = "2.2.2" 887 - source = "registry+https://github.com/rust-lang/crates.io-index" 888 - checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" 889 - dependencies = [ 890 - "form_urlencoded", 891 - "idna", 892 - "matches", 893 - "percent-encoding", 894 - "serde", 895 - ] 896 - 897 - [[package]] 898 - name = "version_check" 899 - version = "0.9.4" 900 - source = "registry+https://github.com/rust-lang/crates.io-index" 901 - checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 902 - 903 - [[package]] 904 - name = "wasi" 905 - version = "0.10.2+wasi-snapshot-preview1" 906 - source = "registry+https://github.com/rust-lang/crates.io-index" 907 - checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 908 - 909 - [[package]] 910 - name = "winapi" 911 - version = "0.3.9" 912 - source = "registry+https://github.com/rust-lang/crates.io-index" 913 - checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 914 - dependencies = [ 915 - "winapi-i686-pc-windows-gnu", 916 - "winapi-x86_64-pc-windows-gnu", 917 - ] 918 - 919 - [[package]] 920 - name = "winapi-i686-pc-windows-gnu" 921 - version = "0.4.0" 922 - source = "registry+https://github.com/rust-lang/crates.io-index" 923 - checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 924 - 925 - [[package]] 926 - name = "winapi-util" 927 - version = "0.1.5" 928 - source = "registry+https://github.com/rust-lang/crates.io-index" 929 - checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 930 - dependencies = [ 931 - "winapi", 932 - ] 933 - 934 - [[package]] 935 - name = "winapi-x86_64-pc-windows-gnu" 936 - version = "0.4.0" 937 - source = "registry+https://github.com/rust-lang/crates.io-index" 938 - checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 939 - 940 - [[package]] 941 - name = "windows-sys" 942 - version = "0.32.0" 943 - source = "registry+https://github.com/rust-lang/crates.io-index" 944 - checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" 945 - dependencies = [ 946 - "windows_aarch64_msvc", 947 - "windows_i686_gnu", 948 - "windows_i686_msvc", 949 - "windows_x86_64_gnu", 950 - "windows_x86_64_msvc", 951 - ] 952 - 953 - [[package]] 954 - name = "windows_aarch64_msvc" 955 - version = "0.32.0" 956 - source = "registry+https://github.com/rust-lang/crates.io-index" 957 - checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" 958 - 959 - [[package]] 960 - name = "windows_i686_gnu" 961 - version = "0.32.0" 962 - source = "registry+https://github.com/rust-lang/crates.io-index" 963 - checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" 964 - 965 - [[package]] 966 - name = "windows_i686_msvc" 967 - version = "0.32.0" 968 - source = "registry+https://github.com/rust-lang/crates.io-index" 969 - checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" 970 - 971 - [[package]] 972 - name = "windows_x86_64_gnu" 973 - version = "0.32.0" 974 - source = "registry+https://github.com/rust-lang/crates.io-index" 975 - checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" 976 - 977 - [[package]] 978 - name = "windows_x86_64_msvc" 979 - version = "0.32.0" 980 - source = "registry+https://github.com/rust-lang/crates.io-index" 981 - checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" 982 - 983 - [[package]] 984 - name = "yansi" 985 - version = "0.5.0" 986 - source = "registry+https://github.com/rust-lang/crates.io-index" 987 - checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71"
-391
rotth/Cargo.lock
··· 1 - # This file is automatically @generated by Cargo. 2 - # It is not intended for manual editing. 3 - version = 3 4 - 5 - [[package]] 6 - name = "ahash" 7 - version = "0.7.6" 8 - source = "registry+https://github.com/rust-lang/crates.io-index" 9 - checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 10 - dependencies = [ 11 - "getrandom", 12 - "once_cell", 13 - "version_check", 14 - ] 15 - 16 - [[package]] 17 - name = "ariadne" 18 - version = "0.1.5" 19 - source = "registry+https://github.com/rust-lang/crates.io-index" 20 - checksum = "f1cb2a2046bea8ce5e875551f5772024882de0b540c7f93dfc5d6cf1ca8b030c" 21 - dependencies = [ 22 - "yansi", 23 - ] 24 - 25 - [[package]] 26 - name = "atty" 27 - version = "0.2.14" 28 - source = "registry+https://github.com/rust-lang/crates.io-index" 29 - checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 30 - dependencies = [ 31 - "hermit-abi", 32 - "libc", 33 - "winapi", 34 - ] 35 - 36 - [[package]] 37 - name = "autocfg" 38 - version = "1.1.0" 39 - source = "registry+https://github.com/rust-lang/crates.io-index" 40 - checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 41 - 42 - [[package]] 43 - name = "bitflags" 44 - version = "1.3.2" 45 - source = "registry+https://github.com/rust-lang/crates.io-index" 46 - checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 47 - 48 - [[package]] 49 - name = "cc" 50 - version = "1.0.73" 51 - source = "registry+https://github.com/rust-lang/crates.io-index" 52 - checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" 53 - 54 - [[package]] 55 - name = "cfg-if" 56 - version = "1.0.0" 57 - source = "registry+https://github.com/rust-lang/crates.io-index" 58 - checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 59 - 60 - [[package]] 61 - name = "chumsky" 62 - version = "0.8.0" 63 - source = "git+https://github.com/zesterer/chumsky.git#96d246a93f182bff6bb89caaba35d357e92bbd0f" 64 - dependencies = [ 65 - "hashbrown", 66 - "stacker", 67 - ] 68 - 69 - [[package]] 70 - name = "clap" 71 - version = "3.1.5" 72 - source = "registry+https://github.com/rust-lang/crates.io-index" 73 - checksum = "ced1892c55c910c1219e98d6fc8d71f6bddba7905866ce740066d8bfea859312" 74 - dependencies = [ 75 - "atty", 76 - "bitflags", 77 - "clap_derive", 78 - "indexmap", 79 - "lazy_static", 80 - "os_str_bytes", 81 - "strsim", 82 - "termcolor", 83 - "textwrap", 84 - ] 85 - 86 - [[package]] 87 - name = "clap_derive" 88 - version = "3.1.4" 89 - source = "registry+https://github.com/rust-lang/crates.io-index" 90 - checksum = "da95d038ede1a964ce99f49cbe27a7fb538d1da595e4b4f70b8c8f338d17bf16" 91 - dependencies = [ 92 - "heck", 93 - "proc-macro-error", 94 - "proc-macro2", 95 - "quote", 96 - "syn", 97 - ] 98 - 99 - [[package]] 100 - name = "fnv" 101 - version = "1.0.7" 102 - source = "registry+https://github.com/rust-lang/crates.io-index" 103 - checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 104 - 105 - [[package]] 106 - name = "getrandom" 107 - version = "0.2.5" 108 - source = "registry+https://github.com/rust-lang/crates.io-index" 109 - checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" 110 - dependencies = [ 111 - "cfg-if", 112 - "libc", 113 - "wasi", 114 - ] 115 - 116 - [[package]] 117 - name = "hashbrown" 118 - version = "0.11.2" 119 - source = "registry+https://github.com/rust-lang/crates.io-index" 120 - checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 121 - dependencies = [ 122 - "ahash", 123 - ] 124 - 125 - [[package]] 126 - name = "heck" 127 - version = "0.4.0" 128 - source = "registry+https://github.com/rust-lang/crates.io-index" 129 - checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 130 - 131 - [[package]] 132 - name = "hermit-abi" 133 - version = "0.1.19" 134 - source = "registry+https://github.com/rust-lang/crates.io-index" 135 - checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 136 - dependencies = [ 137 - "libc", 138 - ] 139 - 140 - [[package]] 141 - name = "indexmap" 142 - version = "1.8.0" 143 - source = "registry+https://github.com/rust-lang/crates.io-index" 144 - checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" 145 - dependencies = [ 146 - "autocfg", 147 - "hashbrown", 148 - ] 149 - 150 - [[package]] 151 - name = "indoc" 152 - version = "1.0.4" 153 - source = "registry+https://github.com/rust-lang/crates.io-index" 154 - checksum = "e7906a9fababaeacb774f72410e497a1d18de916322e33797bb2cd29baa23c9e" 155 - dependencies = [ 156 - "unindent", 157 - ] 158 - 159 - [[package]] 160 - name = "lazy_static" 161 - version = "1.4.0" 162 - source = "registry+https://github.com/rust-lang/crates.io-index" 163 - checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 164 - 165 - [[package]] 166 - name = "libc" 167 - version = "0.2.119" 168 - source = "registry+https://github.com/rust-lang/crates.io-index" 169 - checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" 170 - 171 - [[package]] 172 - name = "memchr" 173 - version = "2.4.1" 174 - source = "registry+https://github.com/rust-lang/crates.io-index" 175 - checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 176 - 177 - [[package]] 178 - name = "once_cell" 179 - version = "1.10.0" 180 - source = "registry+https://github.com/rust-lang/crates.io-index" 181 - checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" 182 - 183 - [[package]] 184 - name = "os_str_bytes" 185 - version = "6.0.0" 186 - source = "registry+https://github.com/rust-lang/crates.io-index" 187 - checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" 188 - dependencies = [ 189 - "memchr", 190 - ] 191 - 192 - [[package]] 193 - name = "proc-macro-error" 194 - version = "1.0.4" 195 - source = "registry+https://github.com/rust-lang/crates.io-index" 196 - checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 197 - dependencies = [ 198 - "proc-macro-error-attr", 199 - "proc-macro2", 200 - "quote", 201 - "syn", 202 - "version_check", 203 - ] 204 - 205 - [[package]] 206 - name = "proc-macro-error-attr" 207 - version = "1.0.4" 208 - source = "registry+https://github.com/rust-lang/crates.io-index" 209 - checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 210 - dependencies = [ 211 - "proc-macro2", 212 - "quote", 213 - "version_check", 214 - ] 215 - 216 - [[package]] 217 - name = "proc-macro2" 218 - version = "1.0.36" 219 - source = "registry+https://github.com/rust-lang/crates.io-index" 220 - checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" 221 - dependencies = [ 222 - "unicode-xid", 223 - ] 224 - 225 - [[package]] 226 - name = "psm" 227 - version = "0.1.17" 228 - source = "registry+https://github.com/rust-lang/crates.io-index" 229 - checksum = "6eca0fa5dd7c4c96e184cec588f0b1db1ee3165e678db21c09793105acb17e6f" 230 - dependencies = [ 231 - "cc", 232 - ] 233 - 234 - [[package]] 235 - name = "quote" 236 - version = "1.0.15" 237 - source = "registry+https://github.com/rust-lang/crates.io-index" 238 - checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" 239 - dependencies = [ 240 - "proc-macro2", 241 - ] 242 - 243 - [[package]] 244 - name = "rotth" 245 - version = "0.1.0" 246 - dependencies = [ 247 - "ariadne", 248 - "chumsky", 249 - "clap", 250 - "fnv", 251 - "indoc", 252 - "simplearena", 253 - "somok", 254 - "thiserror", 255 - ] 256 - 257 - [[package]] 258 - name = "simplearena" 259 - version = "0.1.0" 260 - 261 - [[package]] 262 - name = "somok" 263 - version = "1.5.0" 264 - source = "registry+https://github.com/rust-lang/crates.io-index" 265 - checksum = "c761262ff91894bf387ba89f6e8a7ea5adfa1bc643dbeb69b762be391355f1ff" 266 - 267 - [[package]] 268 - name = "stacker" 269 - version = "0.1.14" 270 - source = "registry+https://github.com/rust-lang/crates.io-index" 271 - checksum = "90939d5171a4420b3ff5fbc8954d641e7377335454c259dcb80786f3f21dc9b4" 272 - dependencies = [ 273 - "cc", 274 - "cfg-if", 275 - "libc", 276 - "psm", 277 - "winapi", 278 - ] 279 - 280 - [[package]] 281 - name = "strsim" 282 - version = "0.10.0" 283 - source = "registry+https://github.com/rust-lang/crates.io-index" 284 - checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 285 - 286 - [[package]] 287 - name = "syn" 288 - version = "1.0.86" 289 - source = "registry+https://github.com/rust-lang/crates.io-index" 290 - checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" 291 - dependencies = [ 292 - "proc-macro2", 293 - "quote", 294 - "unicode-xid", 295 - ] 296 - 297 - [[package]] 298 - name = "termcolor" 299 - version = "1.1.3" 300 - source = "registry+https://github.com/rust-lang/crates.io-index" 301 - checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 302 - dependencies = [ 303 - "winapi-util", 304 - ] 305 - 306 - [[package]] 307 - name = "textwrap" 308 - version = "0.15.0" 309 - source = "registry+https://github.com/rust-lang/crates.io-index" 310 - checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" 311 - 312 - [[package]] 313 - name = "thiserror" 314 - version = "1.0.30" 315 - source = "registry+https://github.com/rust-lang/crates.io-index" 316 - checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" 317 - dependencies = [ 318 - "thiserror-impl", 319 - ] 320 - 321 - [[package]] 322 - name = "thiserror-impl" 323 - version = "1.0.30" 324 - source = "registry+https://github.com/rust-lang/crates.io-index" 325 - checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" 326 - dependencies = [ 327 - "proc-macro2", 328 - "quote", 329 - "syn", 330 - ] 331 - 332 - [[package]] 333 - name = "unicode-xid" 334 - version = "0.2.2" 335 - source = "registry+https://github.com/rust-lang/crates.io-index" 336 - checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 337 - 338 - [[package]] 339 - name = "unindent" 340 - version = "0.1.8" 341 - source = "registry+https://github.com/rust-lang/crates.io-index" 342 - checksum = "514672a55d7380da379785a4d70ca8386c8883ff7eaae877be4d2081cebe73d8" 343 - 344 - [[package]] 345 - name = "version_check" 346 - version = "0.9.4" 347 - source = "registry+https://github.com/rust-lang/crates.io-index" 348 - checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 349 - 350 - [[package]] 351 - name = "wasi" 352 - version = "0.10.2+wasi-snapshot-preview1" 353 - source = "registry+https://github.com/rust-lang/crates.io-index" 354 - checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 355 - 356 - [[package]] 357 - name = "winapi" 358 - version = "0.3.9" 359 - source = "registry+https://github.com/rust-lang/crates.io-index" 360 - checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 361 - dependencies = [ 362 - "winapi-i686-pc-windows-gnu", 363 - "winapi-x86_64-pc-windows-gnu", 364 - ] 365 - 366 - [[package]] 367 - name = "winapi-i686-pc-windows-gnu" 368 - version = "0.4.0" 369 - source = "registry+https://github.com/rust-lang/crates.io-index" 370 - checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 371 - 372 - [[package]] 373 - name = "winapi-util" 374 - version = "0.1.5" 375 - source = "registry+https://github.com/rust-lang/crates.io-index" 376 - checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 377 - dependencies = [ 378 - "winapi", 379 - ] 380 - 381 - [[package]] 382 - name = "winapi-x86_64-pc-windows-gnu" 383 - version = "0.4.0" 384 - source = "registry+https://github.com/rust-lang/crates.io-index" 385 - checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 386 - 387 - [[package]] 388 - name = "yansi" 389 - version = "0.5.0" 390 - source = "registry+https://github.com/rust-lang/crates.io-index" 391 - checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71"
+2 -1
rotth/src/ast.rs
··· 635 635 636 636 fn generics() -> impl Parser<Token, AstNode, Error = Simple<Token, Span>> { 637 637 lbracket() 638 - .then(ty().repeated().at_least(1)) 638 + .then(word().repeated().at_least(1)) 639 639 .then(rbracket()) 640 640 .map_with_span(|((left_bracket, tys), right_bracket), span| AstNode { 641 641 span, ··· 770 770 )) 771 771 .repeated() 772 772 .then_ignore(end()) 773 + .or(end().to(vec![])) 773 774 } 774 775 775 776 pub fn parse_no_include(tokens: Vec<(Token, Span)>) -> Result<Vec<TopLevel>, Error> {
+64 -49
rotth/src/hir.rs
··· 3 3 iconst::IConst, 4 4 lexer::KeyWord, 5 5 span::Span, 6 - types::{self, StructId, StructIndex, Type}, 6 + types::{StructId, StructIndex}, 7 7 }; 8 8 use fnv::FnvHashMap; 9 9 use somok::Somok; ··· 39 39 None 40 40 } 41 41 } 42 + pub fn span(&self) -> Span { 43 + match self { 44 + TopLevel::Proc(p) => p.span.clone(), 45 + TopLevel::Const(c) => c.span.clone(), 46 + TopLevel::Mem(m) => m.span.clone(), 47 + TopLevel::Var(v) => v.span.clone(), 48 + } 49 + } 42 50 } 43 51 44 52 #[derive(Debug, Clone)] 45 53 pub struct TopLevelVar { 46 - pub ty: Type, 54 + pub ty: ast::Type, 47 55 pub span: Span, 48 56 } 49 57 50 58 #[derive(Debug, Clone)] 51 59 pub struct Proc { 52 - pub ins: Vec<Type>, 53 - pub outs: Vec<Type>, 60 + pub generics: Vec<String>, 61 + pub ins: Vec<HirNode>, 62 + pub outs: Vec<HirNode>, 54 63 pub body: Vec<HirNode>, 55 64 pub span: Span, 56 65 pub vars: FnvHashMap<String, Var>, ··· 58 67 59 68 #[derive(Debug, Clone)] 60 69 pub struct Const { 61 - pub outs: Vec<Type>, 70 + pub outs: Vec<HirNode>, 62 71 pub body: Vec<HirNode>, 63 72 pub span: Span, 64 73 } ··· 87 96 IgnorePattern, 88 97 Return, 89 98 FieldAccess(FieldAccess), 99 + Type(ast::Type), 90 100 } 91 101 #[derive(Debug, Clone)] 92 102 pub struct FieldAccess { ··· 124 134 #[derive(Debug, Clone)] 125 135 pub enum Binding { 126 136 Ignore, 127 - Bind { name: String, ty: Type }, 137 + Bind { name: String, ty: Box<HirNode> }, 128 138 } 129 139 130 140 #[derive(Debug, Clone)] ··· 134 144 Swap, 135 145 Over, 136 146 137 - Cast(Type), 147 + Cast(Box<HirNode>), 138 148 139 149 ReadU64, 140 150 ReadU8, ··· 171 181 172 182 #[derive(Debug, Clone)] 173 183 pub struct Var { 174 - pub ty: types::Type, 184 + pub ty: HirNode, 175 185 pub escaping: bool, 176 186 } 177 187 ··· 194 204 cast: _, 195 205 ty: 196 206 box AstNode { 197 - span: _, 207 + span, 198 208 ast: AstKind::Type(ty), 199 209 }, 200 - }) => { 201 - let ty = if let Some(struct_) = ty.clone().to_type(self.structs) { 202 - struct_ 203 - } else { 204 - todo!() 205 - }; 206 - Intrinsic::Cast(ty) 207 - } 210 + }) => Intrinsic::Cast(box HirNode { 211 + span: span.clone(), 212 + hir: HirKind::Type(ty.clone()), 213 + }), 208 214 AstKind::Word(ref w) => match w.as_str() { 209 215 "drop" => Intrinsic::Drop, 210 216 "dup" => Intrinsic::Dup, ··· 268 274 sep: _, 269 275 ty: 270 276 box AstNode { 271 - span: _, 277 + span, 272 278 ast: AstKind::Type(ty), 273 279 }, 274 280 } => res.push(Binding::Bind { 275 281 name, 276 - ty: ty.to_type(self.structs).unwrap(), 282 + ty: box HirNode { 283 + span, 284 + hir: HirKind::Type(ty), 285 + }, 277 286 }), 278 287 _ => unreachable!(), 279 288 } ··· 299 308 ast::TopLevel::Const(c) => TopLevel::Const(self.walk_const(c)), 300 309 ast::TopLevel::Mem(m) => TopLevel::Mem(self.walk_mem(m)), 301 310 ast::TopLevel::Var(v) => { 302 - let ty = coerce_ast!(v.ty => Type || unreachable!()) 303 - .to_type(self.structs) 304 - .unwrap(); 311 + let ty = coerce_ast!(v.ty => Type || unreachable!()); 305 312 TopLevel::Var(TopLevelVar { 306 313 ty, 307 314 span: v.name.span, ··· 327 334 .tys 328 335 .into_iter() 329 336 .map(|ty| { 330 - coerce_ast!(ty => Type || unreachable!()) 331 - .to_type(self.structs) 332 - .unwrap() 337 + let span = ty.span; 338 + let ty = coerce_ast!(ty => Type || unreachable!()); 339 + HirNode { 340 + span, 341 + hir: HirKind::Type(ty), 342 + } 333 343 }) 334 344 .collect(); 335 345 let body = coerce_ast!(const_.body => Body || unreachable!()) ··· 350 360 coerce_ast!(g => Generics || unreachable!()) 351 361 .tys 352 362 .into_iter() 353 - .map(|ty| coerce_ast!(ty => Type || unreachable!())) 363 + .map(|ty| coerce_ast!(ty => Word || unreachable!())) 354 364 }) 355 365 .into_iter() 356 366 .flatten() ··· 368 378 Proc { 369 379 ins, 370 380 outs, 381 + generics, 371 382 body: body.unwrap(), 372 383 vars, 373 384 span: proc.proc.span.merge(proc.end.span), ··· 418 429 fn walk_var(&mut self, var: ast::Var) { 419 430 let name = coerce_ast!(var.name => Word || unreachable!()); 420 431 let escaping = var.ret.is_some(); 421 - let ty = coerce_ast!(var.ty => Type || unreachable!()) 422 - .to_type(self.structs) 423 - .unwrap(); 424 - let var = Var { ty, escaping }; 432 + let span = var.ty.span; 433 + let ty = coerce_ast!(var.ty => Type || unreachable!()); 434 + let var = Var { 435 + ty: HirNode { 436 + span, 437 + hir: HirKind::Type(ty), 438 + }, 439 + escaping, 440 + }; 425 441 self.proc_vars.insert(name, var); 426 442 } 427 443 ··· 489 505 If { truth, lie } 490 506 } 491 507 492 - fn walk_proc_signature(&mut self, signature: ast::ProcSignature) -> (Vec<Type>, Vec<Type>) { 508 + fn walk_proc_signature( 509 + &mut self, 510 + signature: ast::ProcSignature, 511 + ) -> (Vec<HirNode>, Vec<HirNode>) { 493 512 let mut ins = Vec::with_capacity(signature.ins.len()); 494 513 for ty in signature.ins { 495 - if let AstKind::Type(ty) = ty.ast { 496 - if let Some(struct_) = ty.to_type(self.structs) { 497 - ins.push(struct_); 498 - } else { 499 - todo!() 500 - } 501 - } else { 502 - unreachable!(); 503 - } 514 + let span = ty.span; 515 + let ty = coerce_ast!(ty => Type || unreachable!()); 516 + let ty = HirNode { 517 + span, 518 + hir: HirKind::Type(ty), 519 + }; 520 + ins.push(ty); 504 521 } 505 522 let outs = if let Some(outs) = signature.outs { 506 523 let mut proc_outs = Vec::with_capacity(outs.len()); 507 524 for ty in outs { 508 - if let AstKind::Type(ty) = ty.ast { 509 - if let Some(struct_) = ty.to_type(self.structs) { 510 - proc_outs.push(struct_); 511 - } else { 512 - todo!() 513 - } 514 - } else { 515 - unreachable!(); 516 - } 525 + let span = ty.span; 526 + let ty = coerce_ast!(ty => Type || unreachable!()); 527 + let ty = HirNode { 528 + span, 529 + hir: HirKind::Type(ty), 530 + }; 531 + proc_outs.push(ty); 517 532 } 518 533 proc_outs 519 534 } else {
+1 -1
rotth/src/inference.rs
··· 57 57 /// there is a conflict between them) 58 58 pub fn unify(&mut self, a: TypeId, b: TypeId, structs: &StructIndex) -> Result<(), String> { 59 59 use TypeInfo::*; 60 - match (self.vars[&a].clone(), self.vars[&b].clone()) { 60 + match (self.vars[&a], self.vars[&b]) { 61 61 // Follow any references 62 62 (Ref(a), _) => self.unify(a, b, structs), 63 63 (_, Ref(b)) => self.unify(a, b, structs),
+3 -3
rotth/src/lib.rs
··· 36 36 } 37 37 38 38 pub mod ast; 39 - pub mod emit; 40 - pub mod eval; 39 + // pub mod emit; 40 + // pub mod eval; 41 41 pub mod hir; 42 42 pub mod iconst; 43 43 pub mod inference; 44 44 pub mod lexer; 45 - pub mod lir; 45 + // pub mod lir; 46 46 pub mod resolver; 47 47 pub mod span; 48 48 pub mod tir;
+28 -27
rotth/src/main.rs
··· 3 3 use clap::Parser as ClapParser; 4 4 use fnv::FnvHashMap; 5 5 use rotth::{ 6 - ast, emit, 7 - eval::eval, 6 + ast, 7 + // emit, 8 + // eval::eval, 8 9 hir, 9 10 lexer::lex, 10 - lir, 11 - typecheck::{ErrorKind, Typechecker}, 12 - Error, Result, 11 + // lir, 12 + typecheck::ErrorKind, 13 + Error, 14 + Result, 13 15 }; 14 16 use somok::Somok; 15 17 use std::{fs::OpenOptions, io::BufWriter, path::PathBuf, time::Instant}; ··· 185 187 .with_message("Not enough data on the stack".fg(Color::Red)), 186 188 ), 187 189 188 - ErrorKind::Undefined(w) => report.with_label(Label::new(e.span).with_message( 189 - format!("Unknown word `{}`", w.fg(Color::Yellow)).fg(Color::Red), 190 - )), 190 + ErrorKind::Undefined => report 191 + .with_label(Label::new(e.span).with_message("Unknown word".fg(Color::Red))), 191 192 ErrorKind::InvalidMain => report.with_label( 192 193 Label::new(e.span).with_message( 193 194 format!("Invalid type signature for `{}`", "main".fg(Color::Yellow)) ··· 261 262 println!("{hir:#?}"); 262 263 } 263 264 264 - let procs = Typechecker::typecheck_program(hir, &struct_index)?; 265 + // let procs = Typechecker::typecheck_program(hir, &struct_index)?; 265 266 266 267 let typechecked = Instant::now(); 267 268 if args.time { 268 269 println!("Typechecked in:\t{:?}", typechecked - lowered) 269 270 } 270 271 271 - let comp = lir::Compiler::new(struct_index); 272 - let (lir, strs, mems) = comp.compile(procs); 272 + // let comp = lir::Compiler::new(struct_index); 273 + // let (lir, strs, mems) = comp.compile(procs); 273 274 274 275 let transpiled = Instant::now(); 275 276 if args.time { ··· 278 279 279 280 if args.dump_lir { 280 281 println!("LIR:\n"); 281 - for (i, op) in lir.iter().enumerate() { 282 - println!("{i}:\t{op:?}"); 283 - } 282 + // for (i, op) in lir.iter().enumerate() { 283 + // println!("{i}:\t{op:?}"); 284 + // } 284 285 } 285 286 if args.compile { 286 - emit::compile( 287 - lir, 288 - &strs, 289 - &mems, 290 - BufWriter::new( 291 - OpenOptions::new() 292 - .create(true) 293 - .write(true) 294 - .truncate(true) 295 - .open(source.with_extension("asm"))?, 296 - ), 297 - )?; 287 + // emit::compile( 288 + // lir, 289 + // &strs, 290 + // &mems, 291 + // BufWriter::new( 292 + // OpenOptions::new() 293 + // .create(true) 294 + // .write(true) 295 + // .truncate(true) 296 + // .open(source.with_extension("asm"))?, 297 + // ), 298 + // )?; 298 299 299 300 let compiled = Instant::now(); 300 301 if args.time { ··· 302 303 println!("Total:\t{:?}", compiled - start); 303 304 } 304 305 } else { 305 - println!("exitcode: {:?}", eval(lir, &strs).unwrap()); 306 + // println!("exitcode: {:?}", eval(lir, &strs).unwrap()); 306 307 let evaluated = Instant::now(); 307 308 if args.time { 308 309 println!("Evaluated in:\t{:?}", evaluated - transpiled);
+304 -11
rotth/src/tir.rs
··· 1 - use crate::hir; 1 + use crate::{ 2 + ast, 3 + hir::{self, HirKind, HirNode}, 4 + iconst::IConst, 5 + span::Span, 6 + typecheck::{error, ErrorKind::*, Result, THeap, TypeStack}, 7 + types::{StructId, StructIndex}, 8 + }; 9 + use fnv::FnvHashMap; 10 + use somok::Somok; 2 11 12 + #[derive(Debug, Clone)] 3 13 pub enum TopLevel { 4 - Proc(Proc), 14 + Proc(), 15 + Const(), 16 + Mem(), 17 + Var(), 18 + } 19 + pub struct TirNode { 20 + ins: Vec<Type>, 21 + outs: Vec<Type>, 22 + hir: HirKind, 23 + } 24 + #[derive(Debug, Clone, PartialEq, Eq)] 25 + pub struct Type { 26 + pub ptr_depth: usize, 27 + pub kind: TypeKind, 28 + } 29 + 30 + impl Type { 31 + const BOOL: Self = Self { 32 + ptr_depth: 0, 33 + kind: TypeKind::Concrete(ConcreteType::Bool), 34 + }; 35 + const CHAR: Self = Self { 36 + ptr_depth: 0, 37 + kind: TypeKind::Concrete(ConcreteType::Char), 38 + }; 39 + const U64: Self = Self { 40 + ptr_depth: 0, 41 + kind: TypeKind::Concrete(ConcreteType::U64), 42 + }; 43 + 44 + pub fn ptr_to(ty: Self) -> Self { 45 + let ptr_depth = ty.ptr_depth + 1; 46 + Self { 47 + ptr_depth, 48 + kind: ty.kind, 49 + } 50 + } 5 51 } 6 52 7 - pub struct Proc {} 53 + #[derive(Debug, Clone, PartialEq, Eq)] 54 + pub enum TypeKind { 55 + Generic(String), 56 + Concrete(ConcreteType), 57 + } 58 + #[derive(Debug, Clone, PartialEq, Eq)] 59 + pub enum ConcreteType { 60 + Bool, 61 + Char, 62 + 63 + U64, 64 + U32, 65 + U16, 66 + U8, 8 67 9 - pub struct Walker {} 68 + I64, 69 + I32, 70 + I16, 71 + I8, 10 72 73 + Struct(StructId), 74 + } 75 + #[derive(Debug, Clone)] 76 + struct KProc { 77 + generics: Vec<String>, 78 + ins: Vec<Type>, 79 + outs: Vec<Type>, 80 + body: Vec<HirNode>, 81 + } 82 + struct KConst { 83 + outs: Vec<Type>, 84 + body: Vec<HirNode>, 85 + } 86 + struct KMem {} 87 + struct KGVar {} 88 + 89 + pub struct Walker { 90 + typechecked_items: FnvHashMap<String, TopLevel>, 91 + known_consts: FnvHashMap<String, KConst>, 92 + known_procs: FnvHashMap<String, KProc>, 93 + known_gvars: FnvHashMap<String, KGVar>, 94 + known_mems: FnvHashMap<String, KMem>, 95 + structs: StructIndex, 96 + outputs: FnvHashMap<String, hir::TopLevel>, 97 + items: FnvHashMap<String, hir::TopLevel>, 98 + heap: THeap, 99 + } 11 100 impl Walker { 12 - pub fn walk_hir(&mut self, item: hir::TopLevel) -> TopLevel { 13 - match item { 14 - hir::TopLevel::Proc(p) => TopLevel::Proc(self.walk_proc(p)), 15 - hir::TopLevel::Const(_c) => todo!(), 16 - hir::TopLevel::Mem(_m) => todo!(), 17 - hir::TopLevel::Var(_v) => todo!(), 101 + pub fn walk( 102 + items: FnvHashMap<String, hir::TopLevel>, 103 + ) -> Result<FnvHashMap<String, hir::TopLevel>> { 104 + let mut this = Walker { 105 + typechecked_items: Default::default(), 106 + known_consts: Default::default(), 107 + known_procs: Default::default(), 108 + known_gvars: Default::default(), 109 + known_mems: Default::default(), 110 + structs: Default::default(), 111 + outputs: Default::default(), 112 + items: Default::default(), 113 + heap: Default::default(), 114 + }; 115 + 116 + for (name, item) in &items { 117 + match item { 118 + hir::TopLevel::Proc(proc) => this.register_proc(name, proc.clone())?, 119 + hir::TopLevel::Const(const_) => this.register_const(name, const_.clone())?, 120 + hir::TopLevel::Mem(_) => todo!(), 121 + hir::TopLevel::Var(_) => todo!(), 122 + }; 123 + } 124 + this.items = items; 125 + this.typecheck_proc("main", Default::default())?; 126 + this.outputs.okay() 127 + } 128 + 129 + fn register_const(&mut self, proc_name: &str, const_: hir::Const) -> Result<()> { 130 + let outs = const_ 131 + .outs 132 + .into_iter() 133 + .map(|ty| self.abstract_to_concrete_type(ty, &[])) 134 + .collect::<Result<Vec<_>>>()?; 135 + 136 + let known_const = KConst { 137 + outs, 138 + body: const_.body, 139 + }; 140 + 141 + self.known_consts.insert(proc_name.to_string(), known_const); 142 + ().okay() 143 + } 144 + 145 + fn register_proc(&mut self, proc_name: &str, proc: hir::Proc) -> Result<()> { 146 + let generics = proc.generics; 147 + let ins = proc 148 + .ins 149 + .into_iter() 150 + .map(|ty| self.abstract_to_concrete_type(ty, &generics)) 151 + .collect::<Result<Vec<_>>>()?; 152 + let outs = proc 153 + .outs 154 + .into_iter() 155 + .map(|ty| self.abstract_to_concrete_type(ty, &generics)) 156 + .collect::<Result<Vec<_>>>()?; 157 + 158 + if proc_name == "main" && !(ins.is_empty() || matches!(&outs[..], [Type::U64])) { 159 + return error( 160 + proc.span, 161 + InvalidMain, 162 + "Main must have no inputs and a single `u64` output", 163 + ); 164 + } 165 + 166 + let known_proc = KProc { 167 + generics, 168 + ins, 169 + outs, 170 + body: proc.body, 171 + }; 172 + 173 + self.known_procs.insert(proc_name.to_string(), known_proc); 174 + ().okay() 175 + } 176 + 177 + fn typecheck_proc( 178 + &mut self, 179 + proc_name: &str, 180 + type_substitutions: FnvHashMap<String, Type>, 181 + ) -> Result<()> { 182 + let proc = if let Some(proc) = self.known_procs.get(proc_name) { 183 + proc 184 + } else { 185 + return error( 186 + Span::point("", 0), 187 + Undefined, 188 + format!("Procedure `{}` is not defined", proc_name), 189 + ); 190 + }; 191 + let mut stack = TypeStack::default(); 192 + for ty in &proc.ins { 193 + match &ty.kind { 194 + TypeKind::Generic(g) => { 195 + if let Some(ty) = type_substitutions.get(g) { 196 + stack.push(&mut self.heap, ty.clone()) 197 + } else { 198 + let span = self.items[proc_name].span(); 199 + return error( 200 + span, 201 + Undefined, 202 + format!("Undefined type `{}` in this scope", g), 203 + ); 204 + } 205 + } 206 + TypeKind::Concrete(_) => stack.push(&mut self.heap, ty.clone()), 207 + } 208 + } 209 + 210 + self.typecheck_body(proc_name, proc.body.clone(), &mut stack)?; 211 + 212 + todo!() 213 + } 214 + 215 + fn typecheck_body( 216 + &mut self, 217 + item_name: &str, 218 + body: Vec<HirNode>, 219 + stack: &mut TypeStack, 220 + ) -> Result<()> { 221 + for node in body { 222 + match &node.hir { 223 + HirKind::Word(w) => match w.as_str() { 224 + rec if rec == item_name && !self.is_proc(rec) => { 225 + return error(node.span.clone(), Unexpected, "Recursive const refinition") 226 + } 227 + rec if rec == item_name => {} 228 + proc_name if self.is_proc(proc_name) => { 229 + let proc = &self.known_procs[proc_name]; 230 + } 231 + const_name if self.is_const(const_name) => {} 232 + _ => todo!(), 233 + }, 234 + HirKind::Intrinsic(_) => todo!(), 235 + HirKind::Bind(_) => todo!(), 236 + HirKind::While(_) => todo!(), 237 + HirKind::If(_) => todo!(), 238 + HirKind::Cond(_) => todo!(), 239 + HirKind::Literal(ref c) => match c { 240 + IConst::Bool(_) => { 241 + stack.push(&mut self.heap, Type::BOOL); 242 + } 243 + IConst::U64(_) => { 244 + stack.push(&mut self.heap, Type::U64); 245 + } 246 + IConst::I64(_) => todo!(), 247 + IConst::Char(_) => { 248 + stack.push(&mut self.heap, Type::CHAR); 249 + } 250 + IConst::Str(_) => { 251 + stack.push(&mut self.heap, Type::U64); 252 + stack.push(&mut self.heap, Type::ptr_to(Type::CHAR)); 253 + } 254 + IConst::Ptr(_) => todo!(), 255 + }, 256 + HirKind::IgnorePattern => todo!(), 257 + HirKind::Return => todo!(), 258 + HirKind::FieldAccess(_) => todo!(), 259 + HirKind::Type(_) => todo!(), 260 + } 18 261 } 262 + ().okay() 19 263 } 20 264 21 - fn walk_proc(&mut self, proc: hir::Proc) -> Proc { 265 + fn abstract_to_concrete_type(&mut self, ty: HirNode, generics: &[String]) -> Result<Type> { 266 + let span = ty.span; 267 + let ty = if let HirKind::Type(ty) = ty.hir { 268 + ty 269 + } else { 270 + unreachable!() 271 + }; 272 + let kind = match ty.type_name.as_str() { 273 + "bool" => TypeKind::Concrete(ConcreteType::Bool), 274 + "char" => TypeKind::Concrete(ConcreteType::Char), 275 + 276 + "u64" => TypeKind::Concrete(ConcreteType::U64), 277 + "u32" => TypeKind::Concrete(ConcreteType::U32), 278 + "u16" => TypeKind::Concrete(ConcreteType::U16), 279 + "u8" => TypeKind::Concrete(ConcreteType::U8), 280 + 281 + "i64" => TypeKind::Concrete(ConcreteType::I64), 282 + "i32" => TypeKind::Concrete(ConcreteType::I32), 283 + "i16" => TypeKind::Concrete(ConcreteType::I16), 284 + "i8" => TypeKind::Concrete(ConcreteType::I8), 285 + 286 + name if generics.contains(&ty.type_name) => TypeKind::Generic(ty.type_name), 287 + name if self.is_struct(name) => { 288 + TypeKind::Concrete(ConcreteType::Struct(self.structs.name_to_id(name).unwrap())) 289 + } 290 + name => { 291 + return error( 292 + span, 293 + Undefined, 294 + format!("Cannot find type `{}` in this scope", name), 295 + ) 296 + } 297 + }; 298 + 299 + Type { 300 + ptr_depth: ty.ptr_count, 301 + kind, 302 + } 303 + .okay() 304 + } 305 + 306 + fn is_struct(&self, name: &str) -> bool { 307 + self.structs.known(name) 308 + } 309 + 310 + fn is_proc(&self, proc_name: &str) -> bool { 311 + todo!() 312 + } 313 + 314 + fn is_const(&self, const_name: &str) -> bool { 22 315 todo!() 23 316 } 24 317 }
+15 -1144
rotth/src/typecheck.rs
··· 1 - use fnv::FnvHashMap; 2 1 use simplearena::{Heap, Ref}; 3 2 use somok::Somok; 4 3 use std::collections::VecDeque; 5 4 6 - use crate::{ 7 - hir::{self, Binding, CondBranch, HirKind, HirNode, If, Intrinsic, TopLevel}, 8 - iconst::IConst, 9 - span::Span, 10 - types::{StructIndex, Type, ValueType}, 11 - Error, 12 - }; 5 + use crate::{span::Span, tir, types::Type, Error}; 13 6 14 7 #[derive(Debug)] 15 8 pub struct TypecheckError { ··· 30 23 #[derive(Debug)] 31 24 pub enum ErrorKind { 32 25 TypeMismatch { 33 - expected: Vec<Type>, 34 - actual: Vec<Type>, 26 + expected: Vec<tir::Type>, 27 + actual: Vec<tir::Type>, 35 28 }, 36 29 NotEnoughData, 37 - Undefined(String), 30 + Undefined, 38 31 InvalidMain, 39 32 InvalidWhile, 40 33 CompStop, 41 34 Unexpected, 42 35 CallInConst, 43 36 } 44 - use ErrorKind::*; 45 - fn error<T>(span: Span, kind: ErrorKind, message: impl ToString) -> Result<T> { 37 + pub fn error<T>(span: Span, kind: ErrorKind, message: impl ToString) -> Result<T> { 46 38 Error::Typecheck(TypecheckError::new(span, kind, message)).error() 47 39 } 48 40 49 41 pub type Result<T> = std::result::Result<T, Error>; 50 - enum ItemKind { 51 - Proc(ItemProc), 52 - Mem, 53 - Gvar(ItemGvar), 54 - Const(ItemConst), 55 - } 56 - 57 - impl ItemKind { 58 - fn as_proc(&self) -> Option<&ItemProc> { 59 - if let Self::Proc(v) = self { 60 - Some(v) 61 - } else { 62 - None 63 - } 64 - } 65 - 66 - fn as_const(&self) -> Option<&ItemConst> { 67 - if let Self::Const(v) = self { 68 - Some(v) 69 - } else { 70 - None 71 - } 72 - } 73 - } 74 - struct ItemProc { 75 - ins: Vec<Type>, 76 - outs: Vec<Type>, 77 - vars: FnvHashMap<String, hir::Var>, 78 - } 79 - struct ItemGvar { 80 - ty: Type, 81 - } 82 - struct ItemConst { 83 - types: Vec<Type>, 84 - } 85 - 86 - pub struct Typechecker<'s> { 87 - structs: &'s StructIndex, 88 - heap: THeap, 89 - visited: FnvHashMap<String, ItemKind>, 90 - output: FnvHashMap<String, TopLevel>, 91 - } 92 - 93 - impl<'s> Typechecker<'s> { 94 - pub fn typecheck_program( 95 - mut items: FnvHashMap<String, TopLevel>, 96 - structs: &'s StructIndex, 97 - ) -> Result<FnvHashMap<String, TopLevel>> { 98 - let heap = THeap::default(); 99 - let mut this = Self { 100 - structs, 101 - heap, 102 - output: Default::default(), 103 - visited: Default::default(), 104 - }; 105 - 106 - this.typecheck_proc("main", &mut items)?; 107 - 108 - this.output.okay() 109 - } 110 - 111 - fn typecheck_proc( 112 - &mut self, 113 - name: &str, 114 - items: &mut FnvHashMap<String, TopLevel>, 115 - ) -> Result<()> { 116 - if self.output.contains_key(name) { 117 - return ().okay(); 118 - } 119 - let mut item = items.remove(name).ok_or_else(|| { 120 - TypecheckError::new( 121 - Span::point("".to_string(), 0), 122 - Undefined(name.to_string()), 123 - format!("Proc `{}` does not exist", name), 124 - ) 125 - })?; 126 - let proc = match &mut item { 127 - TopLevel::Proc(p) => p, 128 - _ => unreachable!("This can't not be proc"), 129 - }; 130 - self.visited.insert( 131 - name.to_string(), 132 - ItemKind::Proc(ItemProc { 133 - ins: proc.ins.clone(), 134 - outs: proc.outs.clone(), 135 - vars: proc.vars.clone(), 136 - }), 137 - ); 138 - if name == "main" && (!proc.ins.is_empty() || !(proc.outs[..] == [Type::U64])) { 139 - return error( 140 - proc.span.clone(), 141 - InvalidMain, 142 - "Main must have no inputs and a single uint output", 143 - ); 144 - } 145 - 146 - let span = proc.span.clone(); 147 - let mut actual = TypeStack::default(); 148 - let mut expected = TypeStack::default(); 149 - for ty in &proc.ins { 150 - actual.push(&mut self.heap, *ty) 151 - } 152 - for ty in &proc.outs { 153 - expected.push(&mut self.heap, *ty) 154 - } 155 - let mut bindings = Vec::new(); 156 - 157 - self.typecheck_body( 158 - name, 159 - items, 160 - &mut proc.body, 161 - &mut actual, 162 - false, 163 - &mut bindings, 164 - )?; 165 - 166 - if !actual.eq(&expected, &self.heap) { 167 - error( 168 - span, 169 - TypeMismatch { 170 - actual: actual.into_vec(&self.heap), 171 - expected: expected.into_vec(&self.heap), 172 - }, 173 - "Type mismatch: proc body does not equal proc outputs", 174 - ) 175 - } else { 176 - self.output.insert(name.to_string(), item); 177 - ().okay() 178 - } 179 - } 180 - 181 - fn typecheck_cond( 182 - &mut self, 183 - name: &str, 184 - items: &mut FnvHashMap<String, TopLevel>, 185 - node: &mut HirNode, 186 - stack: &mut TypeStack, 187 - in_const: bool, 188 - bindings: &mut Vec<Vec<(String, Type)>>, 189 - ) -> Result<()> { 190 - let ty = stack.pop(&self.heap).ok_or_else(|| { 191 - TypecheckError::new(node.span.clone(), NotEnoughData, "Not enough data for cond") 192 - })?; 193 - let cond = match &mut node.hir { 194 - HirKind::Cond(c) => c, 195 - _ => unreachable!(), 196 - }; 197 - let mut first_branch_stack = TypeStack::default(); 198 - let mut first_branch = true; 199 - for CondBranch { pattern, body } in &mut cond.branches { 200 - let pat_ty = match &pattern.hir { 201 - HirKind::Literal(pat) => match pat { 202 - IConst::Bool(_) => Type::BOOL, 203 - IConst::U64(_) => Type::U64, 204 - IConst::I64(_) => Type::I64, 205 - IConst::Char(_) => Type::CHAR, 206 - IConst::Str(_) => todo!(), 207 - IConst::Ptr(_) => todo!(), 208 - }, 209 - HirKind::Word(const_name) if self.is_const(const_name, items) => { 210 - self.typecheck_const(const_name, items)?; 211 - let const_ = self.output[const_name].as_const().ok_or_else(|| { 212 - TypecheckError::new( 213 - pattern.span.clone(), 214 - Unexpected, 215 - "Recursive const definition", 216 - ) 217 - })?; 218 - if const_.outs.len() != 1 { 219 - return error( 220 - pattern.span.clone(), 221 - Unexpected, 222 - "Cond only supports single-value consts", 223 - ); 224 - } 225 - const_.outs[0] 226 - } 227 - HirKind::Word(_) => { 228 - return error( 229 - pattern.span.clone(), 230 - Unexpected, 231 - "Cond only supports constant patterns", 232 - ) 233 - } 234 - HirKind::IgnorePattern => Type::ANY, 235 - hir => unreachable!("{:?}", hir), 236 - }; 237 - if !ty.type_eq(&pat_ty) { 238 - return error( 239 - pattern.span.clone(), 240 - TypeMismatch { 241 - expected: vec![ty], 242 - actual: vec![pat_ty], 243 - }, 244 - "Wrong type for cond pattern", 245 - ); 246 - } 247 - if first_branch { 248 - self.typecheck_body( 249 - name, 250 - items, 251 - &mut *body, 252 - &mut first_branch_stack, 253 - in_const, 254 - bindings, 255 - )?; 256 - } else { 257 - let mut branch_stack = TypeStack::default(); 258 - self.typecheck_body( 259 - name, 260 - items, 261 - &mut *body, 262 - &mut branch_stack, 263 - in_const, 264 - bindings, 265 - )?; 266 - if !first_branch_stack.eq(&branch_stack, &self.heap) { 267 - return error( 268 - node.span.clone(), 269 - TypeMismatch { 270 - expected: first_branch_stack.into_vec(&self.heap), 271 - actual: branch_stack.into_vec(&self.heap), 272 - }, 273 - "Type mismatch between cond branches", 274 - ); 275 - } 276 - } 277 - first_branch = false; 278 - } 279 - 280 - let first_branch_stack = first_branch_stack.into_vec(&self.heap); 281 - for ty in first_branch_stack.into_iter() { 282 - stack.push(&mut self.heap, ty) 283 - } 284 - 285 - ().okay() 286 - } 287 - 288 - fn typecheck_const( 289 - &mut self, 290 - const_name: &str, 291 - items: &mut FnvHashMap<String, TopLevel>, 292 - ) -> Result<()> { 293 - if self.output.contains_key(const_name) { 294 - return ().okay(); 295 - } 296 - let mut item = items.remove(const_name).ok_or_else(|| { 297 - TypecheckError::new( 298 - Span::point("".to_string(), 0), 299 - Undefined(const_name.to_string()), 300 - format!("Const `{}` does not exist", const_name), 301 - ) 302 - })?; 303 - let const_ = match &mut item { 304 - TopLevel::Const(c) => c, 305 - _ => unreachable!("This can't not be const"), 306 - }; 307 - self.visited.insert( 308 - const_name.to_string(), 309 - ItemKind::Const(ItemConst { 310 - types: const_.outs.clone(), 311 - }), 312 - ); 313 - 314 - let mut actual = TypeStack::default(); 315 - let mut expected = TypeStack::default(); 316 - let span = const_.span.clone(); 317 - for ty in &const_.outs { 318 - if ty.is_ptr() { 319 - return error( 320 - Span::point("".to_string(), 0), 321 - TypeMismatch { 322 - expected: vec![Type::ANY], 323 - actual: vec![*ty], 324 - }, 325 - format!("Const `{}` does not exist", const_name), 326 - ); 327 - } 328 - expected.push(&mut self.heap, *ty); 329 - } 330 - let mut bindings = Vec::new(); 331 - 332 - self.typecheck_body( 333 - const_name, 334 - items, 335 - &mut const_.body, 336 - &mut actual, 337 - true, 338 - &mut bindings, 339 - )?; 340 - 341 - if actual.eq(&expected, &self.heap) { 342 - self.output.insert(const_name.to_string(), item.clone()); 343 - ().okay() 344 - } else { 345 - error( 346 - span, 347 - TypeMismatch { 348 - expected: expected.into_vec(&self.heap), 349 - actual: actual.into_vec(&self.heap), 350 - }, 351 - "Const body does not equal const type", 352 - ) 353 - } 354 - } 355 - 356 - fn typecheck_mem( 357 - &mut self, 358 - mem_name: &str, 359 - items: &mut FnvHashMap<String, TopLevel>, 360 - ) -> Result<()> { 361 - if self.output.contains_key(mem_name) { 362 - return ().okay(); 363 - } 364 - self.visited.insert(mem_name.to_string(), ItemKind::Mem); 365 - let mut item = items.remove(mem_name).ok_or_else(|| { 366 - TypecheckError::new( 367 - Span::point("".to_string(), 0), 368 - Undefined(mem_name.to_string()), 369 - format!("Mem `{}` does not exist", mem_name), 370 - ) 371 - })?; 372 - let mem = match &mut item { 373 - TopLevel::Mem(m) => m, 374 - _ => unreachable!("This can't not be const"), 375 - }; 376 - 377 - let span = mem.span.clone(); 378 - let mut actual = TypeStack::default(); 379 - let mut expected = TypeStack::default(); 380 - 381 - expected.push(&mut self.heap, Type::U64); 382 - 383 - let mut bindings = Vec::new(); 384 - 385 - self.typecheck_body( 386 - mem_name, 387 - items, 388 - &mut mem.body, 389 - &mut actual, 390 - true, 391 - &mut bindings, 392 - )?; 393 - 394 - if actual.eq(&expected, &self.heap) { 395 - self.output.insert(mem_name.to_string(), item.clone()); 396 - ().okay() 397 - } else { 398 - error( 399 - span, 400 - TypeMismatch { 401 - expected: vec![Type::U64], 402 - actual: actual.into_vec(&self.heap), 403 - }, 404 - "Mem body must evaluate to U64", 405 - ) 406 - } 407 - } 408 - 409 - #[allow(clippy::too_many_arguments)] 410 - fn typecheck_if( 411 - &mut self, 412 - name: &str, 413 - items: &mut FnvHashMap<String, TopLevel>, 414 - if_: &mut If, 415 - span: &Span, 416 - stack: &mut TypeStack, 417 - in_const: bool, 418 - bindings: &mut Vec<Vec<(String, Type)>>, 419 - ) -> Result<()> { 420 - let (mut truth, mut lie) = (stack.clone(), stack.clone()); 421 - self.typecheck_body(name, items, &mut if_.truth, &mut truth, in_const, bindings)?; 422 - if let Some(lie_body) = &mut if_.lie { 423 - self.typecheck_body(name, items, &mut *lie_body, &mut lie, in_const, bindings)?; 424 - } else { 425 - return ().okay(); 426 - } 427 - if truth.eq(&lie, &self.heap) { 428 - *stack = truth; 429 - ().okay() 430 - } else { 431 - let (actual, expected) = (truth.into_vec(&self.heap), lie.into_vec(&self.heap)); 432 - error( 433 - span.clone(), 434 - TypeMismatch { actual, expected }, 435 - "If branches must leave stack in the same state", 436 - ) 437 - } 438 - } 439 - 440 - fn typecheck_boolean(&mut self, stack: &mut TypeStack, node: &HirNode) -> Result<()> { 441 - let b = stack.pop(&self.heap).ok_or_else(|| { 442 - TypecheckError::new( 443 - node.span.clone(), 444 - NotEnoughData, 445 - "Not enough data for binary operation", 446 - ) 447 - })?; 448 - let a = stack.pop(&self.heap).ok_or_else(|| { 449 - TypecheckError::new( 450 - node.span.clone(), 451 - NotEnoughData, 452 - "Not enough data for binary operation", 453 - ) 454 - })?; 455 - match (a, b) { 456 - (a, b) if a.type_eq(&b) => stack.push(&mut self.heap, Type::BOOL), 457 - (a, b) => { 458 - return error( 459 - node.span.clone(), 460 - TypeMismatch { 461 - actual: vec![b, a], 462 - expected: vec![a, a], 463 - }, 464 - "Wrong types for boolean operation", 465 - ) 466 - } 467 - } 468 - ().okay() 469 - } 470 - 471 - fn typecheck_divmod(&mut self, stack: &mut TypeStack, node: &HirNode) -> Result<()> { 472 - self.typecheck_binop(stack, node)?; 473 - stack.push(&mut self.heap, Type::U64); 474 - ().okay() 475 - } 476 - 477 - fn typecheck_binop(&mut self, stack: &mut TypeStack, node: &HirNode) -> Result<()> { 478 - let b = stack.pop(&self.heap).ok_or_else(|| { 479 - TypecheckError::new( 480 - node.span.clone(), 481 - NotEnoughData, 482 - "Not enough data for binary operation", 483 - ) 484 - })?; 485 - let a = stack.pop(&self.heap).ok_or_else(|| { 486 - TypecheckError::new( 487 - node.span.clone(), 488 - NotEnoughData, 489 - "Not enough data for binary operation", 490 - ) 491 - })?; 492 - 493 - if a == Type::U64 && b == Type::U64 { 494 - stack.push(&mut self.heap, Type::U64) 495 - } else if a == Type::I64 && b == Type::I64 { 496 - stack.push(&mut self.heap, Type::I64) 497 - } else { 498 - return error( 499 - node.span.clone(), 500 - TypeMismatch { 501 - actual: vec![b, a], 502 - expected: vec![b, b], 503 - }, 504 - "Wrong types for binary operation, must be 2 operands of type uint|int", 505 - ); 506 - } 507 - 508 - ().okay() 509 - } 510 - 511 - fn typecheck_body( 512 - &mut self, 513 - name: &str, 514 - items: &mut FnvHashMap<String, TopLevel>, 515 - body: &mut [HirNode], 516 - stack: &mut TypeStack, 517 - in_const: bool, 518 - bindings: &mut Vec<Vec<(String, Type)>>, 519 - ) -> Result<()> { 520 - for node in body { 521 - match &mut node.hir { 522 - HirKind::Literal(c) => match c { 523 - IConst::Bool(_) => stack.push(&mut self.heap, Type::BOOL), 524 - IConst::U64(_) => stack.push(&mut self.heap, Type::U64), 525 - IConst::I64(_) => stack.push(&mut self.heap, Type::I64), 526 - IConst::Ptr(_) => stack.push(&mut self.heap, Type::ptr_to(Type::U64)), 527 - IConst::Char(_) => stack.push(&mut self.heap, Type::CHAR), 528 - IConst::Str(_) => { 529 - stack.push(&mut self.heap, Type::U64); 530 - stack.push(&mut self.heap, Type::ptr_to(Type::CHAR)); 531 - } 532 - }, 533 - HirKind::Cond(_) => { 534 - self.typecheck_cond(name, items, node, stack, in_const, bindings)? 535 - } 536 - HirKind::Return => match self.visited.get(name) { 537 - Some(ItemKind::Proc(p)) => { 538 - let mut expected = TypeStack::default(); 539 - for &ty in &p.outs { 540 - expected.push(&mut self.heap, ty) 541 - } 542 - if !expected.eq(stack, &self.heap) { 543 - return error( 544 - node.span.clone(), 545 - TypeMismatch { 546 - expected: p.outs.clone(), 547 - actual: stack.clone().into_vec(&self.heap), 548 - }, 549 - "Type mismatched types for early return", 550 - ); 551 - } 552 - } 553 - Some(_) => { 554 - return error( 555 - node.span.clone(), 556 - Unexpected, 557 - "Return is not allowed in const", 558 - ) 559 - } 560 - None => unreachable!(), 561 - }, 562 - HirKind::Word(w) => match w.as_str() { 563 - rec if rec == name => { 564 - let proc = self 565 - .visited 566 - .get(rec) 567 - .and_then(|p| match p { 568 - ItemKind::Proc(p) => p.some(), 569 - _ => None, 570 - }) 571 - .ok_or_else(|| { 572 - TypecheckError::new( 573 - node.span.clone(), 574 - Unexpected, 575 - "Recursive const definition", 576 - ) 577 - })?; 578 - for ty_expected in proc.ins.iter().rev() { 579 - let ty_actual = stack.pop(&self.heap).ok_or_else(|| { 580 - TypecheckError::new( 581 - node.span.clone(), 582 - NotEnoughData, 583 - format!("Not enough data for proc invocation {}", rec), 584 - ) 585 - })?; 586 - if !ty_expected.type_eq(&ty_actual) { 587 - return error( 588 - node.span.clone(), 589 - TypeMismatch { 590 - expected: vec![*ty_expected], 591 - actual: vec![ty_actual], 592 - }, 593 - format!("Wrong types for proc invocation `{}`", rec), 594 - ); 595 - } 596 - } 597 - for ty in &proc.outs { 598 - stack.push(&mut self.heap, *ty) 599 - } 600 - } 601 - proc_name if self.is_proc(proc_name, items) => { 602 - if in_const { 603 - return error( 604 - node.span.clone(), 605 - CallInConst, 606 - "Proc calls not allowed in const context", 607 - ); 608 - } 609 - self.typecheck_proc(proc_name, items)?; 610 - let proc = self.visited[proc_name].as_proc().ok_or_else(|| { 611 - TypecheckError::new( 612 - node.span.clone(), 613 - Unexpected, 614 - "Recursive const definition", 615 - ) 616 - })?; 617 - for ty_expected in proc.ins.iter().rev() { 618 - let ty_actual = stack.pop(&self.heap).ok_or_else(|| { 619 - TypecheckError::new( 620 - node.span.clone(), 621 - NotEnoughData, 622 - format!("Not enough data for proc invocation {}", proc_name), 623 - ) 624 - })?; 625 - if !ty_expected.type_eq(&ty_actual) { 626 - return error( 627 - node.span.clone(), 628 - TypeMismatch { 629 - expected: vec![*ty_expected], 630 - actual: vec![ty_actual], 631 - }, 632 - format!("Wrong types for proc invocation {}", proc_name), 633 - ); 634 - } 635 - } 636 - let proc = self.output[proc_name].as_proc().ok_or_else(|| { 637 - TypecheckError::new( 638 - node.span.clone(), 639 - Unexpected, 640 - "Recursive const definition", 641 - ) 642 - })?; 643 - for ty in &proc.outs { 644 - stack.push(&mut self.heap, *ty) 645 - } 646 - } 647 - const_name if self.is_const(const_name, items) => { 648 - self.typecheck_const(const_name, items)?; 649 - let const_ = self.visited[const_name].as_const().ok_or_else(|| { 650 - TypecheckError::new( 651 - node.span.clone(), 652 - Unexpected, 653 - "Recursive const definition", 654 - ) 655 - })?; 656 - for ty in &const_.types { 657 - stack.push(&mut self.heap, *ty); 658 - } 659 - } 660 - mem_name if self.is_mem(mem_name, items) => { 661 - self.typecheck_mem(mem_name, items)?; 662 - 663 - stack.push(&mut self.heap, Type::ptr_to(Type::U8)); 664 - } 665 - lvar_name if self.is_local_var(name, lvar_name, items) => { 666 - let ty = items 667 - .get(name) 668 - .and_then(|p| p.as_proc()) 669 - .and_then(|p| p.vars.get(lvar_name)) 670 - .map(|lvar| lvar.ty) 671 - .or_else(|| { 672 - self.visited 673 - .get(name) 674 - .and_then(|p| p.as_proc()) 675 - .and_then(|p| p.vars.get(lvar_name)) 676 - .map(|v| v.ty) 677 - }) 678 - .unwrap(); 679 - 680 - stack.push(&mut self.heap, Type::ptr_to(ty)); 681 - } 682 - gvar_name if self.is_global_var(gvar_name, items) => { 683 - let item = &items[gvar_name]; 684 - let gvar = item.as_var().unwrap(); 685 - self.output.insert(gvar_name.to_string(), item.clone()); 686 - stack.push(&mut self.heap, Type::ptr_to(gvar.ty)); 687 - } 688 - binding_name if self.is_binding(binding_name, bindings) => { 689 - let ty = bindings 690 - .iter() 691 - .rev() 692 - .find_map(|bs| { 693 - bs.iter().find_map(|b| { 694 - if b.0 == binding_name { 695 - b.1.some() 696 - } else { 697 - None 698 - } 699 - }) 700 - }) 701 - .unwrap(); 702 - stack.push(&mut self.heap, ty); 703 - } 704 - word => { 705 - return error( 706 - node.span.clone(), 707 - Undefined(word.to_string()), 708 - "Encountered undefined word".to_string(), 709 - ) 710 - } 711 - }, 712 - HirKind::Intrinsic(i) => match i { 713 - Intrinsic::ReadU64 => { 714 - let ty = stack.pop(&self.heap).ok_or_else(|| { 715 - TypecheckError::new( 716 - node.span.clone(), 717 - NotEnoughData, 718 - "Not enough data for @u64", 719 - ) 720 - })?; 721 - if !ty.is_ptr_to(Type::U64) { 722 - return error( 723 - node.span.clone(), 724 - TypeMismatch { 725 - actual: vec![ty], 726 - expected: vec![Type::ptr_to(Type::U64)], 727 - }, 728 - "Wrong types for @u64", 729 - ); 730 - } 731 - stack.push(&mut self.heap, Type::U64) 732 - } 733 - Intrinsic::ReadU8 => { 734 - let ty = stack.pop(&self.heap).ok_or_else(|| { 735 - TypecheckError::new( 736 - node.span.clone(), 737 - NotEnoughData, 738 - "Not enough data for @u8", 739 - ) 740 - })?; 741 - if !ty.is_ptr_to(Type::U8) { 742 - return error( 743 - node.span.clone(), 744 - TypeMismatch { 745 - actual: vec![ty], 746 - expected: vec![Type::ptr_to(Type::U8)], 747 - }, 748 - "Wrong types for @u8", 749 - ); 750 - } 751 - stack.push(&mut self.heap, Type::U8) 752 - } 753 - Intrinsic::WriteU64 => { 754 - let ty = stack.pop(&self.heap).ok_or_else(|| { 755 - TypecheckError::new( 756 - node.span.clone(), 757 - NotEnoughData, 758 - "Not enough data for !u64", 759 - ) 760 - })?; 761 - let ty_store = stack.pop(&self.heap).ok_or_else(|| { 762 - TypecheckError::new( 763 - node.span.clone(), 764 - NotEnoughData, 765 - "Not enough data for !u64", 766 - ) 767 - })?; 768 - if !(ty.is_ptr_to(Type::U64) && ty_store == Type::U64) { 769 - return error( 770 - node.span.clone(), 771 - TypeMismatch { 772 - actual: vec![ty, ty_store], 773 - expected: vec![Type::ptr_to(Type::U64), Type::U64], 774 - }, 775 - "Wrong types for !u8", 776 - ); 777 - } 778 - } 779 - Intrinsic::WriteU8 => { 780 - let ty = stack.pop(&self.heap).ok_or_else(|| { 781 - TypecheckError::new( 782 - node.span.clone(), 783 - NotEnoughData, 784 - "Not enough data for !u8", 785 - ) 786 - })?; 787 - let ty_store = stack.pop(&self.heap).ok_or_else(|| { 788 - TypecheckError::new( 789 - node.span.clone(), 790 - NotEnoughData, 791 - "Not enough data for !u8", 792 - ) 793 - })?; 794 - if !(ty.is_ptr_to(Type::U8) && ty_store == Type::U8) { 795 - return error( 796 - node.span.clone(), 797 - TypeMismatch { 798 - actual: vec![ty, ty_store], 799 - expected: vec![Type::ptr_to(Type::U8), Type::U8], 800 - }, 801 - "Wrong types for !u8", 802 - ); 803 - } 804 - } 805 - &mut Intrinsic::Cast(ty) => { 806 - if !self.expect_arity(1, stack) { 807 - return error( 808 - node.span.clone(), 809 - NotEnoughData, 810 - "Not enough data on the stck for cast operation", 811 - ); 812 - } 813 - stack.push(&mut self.heap, ty) 814 - } 815 - 816 - Intrinsic::CompStop => { 817 - let types: Vec<_> = stack.clone().into_vec(&self.heap); 818 - println!("{:?}", types); 819 - return error(node.span.clone(), CompStop, ""); 820 - } 821 - 822 - Intrinsic::Syscall0 => { 823 - if !self.expect_arity(1, stack) { 824 - return error( 825 - node.span.clone(), 826 - NotEnoughData, 827 - "Not enough data for syscall3", 828 - ); 829 - } 830 - stack.push(&mut self.heap, Type::U64); 831 - } 832 - Intrinsic::Syscall1 => { 833 - if !self.expect_arity(2, stack) { 834 - return error( 835 - node.span.clone(), 836 - NotEnoughData, 837 - "Not enough data for syscall3", 838 - ); 839 - } 840 - stack.push(&mut self.heap, Type::U64); 841 - } 842 - Intrinsic::Syscall2 => { 843 - if !self.expect_arity(3, stack) { 844 - return error( 845 - node.span.clone(), 846 - NotEnoughData, 847 - "Not enough data for syscall3", 848 - ); 849 - } 850 - stack.push(&mut self.heap, Type::U64); 851 - } 852 - Intrinsic::Syscall3 => { 853 - if !self.expect_arity(4, stack) { 854 - return error( 855 - node.span.clone(), 856 - NotEnoughData, 857 - "Not enough data for syscall3", 858 - ); 859 - } 860 - stack.push(&mut self.heap, Type::U64); 861 - } 862 - Intrinsic::Syscall4 => { 863 - if !self.expect_arity(5, stack) { 864 - return error( 865 - node.span.clone(), 866 - NotEnoughData, 867 - "Not enough data for syscall3", 868 - ); 869 - } 870 - stack.push(&mut self.heap, Type::U64); 871 - } 872 - Intrinsic::Syscall5 => { 873 - if !self.expect_arity(6, stack) { 874 - return error( 875 - node.span.clone(), 876 - NotEnoughData, 877 - "Not enough data for syscall3", 878 - ); 879 - } 880 - stack.push(&mut self.heap, Type::U64); 881 - } 882 - Intrinsic::Syscall6 => { 883 - if !self.expect_arity(7, stack) { 884 - return error( 885 - node.span.clone(), 886 - NotEnoughData, 887 - "Not enough data for syscall3", 888 - ); 889 - } 890 - stack.push(&mut self.heap, Type::U64); 891 - } 892 - 893 - Intrinsic::Argc => { 894 - stack.push(&mut self.heap, Type::U64); 895 - } 896 - Intrinsic::Argv => { 897 - stack.push(&mut self.heap, Type::ptr_to(Type::ptr_to(Type::CHAR))); 898 - } 899 - 900 - Intrinsic::Print | Intrinsic::Drop => { 901 - stack.pop(&self.heap).ok_or_else(|| { 902 - TypecheckError::new( 903 - node.span.clone(), 904 - NotEnoughData, 905 - "Not enough data to pop", 906 - ) 907 - })?; 908 - } 909 - 910 - Intrinsic::Dup => { 911 - let ty = stack.pop(&self.heap).ok_or_else(|| { 912 - TypecheckError::new( 913 - node.span.clone(), 914 - NotEnoughData, 915 - "Not enough data to dup", 916 - ) 917 - })?; 918 - stack.push(&mut self.heap, ty); 919 - stack.push(&mut self.heap, ty); 920 - } 921 - Intrinsic::Swap => { 922 - let a = stack.pop(&self.heap).ok_or_else(|| { 923 - TypecheckError::new( 924 - node.span.clone(), 925 - NotEnoughData, 926 - "Not enough data to swap", 927 - ) 928 - })?; 929 - let b = stack.pop(&self.heap).ok_or_else(|| { 930 - TypecheckError::new( 931 - node.span.clone(), 932 - NotEnoughData, 933 - "Not enough data to swap", 934 - ) 935 - })?; 936 - stack.push(&mut self.heap, a); 937 - stack.push(&mut self.heap, b); 938 - } 939 - Intrinsic::Over => { 940 - let a = stack.pop(&self.heap).ok_or_else(|| { 941 - TypecheckError::new( 942 - node.span.clone(), 943 - NotEnoughData, 944 - "Not enough data to over", 945 - ) 946 - })?; 947 - let b = stack.pop(&self.heap).ok_or_else(|| { 948 - TypecheckError::new( 949 - node.span.clone(), 950 - NotEnoughData, 951 - "Not enough data to over", 952 - ) 953 - })?; 954 - stack.push(&mut self.heap, b); 955 - stack.push(&mut self.heap, a); 956 - stack.push(&mut self.heap, b); 957 - } 958 - Intrinsic::Add | Intrinsic::Sub | Intrinsic::Mul => { 959 - self.typecheck_binop(stack, node)? 960 - } 961 - Intrinsic::Divmod => self.typecheck_divmod(stack, node)?, 962 - Intrinsic::Eq 963 - | Intrinsic::Ne 964 - | Intrinsic::Lt 965 - | Intrinsic::Le 966 - | Intrinsic::Gt 967 - | Intrinsic::Ge => self.typecheck_boolean(stack, node)?, 968 - Intrinsic::Dump => (), 969 - }, 970 - HirKind::If(cond) => { 971 - let ty = stack.pop(&self.heap).ok_or_else(|| { 972 - TypecheckError::new( 973 - node.span.clone(), 974 - NotEnoughData, 975 - "Not enough data for if", 976 - ) 977 - })?; 978 - if !ty.type_eq(&Type::BOOL) { 979 - return error( 980 - node.span.clone(), 981 - TypeMismatch { 982 - actual: vec![ty], 983 - expected: vec![Type::BOOL], 984 - }, 985 - "If expects to consume a bool", 986 - ); 987 - } 988 - self.typecheck_if( 989 - name, 990 - items, 991 - cond, 992 - &node.span.clone(), 993 - stack, 994 - in_const, 995 - bindings, 996 - )?; 997 - } 998 - HirKind::While(while_) => { 999 - let stack_before = stack.clone().into_vec(&self.heap); 1000 - self.typecheck_body(name, items, &mut while_.cond, stack, in_const, bindings)?; 1001 - let ty = stack.pop(&self.heap).ok_or_else(|| { 1002 - TypecheckError::new( 1003 - node.span.clone(), 1004 - NotEnoughData, 1005 - "Not enough data for while", 1006 - ) 1007 - })?; 1008 - if !ty.type_eq(&Type::BOOL) { 1009 - return error( 1010 - node.span.clone(), 1011 - TypeMismatch { 1012 - actual: vec![ty], 1013 - expected: vec![Type::BOOL], 1014 - }, 1015 - "While expects to consume a bool", 1016 - ); 1017 - } 1018 - self.typecheck_body(name, items, &mut while_.body, stack, in_const, bindings)?; 1019 - if stack.clone().into_vec(&self.heap) != stack_before { 1020 - return error(node.span.clone(), InvalidWhile, "Invalid while"); 1021 - } 1022 - } 1023 - HirKind::Bind(bind) => { 1024 - let mut new_bindings = Vec::new(); 1025 - for binding in bind.bindings.iter().rev() { 1026 - match binding { 1027 - Binding::Ignore => { 1028 - stack.pop(&self.heap).ok_or_else(|| { 1029 - TypecheckError::new( 1030 - node.span.clone(), 1031 - NotEnoughData, 1032 - "Not enough data for binding", 1033 - ) 1034 - })?; 1035 - } 1036 - Binding::Bind { name, ty } => { 1037 - let actual = stack.pop(&self.heap).ok_or_else(|| { 1038 - TypecheckError::new( 1039 - node.span.clone(), 1040 - NotEnoughData, 1041 - "Not enough data for binding", 1042 - ) 1043 - })?; 1044 - if !actual.type_eq(ty) { 1045 - return error( 1046 - node.span.clone(), 1047 - TypeMismatch { 1048 - expected: vec![*ty], 1049 - actual: vec![actual], 1050 - }, 1051 - "Mismatched types for binding", 1052 - ); 1053 - } 1054 - new_bindings.push((name.clone(), *ty)); 1055 - } 1056 - } 1057 - } 1058 - bindings.push(new_bindings); 1059 - self.typecheck_body(name, items, &mut bind.body, stack, in_const, bindings)?; 1060 - } 1061 - HirKind::IgnorePattern => todo!(), // noop 1062 - HirKind::FieldAccess(f) => { 1063 - let ty = stack.pop(&self.heap).ok_or_else(|| { 1064 - TypecheckError::new( 1065 - node.span.clone(), 1066 - NotEnoughData, 1067 - "Not enough data for field access", 1068 - ) 1069 - })?; 1070 - let field = { 1071 - if let ValueType::Struct(s) = ty.value_type { 1072 - f.ty = s.some(); 1073 - &self.structs[s].fields[&f.field] 1074 - } else { 1075 - return error( 1076 - node.span.clone(), 1077 - Unexpected, 1078 - format!("Expected pointer to struct, got {:?}", ty), 1079 - ); 1080 - } 1081 - }; 1082 - stack.push(&mut self.heap, Type::ptr_to(field.ty)) 1083 - } 1084 - } 1085 - } 1086 - ().okay() 1087 - } 1088 - 1089 - fn expect_arity(&self, arity: usize, stack: &mut TypeStack) -> bool { 1090 - for _ in 0..arity { 1091 - if stack.pop(&self.heap).is_none() { 1092 - return false; 1093 - } 1094 - } 1095 - true 1096 - } 1097 - 1098 - fn is_proc(&self, name: &str, items: &FnvHashMap<String, TopLevel>) -> bool { 1099 - matches!(items.get(name), Some(TopLevel::Proc(_))) 1100 - || matches!(self.output.get(name), Some(TopLevel::Proc(_))) 1101 - || matches!(self.visited.get(name), Some(ItemKind::Proc(_))) 1102 - } 1103 - fn is_mem(&self, name: &str, items: &FnvHashMap<String, TopLevel>) -> bool { 1104 - matches!(items.get(name), Some(TopLevel::Mem(_))) 1105 - || matches!(self.output.get(name), Some(TopLevel::Mem(_))) 1106 - || matches!(self.visited.get(name), Some(ItemKind::Mem)) 1107 - } 1108 - fn is_binding(&self, name: &str, bindings: &[Vec<(String, Type)>]) -> bool { 1109 - bindings.iter().flatten().any(|b| b.0 == name) 1110 - } 1111 - fn is_const(&self, name: &str, items: &FnvHashMap<String, TopLevel>) -> bool { 1112 - matches!(items.get(name), Some(TopLevel::Const(_))) 1113 - || matches!(self.output.get(name), Some(TopLevel::Const(_))) 1114 - || matches!(self.visited.get(name), Some(ItemKind::Const(_))) 1115 - } 1116 - fn is_local_var( 1117 - &self, 1118 - cur_proc: &str, 1119 - name: &str, 1120 - items: &FnvHashMap<String, TopLevel>, 1121 - ) -> bool { 1122 - items 1123 - .get(cur_proc) 1124 - .and_then(|proc| proc.as_proc()) 1125 - .and_then(|proc| proc.vars.get(name)) 1126 - .is_some() 1127 - || self 1128 - .output 1129 - .get(cur_proc) 1130 - .and_then(|proc| proc.as_proc()) 1131 - .and_then(|proc| proc.vars.get(name)) 1132 - .is_some() 1133 - || self 1134 - .visited 1135 - .get(cur_proc) 1136 - .and_then(|proc| proc.as_proc()) 1137 - .and_then(|proc| proc.vars.get(name)) 1138 - .is_some() 1139 - } 1140 - fn is_global_var(&self, name: &str, items: &FnvHashMap<String, TopLevel>) -> bool { 1141 - matches!(items.get(name), Some(TopLevel::Var(_))) 1142 - || matches!(self.output.get(name), Some(TopLevel::Var(_))) 1143 - || matches!(self.visited.get(name), Some(ItemKind::Gvar(_))) 1144 - } 1145 - } 1146 42 1147 43 #[derive(Clone, Default)] 1148 - struct TypeStack { 44 + pub struct TypeStack { 1149 45 top: Option<TRef>, 1150 46 } 1151 47 1152 48 impl TypeStack { 1153 - pub fn push(&mut self, heap: &mut THeap, ty: Type) { 49 + pub fn push(&mut self, heap: &mut THeap, ty: tir::Type) { 1154 50 let frame = TypeFrame { 1155 51 ty, 1156 52 prev: self.top.clone(), ··· 1158 54 self.top = heap.alloc(frame).some(); 1159 55 } 1160 56 1161 - pub fn pop(&mut self, heap: &THeap) -> Option<Type> { 57 + pub fn pop(&mut self, heap: &THeap) -> Option<tir::Type> { 1162 58 if let Some(top) = self.top.clone() { 1163 59 let top = top.deref(heap).unwrap(); 1164 60 let prev = top.prev.clone(); 1165 61 self.top = prev; 1166 - top.ty.some() 62 + top.ty.clone().some() 1167 63 } else { 1168 64 None 1169 65 } ··· 1184 80 } else { 1185 81 return false; 1186 82 }; 1187 - if !lhs.ty.type_eq(&rhs.ty) { 83 + if lhs.ty != rhs.ty { 1188 84 break false; 1189 85 } 1190 86 next_left = &lhs.prev; ··· 1197 93 } 1198 94 } 1199 95 1200 - pub fn into_vec(self, heap: &THeap) -> Vec<Type> { 96 + pub fn into_vec(self, heap: &THeap) -> Vec<tir::Type> { 1201 97 let mut res = VecDeque::new(); 1202 98 let mut next = self.top; 1203 99 while let Some(top) = next { 1204 100 let top = top.deref(heap).unwrap(); 1205 - res.push_front(top.ty); 101 + res.push_front(top.ty.clone()); 1206 102 next = top.prev.clone() 1207 103 } 1208 104 res.into() ··· 1210 106 } 1211 107 1212 108 #[derive(Debug, Clone)] 1213 - struct TypeFrame { 1214 - ty: Type, 109 + pub struct TypeFrame { 110 + ty: tir::Type, 1215 111 prev: Option<TRef>, 1216 112 } 1217 113 1218 114 type TRef = Ref<TypeFrame, 0>; 1219 - type THeap = Heap<TypeFrame, 0>; 1220 - 1221 - #[test] 1222 - fn test_typecheck() { 1223 - use super::hir::{HirKind, HirNode, Proc}; 1224 - use std::assert_matches::assert_matches; 1225 - let procs = [( 1226 - "main".to_string(), 1227 - TopLevel::Proc(Proc { 1228 - ins: vec![], 1229 - outs: vec![Type::U64], 1230 - body: vec![HirNode { 1231 - span: Span::point("".to_string(), 0), 1232 - hir: HirKind::Literal(IConst::U64(1)), 1233 - }], 1234 - span: Span::point("".to_string(), 0), 1235 - vars: Default::default(), 1236 - }), 1237 - )] 1238 - .into_iter() 1239 - .collect(); 1240 - assert_matches!( 1241 - Typechecker::typecheck_program(procs, &StructIndex::default()), 1242 - Ok(_) 1243 - ); 1244 - } 115 + pub type THeap = Heap<TypeFrame, 0>;
+3 -8
rotth/src/types.rs
··· 67 67 value_type: ValueType::Any, 68 68 }; 69 69 70 - pub fn type_eq(&self, other: &Self) -> bool { 71 - if self.value_type == ValueType::Any || other.value_type == ValueType::Any { 72 - self.ptr_depth == other.ptr_depth 73 - } else { 74 - self.ptr_depth == other.ptr_depth && self.value_type == other.value_type 75 - } 76 - } 77 - 78 70 pub fn ptr_to(ty: Self) -> Self { 79 71 let ptr_depth = ty.ptr_depth + 1; 80 72 Self { ··· 202 194 fields: Default::default(), 203 195 name, 204 196 } 197 + } 198 + pub fn known(&self, name: &str) -> bool { 199 + self.structs.iter().any(|s| s.name == name) 205 200 } 206 201 pub fn id_names(&'_ self) -> impl Iterator<Item = (StructId, &'_ str)> { 207 202 self.structs