From a807a54c800b1a87d002e488f44408906878a1de Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Wed, 7 Jul 2021 13:05:52 +0200 Subject: [PATCH] Initial implementation of node graph based on structs --- node-graph/.gitignore | 2 + node-graph/Cargo.lock | 1160 ++++++++++++++++++++++++++++++ node-graph/Cargo.toml | 14 + node-graph/LICENSE | 201 ++++++ node-graph/README.md | 2 + node-graph/proc-macro/Cargo.lock | 47 ++ node-graph/proc-macro/Cargo.toml | 15 + node-graph/proc-macro/src/lib.rs | 76 ++ node-graph/src/main.rs | 117 +++ 9 files changed, 1634 insertions(+) create mode 100644 node-graph/.gitignore create mode 100644 node-graph/Cargo.lock create mode 100644 node-graph/Cargo.toml create mode 100644 node-graph/LICENSE create mode 100644 node-graph/README.md create mode 100644 node-graph/proc-macro/Cargo.lock create mode 100644 node-graph/proc-macro/Cargo.toml create mode 100644 node-graph/proc-macro/src/lib.rs create mode 100644 node-graph/src/main.rs diff --git a/node-graph/.gitignore b/node-graph/.gitignore new file mode 100644 index 000000000..576f2002f --- /dev/null +++ b/node-graph/.gitignore @@ -0,0 +1,2 @@ +**/target + diff --git a/node-graph/Cargo.lock b/node-graph/Cargo.lock new file mode 100644 index 000000000..3a613aefc --- /dev/null +++ b/node-graph/Cargo.lock @@ -0,0 +1,1160 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "always-assert" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf688625d06217d5b1bb0ea9d9c44a1635fd0ee3534466388d18203174f4d11" +dependencies = [ + "log", +] + +[[package]] +name = "anymap" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" + +[[package]] +name = "arrayvec" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd" + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chalk-derive" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea1552e7666a857f5417e6051ce705ea6856ab2cda39be7605e5b626fa47416b" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "chalk-ir" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d7d5f1448dbac493541e97221f7f4c32326c4c76c6ecf543daf72a1dd93e66" +dependencies = [ + "bitflags", + "chalk-derive", + "lazy_static", +] + +[[package]] +name = "chalk-recursive" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0df406d2927321021b48acd193459dd33c913732155c93442d03f5ae8275385" +dependencies = [ + "chalk-derive", + "chalk-ir", + "chalk-solve", + "rustc-hash", + "tracing", +] + +[[package]] +name = "chalk-solve" +version = "0.68.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cbfcd5daa5ab8b1c9e5e10e83b0ac26271480f6ae5b5f35e5b19e1f6a0e6e37" +dependencies = [ + "chalk-derive", + "chalk-ir", + "ena", + "itertools", + "petgraph", + "rustc-hash", + "tracing", +] + +[[package]] +name = "countme" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" +dependencies = [ + "dashmap", + "once_cell", + "rustc-hash", +] + +[[package]] +name = "cov-mark" +version = "2.0.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d48d8f76bd9331f19fe2aaf3821a9f9fb32c3963e1e3d6ce82a8c09cef7444a" + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +dependencies = [ + "cfg-if", + "lazy_static", +] + +[[package]] +name = "dashmap" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" +dependencies = [ + "cfg-if", + "num_cpus", +] + +[[package]] +name = "dissimilar" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4b29f4b9bb94bf267d57269fd0706d343a160937108e9619fe380645428abb" + +[[package]] +name = "dot" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a74b6c4d4a1cff5f454164363c16b72fa12463ca6b31f4b5f2035a65fa3d5906" + +[[package]] +name = "drop_bomb" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "ena" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" +dependencies = [ + "log", +] + +[[package]] +name = "fixedbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "fst" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab85b9b05e3978cc9a9cf8fea7f01b494e1a09ed3037e16ba39edc7a29eb61a" + +[[package]] +name = "graph-ite" +version = "0.1.0" +dependencies = [ + "graph-proc-macros", + "ra_ap_ide", + "ra_ap_ide_db", +] + +[[package]] +name = "graph-proc-macros" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "memchr" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" + +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "perf-event" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5396562cd2eaa828445d6d34258ae21ee1eb9d40fe626ca7f51c8dccb4af9d66" +dependencies = [ + "libc", + "perf-event-open-sys", +] + +[[package]] +name = "perf-event-open-sys" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce9bedf5da2c234fdf2391ede2b90fabf585355f33100689bc364a3ea558561a" +dependencies = [ + "libc", +] + +[[package]] +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + +[[package]] +name = "proc-macro2" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + +[[package]] +name = "pulldown-cmark-to-cmark" +version = "6.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95048382115a9da7be92ad51c84064d585b7da17472dcaa7f5eed8853c4c3707" +dependencies = [ + "pulldown-cmark", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ra_ap_base_db" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad75dcbf16655060d015faee5c607e8f943692f12c7b9102d405081e42aad393" +dependencies = [ + "ra_ap_cfg", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_test_utils", + "ra_ap_tt", + "ra_ap_vfs", + "rustc-hash", + "salsa", +] + +[[package]] +name = "ra_ap_cfg" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45095a712964fe8293f5f535b72f6acbdb004b602e75c10554842c9483b2d35b" +dependencies = [ + "ra_ap_tt", + "rustc-hash", +] + +[[package]] +name = "ra_ap_hir" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebf894f290059ab250d159bc979659f85f7e1d9057310782ab867ba27a5de9cf" +dependencies = [ + "arrayvec", + "either", + "itertools", + "log", + "once_cell", + "ra_ap_base_db", + "ra_ap_cfg", + "ra_ap_hir_def", + "ra_ap_hir_expand", + "ra_ap_hir_ty", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_tt", + "rustc-hash", + "smallvec", +] + +[[package]] +name = "ra_ap_hir_def" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a5c4623546813f0c970e72591face7602f88df6cd29c41ac73e9fc8de4f1a9" +dependencies = [ + "anymap", + "cov-mark", + "dashmap", + "drop_bomb", + "either", + "fst", + "indexmap", + "itertools", + "log", + "once_cell", + "ra_ap_base_db", + "ra_ap_cfg", + "ra_ap_hir_expand", + "ra_ap_la-arena", + "ra_ap_mbe", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_tt", + "rustc-hash", + "smallvec", +] + +[[package]] +name = "ra_ap_hir_expand" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b75f701fd5bb2d75f56740e7640e4a88efb64cfe77a7161e7463dfc8fa2f1fa" +dependencies = [ + "either", + "log", + "ra_ap_base_db", + "ra_ap_cfg", + "ra_ap_la-arena", + "ra_ap_mbe", + "ra_ap_parser", + "ra_ap_profile", + "ra_ap_syntax", + "ra_ap_tt", + "rustc-hash", +] + +[[package]] +name = "ra_ap_hir_ty" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84432db1634ef0c0ec4af1df22e6a29b4195411c36bc2b499b18268c7c4a61e5" +dependencies = [ + "arrayvec", + "chalk-ir", + "chalk-recursive", + "chalk-solve", + "cov-mark", + "ena", + "itertools", + "log", + "once_cell", + "ra_ap_base_db", + "ra_ap_hir_def", + "ra_ap_hir_expand", + "ra_ap_la-arena", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "rustc-hash", + "scoped-tls", + "smallvec", +] + +[[package]] +name = "ra_ap_ide" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7708bf39deaf7144e3eb3717d2684e71a4c3f0d5dc5b99d64234328b9350ac5" +dependencies = [ + "cov-mark", + "dot", + "either", + "indexmap", + "itertools", + "log", + "oorandom", + "pulldown-cmark", + "pulldown-cmark-to-cmark", + "ra_ap_cfg", + "ra_ap_hir", + "ra_ap_ide_assists", + "ra_ap_ide_completion", + "ra_ap_ide_db", + "ra_ap_ide_diagnostics", + "ra_ap_ide_ssr", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_text_edit", + "rustc-hash", + "url", +] + +[[package]] +name = "ra_ap_ide_assists" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b774157bfc45644c87927d2267037149a9de8e7d15dcd096c4717e4579afb6f4" +dependencies = [ + "cov-mark", + "either", + "itertools", + "ra_ap_hir", + "ra_ap_ide_db", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_text_edit", + "rustc-hash", +] + +[[package]] +name = "ra_ap_ide_completion" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d0973fae1d3eae7a033edcc61fe183883ee49b92e78a643840403926f1d8dc" +dependencies = [ + "cov-mark", + "either", + "itertools", + "log", + "once_cell", + "ra_ap_base_db", + "ra_ap_hir", + "ra_ap_ide_db", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_text_edit", + "rustc-hash", +] + +[[package]] +name = "ra_ap_ide_db" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "199cb7e3fdd036a56d357fc73e8c6345f2d8016911bcb6acaed6e354d79e4a92" +dependencies = [ + "cov-mark", + "either", + "fst", + "itertools", + "log", + "once_cell", + "ra_ap_base_db", + "ra_ap_hir", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_text_edit", + "rayon", + "rustc-hash", +] + +[[package]] +name = "ra_ap_ide_diagnostics" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5393acf7e08b2f07f04bbc3589c33d5e84b839cb40a80b3be3ede15244055ee5" +dependencies = [ + "cov-mark", + "either", + "itertools", + "ra_ap_cfg", + "ra_ap_hir", + "ra_ap_ide_db", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_text_edit", + "rustc-hash", +] + +[[package]] +name = "ra_ap_ide_ssr" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "675a51104fb31f33535ad3445b29223b01c86474cfa2d8deed9f94b26db185b2" +dependencies = [ + "cov-mark", + "itertools", + "ra_ap_hir", + "ra_ap_ide_db", + "ra_ap_syntax", + "ra_ap_text_edit", + "rustc-hash", +] + +[[package]] +name = "ra_ap_la-arena" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c021212fed9211c9484e29669dbe56badb61aab5b50c43b2369147626ea1fc7" + +[[package]] +name = "ra_ap_mbe" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc9f4463afacc1c9c7f0996a5466cfa157c51afae25223e3da7c2556312eff8f" +dependencies = [ + "cov-mark", + "log", + "ra_ap_parser", + "ra_ap_stdx", + "ra_ap_syntax", + "ra_ap_tt", + "rustc-hash", + "smallvec", +] + +[[package]] +name = "ra_ap_parser" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3798fa72cd25c997af35e0af97fde3d18f3eb9021a5c66f51cf43386149ac8c" +dependencies = [ + "drop_bomb", +] + +[[package]] +name = "ra_ap_paths" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96445253d6f577843a6c290916d0be1c1b13ab415a5b8d6b169f996e24a019a1" + +[[package]] +name = "ra_ap_profile" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d6035f3193b630f7bffc9a22fbb626975cb73caa9a308916f77f441eeaccc6" +dependencies = [ + "cfg-if", + "countme", + "libc", + "once_cell", + "perf-event", + "ra_ap_la-arena", + "winapi", +] + +[[package]] +name = "ra_ap_stdx" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1affd8e72aa957fc9bc9ff840c0c319ae7addf2b30bb0232cc45553bc0ea3138" +dependencies = [ + "always-assert", + "libc", + "miow", + "winapi", +] + +[[package]] +name = "ra_ap_syntax" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e9a45ddbd92aae76a2a4b79e7c2246d54d2545a816cbabccdd7cc8f9e30c41c" +dependencies = [ + "arrayvec", + "cov-mark", + "indexmap", + "itertools", + "once_cell", + "ra_ap_parser", + "ra_ap_profile", + "ra_ap_stdx", + "ra_ap_text_edit", + "rowan", + "rustc-ap-rustc_lexer", + "rustc-hash", + "serde", + "smol_str", +] + +[[package]] +name = "ra_ap_test_utils" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721f6b0fceb429c3594accd4f0a0eb5dae8d42328a9fba4bb13c089acfabf106" +dependencies = [ + "dissimilar", + "ra_ap_profile", + "ra_ap_stdx", + "rustc-hash", + "text-size", +] + +[[package]] +name = "ra_ap_text_edit" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc90629006acaff9042011f64b063585f70d8a7e209be8667544543be138362" +dependencies = [ + "text-size", +] + +[[package]] +name = "ra_ap_tt" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62388fb1a2ab3e0448e89cc0fe1f90f821079799ba7262a2f482b5f0fdcb3307" +dependencies = [ + "ra_ap_stdx", + "smol_str", +] + +[[package]] +name = "ra_ap_vfs" +version = "0.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99af8a98fe67a3d167fec0c7a32b58c3d834059afd9eb20214f3f0e01503893e" +dependencies = [ + "fst", + "indexmap", + "ra_ap_paths", + "rustc-hash", +] + +[[package]] +name = "rayon" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rowan" +version = "0.13.0-pre.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9a7c0b71a45f8ba80c74d55a7d4b3ec611042d3b98ee56835b6af7b5e9f3f83" +dependencies = [ + "countme", + "hashbrown", + "memoffset", + "rustc-hash", + "text-size", +] + +[[package]] +name = "rustc-ap-rustc_lexer" +version = "721.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ba1f60e2942dc7dc5ea64edeaae01cfba2303871b14936e1af0f54d5420b3d1" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "salsa" +version = "0.17.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58038261ea8cd5a7730c4d8c97a22063d7c7eb1c2809e55c3c15f0a5903e5582" +dependencies = [ + "crossbeam-utils", + "indexmap", + "lock_api", + "log", + "oorandom", + "parking_lot", + "rustc-hash", + "salsa-macros", + "smallvec", +] + +[[package]] +name = "salsa-macros" +version = "0.17.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e2fc060627fa5d44bffac98f6089b9497779e2deccc26687f60adc2638e32fb" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "smol_str" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b203e79e90905594272c1c97c7af701533d42adaab0beb3859018e477d54a3b0" +dependencies = [ + "serde", +] + +[[package]] +name = "syn" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "text-size" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a" + +[[package]] +name = "tinyvec" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tracing" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/node-graph/Cargo.toml b/node-graph/Cargo.toml new file mode 100644 index 000000000..df4315694 --- /dev/null +++ b/node-graph/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "graph-ite" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[features] +rust_analyzer = ["ide", "ide_db"] + +[dependencies] +ide = { version = "*", package = "ra_ap_ide", optional = true } +ide_db = { version = "*", package = "ra_ap_ide_db" , optional = true } +graph-proc-macros = {path = "proc-macro"} diff --git a/node-graph/LICENSE b/node-graph/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/node-graph/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/node-graph/README.md b/node-graph/README.md new file mode 100644 index 000000000..0577998c4 --- /dev/null +++ b/node-graph/README.md @@ -0,0 +1,2 @@ +# NodeGraphExperiments +Repo for testing ideas for the upcoming Graphite node graph implementation diff --git a/node-graph/proc-macro/Cargo.lock b/node-graph/proc-macro/Cargo.lock new file mode 100644 index 000000000..f699244be --- /dev/null +++ b/node-graph/proc-macro/Cargo.lock @@ -0,0 +1,47 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "graph-proc-macros" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" diff --git a/node-graph/proc-macro/Cargo.toml b/node-graph/proc-macro/Cargo.toml new file mode 100644 index 000000000..f5f0bf0f8 --- /dev/null +++ b/node-graph/proc-macro/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "graph-proc-macros" +version = "0.1.0" +authors = ["Graphite Authors "] +edition = "2018" +publish = false + +[lib] +path = "src/lib.rs" +proc-macro = true + +[dependencies] +proc-macro2 = "1.0.26" +syn = { version = "1.0.68", features = ["full"] } +quote = "1.0.9" diff --git a/node-graph/proc-macro/src/lib.rs b/node-graph/proc-macro/src/lib.rs new file mode 100644 index 000000000..2a4433c59 --- /dev/null +++ b/node-graph/proc-macro/src/lib.rs @@ -0,0 +1,76 @@ +use proc_macro::TokenStream; +use quote::{quote, ToTokens}; +use syn::punctuated::Punctuated; +use syn::{parse_macro_input, FnArg, ItemFn, Pat, Type}; + +fn extract_type(a: FnArg) -> Box { + match a { + FnArg::Typed(p) => p.ty, // notice `ty` instead of `pat` + _ => panic!("Not supported on types with `self`!"), + } +} + +fn extract_arg_types(fn_args: Punctuated) -> Vec> { + return fn_args.into_iter().map(extract_type).collect::>(); +} + +fn extract_arg_idents(fn_args: Punctuated) -> Vec> { + return fn_args.into_iter().map(extract_arg_pat).collect::>(); +} + +fn extract_arg_pat(a: FnArg) -> Box { + match a { + FnArg::Typed(p) => p.pat, + _ => panic!("Not supported on types with `self`!"), + } +} + +#[proc_macro_attribute] // 2 +pub fn to_node(_attr: TokenStream, item: TokenStream) -> TokenStream { + let string = item.to_string(); + let item2 = item.clone(); + let parsed = parse_macro_input!(item2 as ItemFn); // 3 + //item.extend(generate_to_string(parsed, string)); // 4 + //item + generate_to_string(parsed, string) +} + +fn generate_to_string(parsed: ItemFn, string: String) -> TokenStream { + let whole_function = parsed.clone(); + //let fn_body = parsed.block; // function body + let sig = parsed.sig; // function signature + //let vis = parsed.vis; // visibility, pub or not + let generics = sig.generics; + let fn_args = sig.inputs; // comma separated args + let fn_return_type = sig.output; // return type + let fn_name = sig.ident; // function name/identifier + let idents = extract_arg_idents(fn_args.clone()); + let types = extract_arg_types(fn_args); + let types = types.iter().map(|t| t.to_token_stream()).collect::>(); + let idents = idents.iter().map(|t| t.to_token_stream()).collect::>(); + + let node_fn_name = syn::Ident::new(&(fn_name.to_string() + "_node"), proc_macro2::Span::call_site()); // function name/identifier + let return_type_string = fn_return_type.to_token_stream().to_string().replace("->",""); + let arg_type_string = types.iter().map(|t|t.to_string()).collect::>().join(", "); + let error = format!("called {} with the wrong type", fn_name.to_string()); + + let x = quote! { + //#whole_function + fn #node_fn_name #generics() -> Node { + Node { func: Box::new(move |x| { + let args = x.downcast::<(#(#types,)*)>().expect(#error); + let (#(#idents,)*) = *args; + #whole_function + + Box::new(#fn_name(#(#idents,)*)) + }), + code: #string.to_string(), + return_type: #return_type_string.trim().to_string(), + args: format!("({})",#arg_type_string.trim()), + } + } + + }; + //panic!("{}\n{:?}", x.to_string(), x); + x.into() +} diff --git a/node-graph/src/main.rs b/node-graph/src/main.rs new file mode 100644 index 000000000..3cffa9c78 --- /dev/null +++ b/node-graph/src/main.rs @@ -0,0 +1,117 @@ +use std::any::Any; + +type Function = Box) -> Box>; + +struct Node { + func: Function, + code: String, + return_type: String, + args: String, +} + +impl Node { + fn eval(&self, t: T) -> U { + *(self.func)(Box::new(t)).downcast::().unwrap() + } + #[allow(unused)] + fn id(self) -> Self { + self + } +} + +impl std::ops::Mul for Node { + type Output = Self; + fn mul(self, other: Self) -> Self { + node_compose(self, other) + } +} + +pub fn compose(g: G, f: F) -> Box V> +where + F: Fn(Fv) -> Gv, + G: Fn(Gv) -> V, +{ + Box::new(move |x| g(f(x))) +} + +fn node_compose(g: Node, f: Node) -> Node { + #[rustfmt::skip] + let Node { func: ff, code: fc, args: fa, return_type: fr} = f; + #[rustfmt::skip] + let Node { func, code, args, return_type } = g; + assert_eq!(args, fr); + Node { + func: Box::new(move |x| func(ff(x))), + code: fc + code.as_str(), // temporary TODO: replace + return_type, + args: fa, + } +} +#[graph_proc_macros::to_node] +fn id(t: T) -> T { + t +} + +#[graph_proc_macros::to_node] +fn gen_int() -> (u32, u32) { + (42, 43) +} +#[graph_proc_macros::to_node] +fn format_int(x: u32, y: u32) -> String { + x.to_string() + &y.to_string() +} + +#[graph_proc_macros::to_node] +fn curry_first_u32(x: u32, node: Node) -> Node { + assert_eq!(node.args[1..].split(",").next(), Some("u32")); + curry_first_arg_node::().eval((x, node)) +} + +#[graph_proc_macros::to_node] +fn curry_first_arg(x: T, node: Node) -> Node { + node_after_fn_node().eval::<(Node, Function), Node>(( + node, + Box::new(move |y: Box| { + Box::new((x.clone(), *y.downcast::().unwrap())) as Box + }) , + )) +} + +#[graph_proc_macros::to_node] +fn compose_node(g: Node, f: Node) -> Node { + node_compose(g, f) +} + +#[graph_proc_macros::to_node] +fn node_after_fn(g: Node, f: Box) -> Box>) -> Node { + let Node { + func, return_type, .. + } = g; + Node { + func: compose(func, f), + code: "unimplemented".to_string(), + return_type, + args: "".to_string(), + } +} + +#[graph_proc_macros::to_node] +fn node_from_fn(f: Box) -> Box>) -> Node { + node_after_fn_node().eval((id_node::>, f)) +} + +fn main() { + println!("{:?}",(format_int_node() * gen_int_node()).eval::<_, String>(())); + println!( + "{:?}", + curry_first_u32_node() + .eval::<(u32, Node), Node>((3, format_int_node())) + .eval::(43) + ); + println!( + "{:?}", + curry_first_arg_node::() + .eval::<(u32, Node), Node>((3, format_int_node())) + .eval::(43) + ); +}