diff --git a/.gitignore b/.gitignore index 7798b5e..f350853 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /target -out.json +log.txt diff --git a/Cargo.lock b/Cargo.lock index 8fee5c5..1a76572 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,41 +1,83 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "anyhow" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" + +[[package]] +name = "assert-unchecked" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7330592adf847ee2e3513587b4db2db410a0d751378654e7e993d9adcbe5c795" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] -name = "bitflags" -version = "2.3.3" +name = "backtrace" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] [[package]] -name = "bumpalo" -version = "3.13.0" +name = "bitflags" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] -name = "castaway" -version = "0.2.2" +name = "bumpalo" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" dependencies = [ - "rustversion", + "allocator-api2", ] [[package]] -name = "cc" -version = "1.0.81" +name = "castaway" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c6b2562119bf28c3439f7f02db99faf0aa1a8cdfe5772a2ee155d32227239f0" +checksum = "0abae9be0aaf9ea96a3b1b8b1b55c602ca751eba1b1500220cea4ecbafe7c0d5" dependencies = [ - "libc", + "rustversion", ] [[package]] @@ -46,22 +88,29 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "compact_str" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" +checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32" dependencies = [ "castaway", "cfg-if", "itoa", + "rustversion", "ryu", "static_assertions", ] +[[package]] +name = "cow-utils" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417bef24afe1460300965a25ff4a24b8b45ad011948302ec221e8a0a81eb2c79" + [[package]] name = "either" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "equivalent" @@ -70,352 +119,357 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "errno" -version = "0.3.2" +name = "fixedbitset" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "gimli" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - -[[package]] -name = "hermit-abi" -version = "0.3.2" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - -[[package]] -name = "index_vec" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74086667896a940438f2118212f313abba4aff3831fef6f4b17d02add5c8bb60" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "allocator-api2", +] [[package]] name = "indexmap" -version = "2.0.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", ] -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] - [[package]] name = "itertools" -version = "0.11.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] -name = "linux-raw-sys" -version = "0.4.5" +name = "memchr" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "miette" -version = "5.10.0" +name = "miniz_oxide" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ - "miette-derive", - "once_cell", - "thiserror", - "unicode-width", + "adler2", ] [[package]] -name = "miette-derive" -version = "5.10.0" +name = "nonmax" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ - "autocfg", "num-integer", "num-traits", ] [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] -name = "once_cell" -version = "1.18.0" +name = "object" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] [[package]] name = "owo-colors" -version = "3.5.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" [[package]] -name = "oxc" -version = "0.1.0" +name = "oxc-miette" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a0ebb0835907a97858b3f752b6a13da694b2a9dcdc82e42bd39a4c4424c6bb2" +checksum = "e03e63fd113c068b82d07c9c614b0b146c08a3ac0a4dface3ea1d1a9d14d549e" dependencies = [ - "oxc_allocator", - "oxc_ast", - "oxc_ast_lower", - "oxc_diagnostics", - "oxc_formatter", - "oxc_hir", - "oxc_index", - "oxc_minifier", - "oxc_parser", - "oxc_semantic", - "oxc_span", - "oxc_syntax", + "cfg-if", + "owo-colors", + "oxc-miette-derive", + "textwrap", + "thiserror", + "unicode-width 0.2.0", +] + +[[package]] +name = "oxc-miette-derive" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e21f680e8c5f1900297d394627d495351b9e37761f7bbf90116bd5eeb6e80967" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] name = "oxc_allocator" -version = "0.1.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3697bafacd571dc6d941c1eaaad599158a5218dddf175a14d7c03a34dd620f" +checksum = "dd69a857285f6519c595cfba74b91649b22b715169f11e2b4355f32b36c780c2" dependencies = [ + "allocator-api2", "bumpalo", - "serde", + "hashbrown", + "rustc-hash", + "simdutf8", ] [[package]] name = "oxc_ast" -version = "0.1.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5af212e55904ad7ea1f0937676bfeb446775908df51445a0b1d8a90c2428236" +checksum = "aeac0e9cfa9b40f04feb51d723a71279a985088c3df18d04e92e8a2d96385017" dependencies = [ "bitflags", + "cow-utils", "num-bigint", "num-traits", "oxc_allocator", - "oxc_index", + "oxc_ast_macros", + "oxc_estree", + "oxc_regular_expression", "oxc_span", "oxc_syntax", - "rustc-hash", ] [[package]] -name = "oxc_ast_lower" -version = "0.1.0" +name = "oxc_ast_macros" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0778ce79c77caa7695a27e0dcc34a7d2d4bbff91ee3c7019771baf7b5f890c23" +checksum = "4f3dfdfd34a28dd0258717a0a6e40c1f33bcf096c11f0b29a0930aca48b34b81" dependencies = [ - "oxc_allocator", - "oxc_ast", - "oxc_hir", - "oxc_semantic", - "oxc_span", - "stacker", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "oxc_diagnostics" -version = "0.1.0" +name = "oxc_cfg" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16dcde1fbb4b830ce5b2ab1447a3970b275a6bb38c5c4e7131f5adfabe325b05" +checksum = "8828ecb52029aeec2cc96039e407e9e64c3c343cb85a3ed7d7e17908f3013c10" dependencies = [ - "is-terminal", - "miette", - "owo-colors", - "textwrap", - "thiserror", - "unicode-width", + "bitflags", + "itertools", + "nonmax", + "oxc_index", + "oxc_syntax", + "petgraph", + "rustc-hash", ] [[package]] -name = "oxc_formatter" -version = "0.1.0" +name = "oxc_data_structures" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0f7e4c4b400a3a88f5f352beaca46cd727cc5badec8e2d75d195d06c51c3b7" +checksum = "150f668753d100a1709f2962f4000405e85b34feac675aec71c9cf158676a26a" dependencies = [ - "oxc_allocator", - "oxc_ast", - "oxc_span", - "oxc_syntax", + "assert-unchecked", + "ropey", ] [[package]] -name = "oxc_hir" -version = "0.1.0" +name = "oxc_diagnostics" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab39639fcbfa83b0c3450a3dfa79e3cfb1bc18043328bdd45bd0d4e9d3ee6d7" +checksum = "cc6d24b258ff0a030abaf64b0dcf66b7e0edd7a7a250982bee221a00518517b0" +dependencies = [ + "oxc-miette", +] + +[[package]] +name = "oxc_ecmascript" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2436fe122e749f834e8a8d9efe68f5d3b64e3c757424db0a897a289e173dfea1" dependencies = [ - "bitflags", "num-bigint", "num-traits", - "oxc_allocator", - "oxc_index", - "oxc_semantic", + "oxc_ast", "oxc_span", "oxc_syntax", ] +[[package]] +name = "oxc_estree" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae587120a6203d483ff0e3f36aa7b062cdffba829e9ebbfecc9e434f83a7db19" + [[package]] name = "oxc_index" -version = "0.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc021fc221d42f48a82849d057b62be095d178db6db919e8878b12bf2ac3ffd" -dependencies = [ - "index_vec", - "static_assertions", -] +checksum = "5eca5d9726cd0a6e433debe003b7bc88b2ecad0bb6109f0cef7c55e692139a34" [[package]] -name = "oxc_minifier" -version = "0.1.0" +name = "oxc_parser" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61d1318c769e99ac7bd0260c8e1da04518912c2eaf0c2192116f6ef5edb879b9" +checksum = "3012efb4a88efc6b24977a45254ef5f4e18490d47421bbefa11503198399bfa2" dependencies = [ + "assert-unchecked", "bitflags", - "itertools", + "cow-utils", + "memchr", "num-bigint", "num-traits", "oxc_allocator", "oxc_ast", - "oxc_ast_lower", - "oxc_hir", - "oxc_index", - "oxc_parser", - "oxc_semantic", + "oxc_diagnostics", + "oxc_ecmascript", + "oxc_regular_expression", "oxc_span", "oxc_syntax", + "rustc-hash", + "seq-macro", ] [[package]] -name = "oxc_parser" -version = "0.1.0" +name = "oxc_regular_expression" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a04ebe4a5308f6bb2a7c783e86a69451d41887685e08e7cb44034218d2cbe53e" +checksum = "f207437d0911f8f9e77efb680b7fc5a7000073fcf72072139cf95cac18e89f6c" dependencies = [ - "bitflags", - "num-bigint", "oxc_allocator", - "oxc_ast", + "oxc_ast_macros", "oxc_diagnostics", - "oxc_index", + "oxc_estree", "oxc_span", - "oxc_syntax", + "phf", "rustc-hash", + "unicode-id-start", ] [[package]] name = "oxc_semantic" -version = "0.1.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c3c6f54376a5242e868ed1ce0061c4fa56f343e0507e1a0078f2ef0b505847" +checksum = "3adfa6378abdef12ee82535f4c53018b46773e5ed91c4f0ca632e6e369fae89b" dependencies = [ - "bitflags", - "indexmap", + "assert-unchecked", + "itertools", + "oxc_allocator", "oxc_ast", + "oxc_cfg", + "oxc_data_structures", "oxc_diagnostics", + "oxc_ecmascript", "oxc_index", "oxc_span", "oxc_syntax", "phf", "rustc-hash", + "self_cell", ] [[package]] name = "oxc_span" -version = "0.1.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928b474c24d5e3d794de59bd3e29beafa2b45f8114236e0b04183d3d81e5d4de" +checksum = "8457acf582fa6139d91b6e28d839baf67fe8f0f1f427a3da15cb50e71b82e1f8" dependencies = [ "compact_str", - "miette", + "oxc-miette", + "oxc_allocator", + "oxc_ast_macros", + "oxc_estree", ] [[package]] name = "oxc_syntax" -version = "0.1.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a47093551a46220d581af1a4fe6eca62832bb306876ac861978a68278e60014" +checksum = "56135335adaf1c90d23851da0afb9960f191ef2f3fcd6f16cf16da2e6cfc339e" dependencies = [ + "assert-unchecked", "bitflags", + "cow-utils", + "nonmax", + "oxc_allocator", + "oxc_ast_macros", + "oxc_estree", "oxc_index", "oxc_span", + "phf", "rustc-hash", + "ryu-js", "unicode-id-start", ] +[[package]] +name = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "phf" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ "phf_macros", "phf_shared", @@ -423,9 +477,9 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared", "rand", @@ -433,9 +487,9 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" dependencies = [ "phf_generator", "phf_shared", @@ -446,47 +500,49 @@ dependencies = [ [[package]] name = "phf_shared" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ "siphasher", ] [[package]] -name = "proc-macro2" -version = "1.0.66" +name = "pin-project-lite" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" -dependencies = [ - "unicode-ident", -] +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] -name = "psm" -version = "0.1.21" +name = "proc-macro2" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ - "cc", + "unicode-ident", ] [[package]] name = "queso" version = "0.1.0" dependencies = [ - "cc", - "oxc", + "anyhow", + "oxc_allocator", + "oxc_ast", + "oxc_parser", + "oxc_semantic", + "oxc_span", "serde", "serde_json", + "tokio", "walkdir", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -507,35 +563,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] -name = "rustc-hash" -version = "1.1.0" +name = "ropey" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93411e420bcd1a75ddd1dc3caf18c23155eda2c090631a85af21ba19e97093b5" +dependencies = [ + "smallvec", + "str_indices", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] -name = "rustix" -version = "0.38.6" +name = "rustc-hash" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee020b1716f0a80e2ace9b03441a749e402e86712f15f16fe8a8f75afac732f" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" + +[[package]] +name = "ryu-js" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "ad97d4ce1560a5e27cec89519dc8300d1aa6035b099821261c651486a19e44d5" [[package]] name = "same-file" @@ -546,20 +611,32 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "self_cell" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe" + +[[package]] +name = "seq-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" + [[package]] name = "serde" -version = "1.0.181" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3e73c93c3240c0bda063c239298e633114c69a888c3e37ca8bb33f343e9890" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.181" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be02f6cb0cd3a5ec20bbcfbcbd749f57daddb1a0882dc2e46a6c236c90b977ed" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -568,39 +645,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "siphasher" -version = "0.3.10" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] -name = "smawk" -version = "0.3.1" +name = "smallvec" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] -name = "stacker" -version = "0.1.15" +name = "smawk" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" -dependencies = [ - "cc", - "cfg-if", - "libc", - "psm", - "winapi", -] +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "static_assertions" @@ -608,11 +685,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "str_indices" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08889ec5408683408db66ad89e0e1f93dff55c73a4ccc71c427d5b277ee47e6" + [[package]] name = "syn" -version = "2.0.28" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -621,29 +704,51 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", "unicode-linebreak", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio" +version = "1.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +dependencies = [ + "backtrace", + "pin-project-lite", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -652,15 +757,15 @@ dependencies = [ [[package]] name = "unicode-id-start" -version = "1.1.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e15598ae4ac01f33d64525526e028beb497b216015dd768c44187a62b44cbce8" +checksum = "2f322b60f6b9736017344fa0635d64be2f458fbc04eef65f6be22976dd1ffd5b" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "unicode-linebreak" @@ -670,69 +775,54 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] -name = "walkdir" -version = "2.3.3" +name = "unicode-width" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" -dependencies = [ - "same-file", - "winapi-util", -] +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" [[package]] -name = "winapi" -version = "0.3.9" +name = "walkdir" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "same-file", + "winapi-util", ] -[[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-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -741,42 +831,48 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index 9b045fc..4aa9979 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,13 +3,15 @@ name = "queso" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -oxc = "0.1" -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0", features = ["std"] } -walkdir="2.3" - -[build-dependencies] -cc="*" +walkdir = "2" +oxc_ast = { version = "0.48" } +oxc_allocator = { version = "0.48" } +oxc_parser = { version = "0.48" } +oxc_semantic = { version = "0.48" } +oxc_span = { version = "0.48" } +tokio = { version = "1.43", features = ["macros", "rt-multi-thread"] } +anyhow = "1.0" +serde = "1.0" +serde_json = "1.0" diff --git a/Makefile b/Makefile index 91eb214..e70da07 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -all: - cargo run && echo && echo "############### out.json content ###############" && echo && cat out.json +run: + cargo run -test: - cargo test -- --nocapture +js: + node test-dir/index.js diff --git a/src/document/mod.rs b/src/document/mod.rs deleted file mode 100644 index 784d0c2..0000000 --- a/src/document/mod.rs +++ /dev/null @@ -1,55 +0,0 @@ -use oxc::{allocator::Allocator, span::SourceType}; - -pub struct Document<'a> { - uri: String, - content: String, - allocator: &'a Allocator, - source_type: SourceType, -} - -impl<'a> Document<'a> { - pub fn new(uri: String, content: String, allocator: &'a Allocator) -> Self { - Self { - uri: uri.clone(), - content, - allocator, - source_type: SourceType::from_path(uri.clone()).unwrap(), - } - } - - /// Parse the document to extract functions - /// - input type definitions - /// - return types - pub fn parse(&self) { - println!("{}", self.content); - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_function_names() { - let source_text = r#" -function giveMeThat(data, config) { - console.log(data.id); - console.log(data.items, data["id"]); - const input = data.items[0].id; - - call(input); -} - -function call({ token }, { config }, ...args) { - console.log(toast); -} - -giveMeThat(data); - "#; - - let allocator = Allocator::default(); - let document = Document::new("test.js".to_owned(), source_text.to_owned(), &allocator); - - let ret = document.parse(); - } -} diff --git a/src/evaluate/block.rs b/src/evaluate/block.rs deleted file mode 100644 index 97310e2..0000000 --- a/src/evaluate/block.rs +++ /dev/null @@ -1,92 +0,0 @@ -use std::path::Path; - -use oxc::{ - allocator::Allocator, - ast::AstKind, - parser::{Parser, ParserReturn}, - span::SourceType, -}; - -/// Represents either a Block statement or a function statement -struct Block<'a> { - // will come back to this - allocator: &'a Allocator, - source_type: SourceType, - source_text: String, -} - -impl<'a> Block<'a> { - /// Get all the defined variables in the block - /// and their tentative types - pub fn evaluate(&self) {} - - pub fn from_file(file_path: &Path, allocator: &'a Allocator) -> Self { - let source_text = std::fs::read_to_string(file_path).unwrap(); - let source_type = SourceType::from_path(file_path).unwrap(); - - Self { - allocator, - source_type, - source_text, - } - } - - pub fn from_source( - source_text: String, - source_type: SourceType, - allocator: &'a Allocator, - ) -> Self { - Self { - allocator, - source_type, - source_text, - } - } - - pub fn parse(&'a self) -> ParserReturn<'a> { - let parser_ret = - Parser::new(self.allocator, self.source_text.as_str(), self.source_type).parse(); - - parser_ret - } -} - -#[cfg(test)] -mod test { - use crate::evaluate::visitor::Visitor; - use oxc::{allocator::Allocator, ast::Visit, span::SourceType}; - - use super::Block; - - #[test] - fn test_function_names() { - let source_text = r#" -function giveMeThat(data, config) { - console.log(data.id); - console.log(data.items, data["id"]); - const input = data.items[0].id; - - call(input); -} - -function call({ token }, { config }, ...args) { - console.log(toast); -} - -giveMeThat(data); - "#; - - let allocator = Allocator::default(); - let block = Block::from_source( - source_text.to_string(), - SourceType::from_path("index.js").unwrap(), - &allocator, - ); - - let ret = block.parse(); - let program = allocator.alloc(ret.program); - - let mut visitor = Visitor::new(source_text); - visitor.visit_program(program); - } -} diff --git a/src/evaluate/mod.rs b/src/evaluate/mod.rs deleted file mode 100644 index 1f1d404..0000000 --- a/src/evaluate/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -use oxc::{ - allocator::Allocator, - parser::{Parser, ParserReturn}, - span::SourceType, -}; - -mod block; -mod visitor; diff --git a/src/evaluate/visitor.rs b/src/evaluate/visitor.rs deleted file mode 100644 index 42721e0..0000000 --- a/src/evaluate/visitor.rs +++ /dev/null @@ -1,166 +0,0 @@ -use crate::types::Serializer; -use oxc::ast::{ - ast::{ComputedMemberExpression, Expression, FormalParameters}, - AstKind, Visit, -}; -use serde_json::{json, Value}; -use std::collections::HashMap; - -pub(super) struct Visitor<'a> { - // how to store the type of the variable such that it can later be verified - source_text: &'a str, - variables: HashMap, - scope: u8, - is_variable: bool, - is_callee: bool, - functions: Vec<&'a str>, - functions_data: Value, - callee: String, - tracked_variables: Vec<&'a str>, -} - -#[derive(Debug)] -struct QuesoFunction { - name: String, -} - -#[allow(unused)] -impl<'a> Visitor<'a> { - fn print(&self, input: &str) { - // println!( - // "[{}] {}() {}", - // self.scope, - // self.functions.last().unwrap_or(&""), - // input - // ); - } - - pub fn new(source_text: &'a str) -> Self { - Self { - source_text, - variables: HashMap::new(), - functions: Vec::new(), - functions_data: json!({}), - scope: 0, - is_variable: false, - is_callee: false, - callee: String::new(), - tracked_variables: Vec::new(), - } - } - - fn visit_function_parameters(&self, function_name: String) {} -} - -#[allow(unused)] -impl<'a> Visit<'a> for Visitor<'a> { - fn enter_node(&mut self, kind: AstKind<'a>) { - match &kind { - AstKind::IdentifierReference(iden) => { - println!("IDEN, REFERE {}", iden.name); - } - AstKind::VariableDeclarator(decl) => { - // process variable to get the initial type - self.is_variable = true; - } - AstKind::BindingIdentifier(iden) => { - if self.is_variable { - self.tracked_variables.push(iden.name.as_str()); - self.print(iden.name.as_str()); - } - } - AstKind::Function(function) => { - if let Some(name) = &function.id { - let function_name = name.name.as_str(); - - self.functions_data[function_name] = json!({ "name": function_name}); - self.functions.push(function_name); - } - self.scope += 1; - } - AstKind::BlockStatement(block) => { - self.scope += 1; - } - AstKind::CallExpression(call) => { - self.is_callee = true; - } - _ => {} - } - } - - fn leave_node(&mut self, kind: AstKind<'a>) { - match &kind { - AstKind::VariableDeclarator(decl) => { - self.is_variable = false; - } - AstKind::Function(function) => { - let source_text = self.source_text; - - if let Some(name) = &function.id { - let function_name = self.functions.pop().unwrap_or(""); - let mut value = self.functions_data[&function_name].to_string(); - value.push('\n'); - - self.functions_data - .as_object_mut() - .unwrap() - .remove(&function_name.to_owned()); - } - // println!("variables: {:#?}", self.tracked_variables); - self.scope -= 1; - } - AstKind::BlockStatement(block) => { - self.scope -= 1; - } - AstKind::CallExpression(call) => {} - _ => { - self.is_callee = true; - } - } - } - - fn visit_formal_parameters(&mut self, params: &'a FormalParameters<'a>) { - if params.rest.is_some() { - // println!("WARNING: RestElement is not handled yet!"); - } - - let cur_function = self.functions.last().unwrap(); - let mut function_params: Vec = vec![]; - - for (index, param) in (0_u8..).zip(¶ms.items) { - let params = param.pattern.serialize().unwrap(); - let mut param_name = params.name; - if params.is_phantom { - param_name = format!("<{}-{index}>", param_name); - } - - // println!("params: {param_name}"); - function_params.push(Value::String(param_name)); - } - self.functions_data[cur_function]["params"] = Value::Array(function_params); - - if let Some(rest) = ¶ms.rest { - self.visit_rest_element(rest); - } - } - - fn visit_computed_member_expression(&mut self, expr: &'a ComputedMemberExpression<'a>) { - let cur_function = &self.functions.last().unwrap(); - - if let Expression::Identifier(iden) = &expr.object { - if let Expression::StringLiteral(value) = &expr.expression { - self.functions_data[cur_function]["variables"] = Value::Array(vec![]); - self.print(format!("{}[{}]", iden.name, value.value).as_str()); - } - } - } - - fn visit_static_member_expression( - &mut self, - expr: &'a oxc::ast::ast::StaticMemberExpression<'a>, - ) { - if let Expression::Identifier(iden) = &expr.object { - self.print(format!("{}.{}", iden.name, expr.property.name).as_str()); - } - } -} diff --git a/src/main.rs b/src/main.rs index 60c5fd0..a54546f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,26 +1,111 @@ -use crate::types::object::Serializer; -use oxc::{ - allocator::Allocator, - ast::{ - ast::{ComputedMemberExpression, Expression, FormalParameters}, - AstKind, Visit, - }, - parser::Parser, - span::SourceType, -}; -use queso::Queso; -use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; -use std::{collections::HashMap, fs::OpenOptions}; -use std::{fs::File, io::Write}; - -mod document; -mod evaluate; -mod queso; -mod types; - -fn main() { - let folder_name = "./test-dir"; - let allocator = Allocator::default(); - let queso = Queso::new(folder_name, &allocator); +use anyhow::Result; +use oxc_allocator::Allocator; +use oxc_ast::AstKind; +use oxc_parser::{Parser, ParserReturn}; +use oxc_semantic::{AstNode, Reference, Semantic, SemanticBuilder, SemanticBuilderReturn}; +use oxc_span::{GetSpan, SourceType}; +use std::ffi::OsStr; +use walkdir::WalkDir; + +fn debug_ast_node(node: &AstNode, semantic: &Semantic) { + let nodes = semantic.nodes(); + let mut answer = None; + + for ancestor in nodes.ancestors(node.id()) { + match ancestor.kind() { + AstKind::Program(_) => {} + _ => { + answer = Some(ancestor); + } + } + } + + if let Some(answer) = answer { + let span = answer.span(); + println!( + "[DBG_AST_NODE] {:?} {}", + answer.scope_id(), + semantic + .source_text() + .get((span.start as usize)..(span.end as usize)) + .unwrap() + ); + } +} + +fn debug_reference(reference: &Reference, semantic: &Semantic) { + let id = reference.symbol_id().unwrap(); + let references = semantic.symbol_references(id); + + debug_ast_node(semantic.nodes().get_node(reference.node_id()), semantic); + + for refer in references { + if refer.symbol_id() != reference.symbol_id() { + debug_reference(refer, semantic); + } + } +} + +#[tokio::main] +async fn main() -> Result<()> { + for entry in WalkDir::new("./test-dir").into_iter().flatten() { + if entry.path().extension() == Some(OsStr::new("js")) { + println!("{}", entry.path().display()); + let source_path = entry.path(); + let source_text = std::fs::read_to_string(entry.path())?; + let allocator = Allocator::default(); + let source_type = SourceType::from_path(source_path)?; + + let mut errors = Vec::new(); + let ParserReturn { + program, + errors: parsing_errors, + panicked, + .. + } = Parser::new(&allocator, source_text.as_str(), source_type).parse(); + + errors.extend(parsing_errors); + + if panicked { + for error in &errors { + eprintln!("{error:?}"); + } + + panic!("Parsing failed."); + } + + let SemanticBuilderReturn { + semantic, + errors: semantic_errors, + } = SemanticBuilder::new().build(&program); + + errors.extend(semantic_errors); + + if !errors.is_empty() { + for error in errors { + eprintln!("{error:?}"); + } + + panic!("Failed to build Semantic for Counter component."); + } + + let symbol_table = semantic.symbols(); + + for id in symbol_table.symbol_ids() { + if symbol_table.get_name(id) == "call" { + let references = semantic.symbol_references(id); + let declaration = semantic.symbol_declaration(id); + + print!("DECLARATION:"); + debug_ast_node(declaration, &semantic); + + for reference in references { + debug_reference(reference, &semantic); + } + } + } + } + } + + Ok(()) } diff --git a/src/queso.rs b/src/queso.rs deleted file mode 100644 index 8aa1e49..0000000 --- a/src/queso.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::{rc::Rc, sync::Arc}; - -use oxc::allocator::Allocator; -use walkdir::WalkDir; - -use crate::document::Document; - -pub struct Queso<'a> { - documents: Vec>, -} - -impl<'a> Queso<'a> { - pub fn new(folder_name: &'a str, allocator: &'a Allocator) -> Self { - let mut paths: Vec = Vec::new(); - for path in WalkDir::new(folder_name) - .into_iter() - .filter_map(Result::ok) - .filter(|e| !e.file_type().is_dir()) - { - let content = std::fs::read_to_string(path.path()).unwrap(); - let document = Document::new(path.path().to_str().unwrap().into(), content, allocator); - - paths.push(document); - } - - println!("{}", paths.len()); - - Self { - documents: Vec::new(), - } - } -} diff --git a/src/types/mod.rs b/src/types/mod.rs deleted file mode 100644 index 8014a75..0000000 --- a/src/types/mod.rs +++ /dev/null @@ -1,252 +0,0 @@ -pub mod object; -pub use object::Serializer; -use oxc::{ - ast::{ - ast::{CallExpression, Declaration, Expression, Function, Statement}, - AstKind, - }, - semantic::AstNode, -}; - -trait Traverse { - fn traverse(&self); -} - -#[allow(unused)] -impl<'a> Traverse for Statement<'a> { - fn traverse(&self) { - match &self { - Statement::BlockStatement(statement) => {} - Statement::BreakStatement(statement) => {} - Statement::ContinueStatement(statement) => {} - Statement::DebuggerStatement(statement) => {} - Statement::DoWhileStatement(statement) => {} - Statement::EmptyStatement(statement) => {} - Statement::ExpressionStatement(statement) => { - statement.expression.traverse(); - } - Statement::ForInStatement(statement) => {} - Statement::ForOfStatement(statement) => {} - Statement::ForStatement(statement) => {} - Statement::IfStatement(statement) => {} - Statement::LabeledStatement(statement) => {} - Statement::ReturnStatement(statement) => {} - Statement::SwitchStatement(statement) => {} - Statement::ThrowStatement(statement) => {} - Statement::TryStatement(statement) => {} - Statement::WhileStatement(statement) => {} - Statement::WithStatement(statement) => {} - Statement::ModuleDeclaration(statement) => {} - Statement::Declaration(statement) => { - statement.traverse(); - } - } - } -} - -#[allow(unused)] -impl<'a> Traverse for Declaration<'a> { - fn traverse(&self) { - match &self { - Declaration::VariableDeclaration(declaration) => {} - Declaration::FunctionDeclaration(declaration) => { - println!("{:#?}", declaration.id); - println!("{:#?}", declaration.params); - } - Declaration::ClassDeclaration(declaration) => {} - Declaration::TSTypeAliasDeclaration(declaration) => {} - Declaration::TSInterfaceDeclaration(declaration) => {} - Declaration::TSEnumDeclaration(declaration) => {} - Declaration::TSModuleDeclaration(declaration) => {} - Declaration::TSImportEqualsDeclaration(declaration) => {} - } - } -} - -#[allow(unused)] -impl<'a> Traverse for CallExpression<'a> { - fn traverse(&self) { - println!("Args: {:#?}", self.arguments); - } -} - -#[allow(unused)] -impl<'a> Traverse for Expression<'a> { - fn traverse(&self) { - match &self { - Expression::BooleanLiteral(expr) => {} - Expression::NullLiteral(expr) => {} - Expression::NumberLiteral(expr) => {} - Expression::BigintLiteral(expr) => {} - Expression::RegExpLiteral(expr) => {} - Expression::StringLiteral(expr) => {} - Expression::TemplateLiteral(expr) => {} - - Expression::Identifier(expr) => {} - - Expression::MetaProperty(expr) => {} - Expression::Super(expr) => {} - - Expression::ArrayExpression(expr) => {} - Expression::ArrowExpression(expr) => {} - Expression::AssignmentExpression(expr) => {} - Expression::AwaitExpression(expr) => {} - Expression::BinaryExpression(expr) => {} - Expression::CallExpression(expr) => { - expr.traverse(); - } - Expression::ChainExpression(expr) => {} - Expression::ClassExpression(expr) => {} - Expression::ConditionalExpression(expr) => {} - Expression::FunctionExpression(expr) => {} - Expression::ImportExpression(expr) => {} - Expression::LogicalExpression(expr) => {} - Expression::MemberExpression(expr) => {} - Expression::NewExpression(expr) => {} - Expression::ObjectExpression(expr) => {} - Expression::ParenthesizedExpression(expr) => {} - Expression::SequenceExpression(expr) => {} - Expression::TaggedTemplateExpression(expr) => {} - Expression::ThisExpression(expr) => {} - Expression::UnaryExpression(expr) => {} - Expression::UpdateExpression(expr) => {} - Expression::YieldExpression(expr) => {} - Expression::PrivateInExpression(expr) => {} - - Expression::JSXElement(expr) => {} - Expression::JSXFragment(expr) => {} - - Expression::TSAsExpression(expr) => {} - Expression::TSSatisfiesExpression(expr) => {} - Expression::TSTypeAssertion(expr) => {} - Expression::TSNonNullExpression(expr) => {} - Expression::TSInstantiationExpression(expr) => {} - } - } -} - -impl<'a> Traverse for Function<'a> { - fn traverse(&self) { - println!("{:#?}", self.params.items); - - // extract what are the properties we are referring to, for the argument - if let Some(body) = &self.body { - for item in body.statements.iter() { - item.traverse(); - } - } - } -} - -#[allow(unused)] -impl<'a> Traverse for AstKind<'a> { - fn traverse(&self) { - match &self { - AstKind::Program(item) => {} - AstKind::Directive(item) => {} - AstKind::Hashbang(item) => {} - - AstKind::BlockStatement(item) => {} - AstKind::BreakStatement(item) => {} - AstKind::ContinueStatement(item) => {} - AstKind::DebuggerStatement(item) => {} - AstKind::DoWhileStatement(item) => {} - AstKind::EmptyStatement(item) => {} - AstKind::ExpressionStatement(item) => {} - AstKind::ForInStatement(item) => {} - AstKind::ForOfStatement(item) => {} - AstKind::ForStatement(item) => {} - AstKind::ForStatementInit(item) => {} - AstKind::IfStatement(item) => {} - AstKind::LabeledStatement(item) => {} - AstKind::ReturnStatement(item) => {} - AstKind::SwitchStatement(item) => {} - AstKind::ThrowStatement(item) => {} - AstKind::TryStatement(item) => {} - AstKind::WhileStatement(item) => {} - AstKind::WithStatement(item) => {} - - AstKind::SwitchCase(item) => {} - AstKind::CatchClause(item) => {} - AstKind::FinallyClause(item) => {} - - AstKind::VariableDeclaration(item) => {} - AstKind::VariableDeclarator(item) => {} - - AstKind::IdentifierName(item) => {} - AstKind::IdentifierReference(item) => {} - AstKind::BindingIdentifier(item) => {} - AstKind::LabelIdentifier(item) => {} - AstKind::PrivateIdentifier(item) => {} - - AstKind::NumberLiteral(item) => {} - AstKind::StringLiteral(item) => {} - AstKind::BooleanLiteral(item) => {} - AstKind::NullLiteral(item) => {} - AstKind::BigintLiteral(item) => {} - AstKind::RegExpLiteral(item) => {} - AstKind::TemplateLiteral(item) => {} - - AstKind::MetaProperty(item) => {} - AstKind::Super(item) => {} - - AstKind::ArrayExpression(item) => {} - AstKind::ArrowExpression(item) => {} - AstKind::AssignmentExpression(item) => {} - AstKind::AwaitExpression(item) => {} - AstKind::BinaryExpression(item) => {} - AstKind::CallExpression(item) => {} - AstKind::ConditionalExpression(item) => {} - AstKind::LogicalExpression(item) => {} - AstKind::MemberExpression(item) => {} - AstKind::NewExpression(item) => {} - AstKind::ObjectExpression(item) => {} - AstKind::ParenthesizedExpression(item) => {} - AstKind::SequenceExpression(item) => {} - AstKind::TaggedTemplateExpression(item) => {} - AstKind::ThisExpression(item) => {} - AstKind::UnaryExpression(item) => {} - AstKind::UpdateExpression(item) => {} - AstKind::YieldExpression(item) => {} - - AstKind::ObjectProperty(item) => {} - AstKind::PropertyKey(item) => {} - AstKind::Argument(item) => {} - AstKind::AssignmentTarget(item) => {} - AstKind::SimpleAssignmentTarget(item) => {} - AstKind::AssignmentTargetWithDefault(item) => {} - AstKind::ArrayExpressionElement(item) => {} - AstKind::Elision(span) => {} - AstKind::SpreadElement(item) => {} - AstKind::RestElement(item) => {} - - AstKind::Function(item) => { - item.traverse(); - } - AstKind::FunctionBody(item) => {} - AstKind::FormalParameters(item) => {} - AstKind::FormalParameter(item) => {} - - AstKind::Class(item) => {} - AstKind::ClassHeritage(item) => {} - AstKind::StaticBlock(item) => {} - AstKind::PropertyDefinition(item) => {} - AstKind::MethodDefinition(item) => {} - - AstKind::ArrayPattern(item) => {} - AstKind::ObjectPattern(item) => {} - AstKind::AssignmentPattern(item) => {} - - AstKind::Decorator(item) => {} - - AstKind::ModuleDeclaration(item) => {} - _ => {} - } - } -} - -impl<'a> Traverse for AstNode<'a> { - fn traverse(&self) { - self.kind().traverse(); - } -} diff --git a/src/types/object.rs b/src/types/object.rs deleted file mode 100644 index 6f6c26b..0000000 --- a/src/types/object.rs +++ /dev/null @@ -1,75 +0,0 @@ -use oxc::ast::ast::{BindingPattern, BindingPatternKind, ObjectPattern, PropertyKey}; -use serde::{Deserialize, Serialize}; -use serde_json::Value; - -#[derive(Debug, Serialize, Deserialize, Default)] -pub struct Variable { - pub name: String, - pub is_phantom: bool, - /// leaf properties which are in scope of the function - pub exposed_properties: Vec, -} - -impl Variable { - pub fn new(name: String, is_phantom: bool) -> Self { - Self { - name, - is_phantom, - ..Default::default() - } - } -} - -#[allow(unused)] -pub trait Serializer { - fn serialize(&self) -> Option; -} - -#[allow(unused)] -impl<'a> Serializer for BindingPattern<'a> { - fn serialize(&self) -> Option { - match &self.kind { - BindingPatternKind::BindingIdentifier(pattern) => { - Some(Variable::new(pattern.name.to_string(), false)) - } - // BindingPatternKind::ObjectPattern(pattern) => pattern.serialize(), - BindingPatternKind::ArrayPattern(pattern) => { - println!("ArrayPattern: {:#?}", pattern); - Some(Variable::new("param".to_owned(), true)) - } - // BindingPatternKind::AssignmentPattern(pattern) => None, - _ => Some(Variable::new("param".to_owned(), true)), - } - } -} - -impl<'a> Serializer for ObjectPattern<'a> { - fn serialize(&self) -> Option { - todo!("serializer for ObjectPattern"); - // let mut result = json!({}); - // self.properties.iter().for_each(|_x| { - // let key = x - // .key - // .serialize() - // .unwrap_or(Value::String("".to_owned())); - // let value = x - // .value - // .serialize() - // .unwrap_or(Value::String("".to_owned())); - - // result[key.as_str().unwrap().to_string()] = value; - // }); - - // Some(result) - } -} - -impl<'a> Serializer for PropertyKey<'a> { - fn serialize(&self) -> Option { - match &self { - PropertyKey::Identifier(iden) => Some(Value::String(iden.name.to_string())), - PropertyKey::PrivateIdentifier(iden) => Some(Value::String(iden.name.to_string())), - PropertyKey::Expression(_expr) => None, - } - } -} diff --git a/test-dir/factory.js b/test-dir/factory.js new file mode 100644 index 0000000..a25f88e --- /dev/null +++ b/test-dir/factory.js @@ -0,0 +1,11 @@ +const factory = { + test: (data) => { + var test_symbol = 0; + console.log(data.id); + }, +}; + +export const call = () => { + factory.test({ id: 1 }); +}; +const test_symbol_root = 0; diff --git a/test-dir/index.js b/test-dir/index.js index eefb8f1..b08cc83 100644 --- a/test-dir/index.js +++ b/test-dir/index.js @@ -1,14 +1,37 @@ -function giveMeThat(data, config) { - console.log(data.id); - console.log(data.items, data["id"]); - const input = data.items[0].id; +import { call } from "./factory.js"; - call(input); -} +const functionFactory = { + mainFunction: () => { + call(); + }, + testFunction: () => { + return new Promise((resolve, reject) => { + call(); + resolve("1"); + }); + }, +}; -function call({ token }, { config }, ...args) { - console.log(toast); -} +const main = () => { + call(); -giveMeThat(data); + Object.values(functionFactory).forEach((fn) => { + console.log(fn()); + }); +}; +(() => { + // what will be this function + call(); +})(); + +const unrelatedScope = () => {}; + +main(); +/** + * References of call()? + * - functionFactory.mainFunction(); + * - functionFactory.testFunction(); + * - + * - main(); + */ diff --git a/test-dir/package.json b/test-dir/package.json new file mode 100644 index 0000000..605a676 --- /dev/null +++ b/test-dir/package.json @@ -0,0 +1,13 @@ +{ + "name": "test-dir", + "version": "1.0.0", + "description": "", + "main": "index.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +}