From 8cd4579bd897b98e288086d3336396a60eb05394 Mon Sep 17 00:00:00 2001 From: Robert-M-Lucas <100799838+Robert-M-Lucas@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:03:34 +0100 Subject: [PATCH] Continued import implementation --- .idea/workspace.xml | 29 +- build/out.asm | 624 +++++++++++++++--------------- build/out.o | Bin 4688 -> 4688 bytes build/out.out | Bin 18224 -> 18224 bytes src/root/compiler/compile.rs | 2 +- src/root/name_resolver/resolve.rs | 1 + src/root/parser/parse.rs | 3 +- src/root/parser/parse_imports.rs | 2 +- src/root/parser/path_storage.rs | 36 +- 9 files changed, 356 insertions(+), 341 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c1389b4..f260c49 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,11 +7,8 @@ - + - - - @@ -289,15 +286,7 @@ - - - - - @@ -740,7 +737,6 @@ - @@ -765,7 +761,8 @@ - diff --git a/build/out.asm b/build/out.asm index a0801fe..eaee14f 100644 --- a/build/out.asm +++ b/build/out.asm @@ -2,6 +2,230 @@ section .text +_12: + push rbp + mov rbp, rsp + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-8], rax + mov rdx, qword [rbp-8] + mov rax, qword [rdx+0] + mov qword [rbp-16], rax + mov rax, qword [rbp+24] + mov qword [rbp-24], rax + mov rax, qword [rbp-24] + mov qword [rbp-48], rax + mov rax, qword [rbp-16] + mov qword [rbp-56], rax + sub rsp, 0x0000000000000038 + call _17 + add rsp, 0x0000000000000038 + mov rax, qword [rbp-40] + mov qword [rbp+32], rax + leave + ret + + +_19: + push rbp + mov rbp, rsp + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-16], rax + mov rdx, qword [rbp-16] + mov rax, qword [rdx+0] + mov qword [rbp-8], rax + mov rdi, __8_fstr + mov rsi, [rbp-8] + mov al, 0 + sub rsp, 16 + extern printf + call printf + add rsp, 16 + mov rax, [rbp+16] + add rax, 0x0000000000000008 + mov qword [rbp-34], rax + mov rdx, qword [rbp-34] + mov rax, qword [rdx+0] + mov qword [rbp-26], rax + mov rax, qword [rbp-26] + cmp rax, 0 + jz __36_18 + mov byte [rbp-18], 0 + jmp __36_19 + __36_18: + mov byte [rbp-18], 1 + __36_19: + mov al, byte [rbp-18] + cmp al, 0 + jz __23_20 + mov byte [rbp-17], 0 + jmp __23_21 + __23_20: + mov byte [rbp-17], 1 + __23_21: + cmp byte [rbp-17], 0 + jz _19_22 + mov rax, [rbp+16] + add rax, 0x0000000000000008 + mov qword [rbp-42], rax + mov rdx, qword [rbp-42] + mov rax, qword [rdx+0] + mov qword [rbp-50], rax + mov rax, qword [rbp-50] + mov qword [rbp-58], rax + sub rsp, 0x000000000000003a + call _19 + add rsp, 0x000000000000003a + _19_23: + _19_22: + +leave +ret + +_10: + push rbp + mov rbp, rsp + mov qword [rbp+16], 0 + leave + ret + + +_13: + push rbp + mov rbp, rsp + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-17], rax + mov rdx, qword [rbp-17] + mov rax, qword [rdx+0] + mov qword [rbp-25], rax + mov rax, [rbp-25] + add rax, 0x0000000000000008 + mov qword [rbp-33], rax + mov rdx, qword [rbp-33] + mov rax, qword [rdx+0] + mov qword [rbp-9], rax + mov rax, qword [rbp-9] + cmp rax, 0 + jz __36_6 + mov byte [rbp-1], 0 + jmp __36_7 + __36_6: + mov byte [rbp-1], 1 + __36_7: + cmp byte [rbp-1], 0 + jz _13_8 + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-49], rax + mov rdx, qword [rbp-49] + mov rax, qword [rdx+0] + mov qword [rbp-57], rax + mov rax, [rbp-57] + add rax, 0x0000000000000000 + mov qword [rbp-65], rax + mov rdx, qword [rbp-65] + mov rax, qword [rdx+0] + mov qword [rbp-41], rax + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-81], rax + mov rdx, qword [rbp-81] + mov rax, qword [rdx+0] + mov qword [rbp-73], rax + mov rdi, qword [rbp-73] + sub rsp, 81 + extern free + call free + add rsp, 81 + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-89], rax + mov qword [rbp-97], 0 + mov rdx, qword [rbp-89] + mov rax, qword [rbp-97] + mov qword [rdx+0], rax + mov rax, qword [rbp-41] + mov qword [rbp+24], rax + leave + ret + _13_9: + _13_8: + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-41], rax + mov rdx, qword [rbp-41] + mov rax, qword [rdx+0] + mov qword [rbp-49], rax + mov rax, qword [rbp-49] + mov qword [rbp-65], rax + sub rsp, 0x0000000000000041 + call _18 + add rsp, 0x0000000000000041 + mov rax, qword [rbp-57] + mov qword [rbp+24], rax + leave + ret + + +_11: + push rbp + mov rbp, rsp + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-17], rax + mov rdx, qword [rbp-17] + mov rax, qword [rdx+0] + mov qword [rbp-9], rax + mov rax, qword [rbp-9] + cmp rax, 0 + jz __36_24 + mov byte [rbp-1], 0 + jmp __36_25 + __36_24: + mov byte [rbp-1], 1 + __36_25: + cmp byte [rbp-1], 0 + jz _11_27 + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-25], rax + mov rax, qword [rbp+24] + mov qword [rbp-41], rax + mov rax, qword [rbp-41] + mov qword [rbp-57], rax + sub rsp, 0x0000000000000039 + call _15 + add rsp, 0x0000000000000039 + mov rax, qword [rbp-49] + mov qword [rbp-33], rax + mov rdx, qword [rbp-25] + mov rax, qword [rbp-33] + mov qword [rdx+0], rax + jmp _11_26 + _11_27: + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-25], rax + mov rdx, qword [rbp-25] + mov rax, qword [rdx+0] + mov qword [rbp-33], rax + mov rax, qword [rbp+24] + mov qword [rbp-41], rax + mov rax, qword [rbp-41] + mov qword [rbp-65], rax + mov rax, qword [rbp-33] + mov qword [rbp-73], rax + sub rsp, 0x0000000000000049 + call _16 + add rsp, 0x0000000000000049 + _11_28: + _11_26: + +leave +ret + main: push rbp mov rbp, rsp @@ -120,35 +344,71 @@ main: ret -_10: +_14: push rbp mov rbp, rsp - mov qword [rbp+16], 0 - leave - ret + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-18], rax + mov rdx, qword [rbp-18] + mov rax, qword [rdx+0] + mov qword [rbp-10], rax + mov rax, qword [rbp-10] + cmp rax, 0 + jz __36_0 + mov byte [rbp-2], 0 + jmp __36_1 + __36_0: + mov byte [rbp-2], 1 + __36_1: + mov al, byte [rbp-2] + cmp al, 0 + jz __23_2 + mov byte [rbp-1], 0 + jmp __23_3 + __23_2: + mov byte [rbp-1], 1 + __23_3: + cmp byte [rbp-1], 0 + jz _14_4 + mov rax, [rbp+16] + add rax, 0x0000000000000000 + mov qword [rbp-26], rax + mov rdx, qword [rbp-26] + mov rax, qword [rdx+0] + mov qword [rbp-34], rax + mov rax, qword [rbp-34] + mov qword [rbp-42], rax + sub rsp, 0x000000000000002a + call _19 + add rsp, 0x000000000000002a + _14_5: + _14_4: +leave +ret -_11: +_16: push rbp mov rbp, rsp mov rax, [rbp+16] - add rax, 0x0000000000000000 + add rax, 0x0000000000000008 mov qword [rbp-17], rax mov rdx, qword [rbp-17] mov rax, qword [rdx+0] mov qword [rbp-9], rax mov rax, qword [rbp-9] cmp rax, 0 - jz __36_16 + jz __36_29 mov byte [rbp-1], 0 - jmp __36_17 - __36_16: + jmp __36_30 + __36_29: mov byte [rbp-1], 1 - __36_17: + __36_30: cmp byte [rbp-1], 0 - jz _11_19 + jz _16_32 mov rax, [rbp+16] - add rax, 0x0000000000000000 + add rax, 0x0000000000000008 mov qword [rbp-25], rax mov rax, qword [rbp+24] mov qword [rbp-41], rax @@ -162,10 +422,10 @@ _11: mov rdx, qword [rbp-25] mov rax, qword [rbp-33] mov qword [rdx+0], rax - jmp _11_18 - _11_19: + jmp _16_31 + _16_32: mov rax, [rbp+16] - add rax, 0x0000000000000000 + add rax, 0x0000000000000008 mov qword [rbp-25], rax mov rdx, qword [rbp-25] mov rax, qword [rdx+0] @@ -179,41 +439,17 @@ _11: sub rsp, 0x0000000000000049 call _16 add rsp, 0x0000000000000049 - _11_20: - _11_18: + _16_33: + _16_31: leave ret -_12: - push rbp - mov rbp, rsp - mov rax, [rbp+16] - add rax, 0x0000000000000000 - mov qword [rbp-8], rax - mov rdx, qword [rbp-8] - mov rax, qword [rdx+0] - mov qword [rbp-16], rax - mov rax, qword [rbp+24] - mov qword [rbp-24], rax - mov rax, qword [rbp-24] - mov qword [rbp-48], rax - mov rax, qword [rbp-16] - mov qword [rbp-56], rax - sub rsp, 0x0000000000000038 - call _17 - add rsp, 0x0000000000000038 - mov rax, qword [rbp-40] - mov qword [rbp+32], rax - leave - ret - - -_13: +_18: push rbp mov rbp, rsp mov rax, [rbp+16] - add rax, 0x0000000000000000 + add rax, 0x0000000000000008 mov qword [rbp-17], rax mov rdx, qword [rbp-17] mov rax, qword [rdx+0] @@ -226,16 +462,16 @@ _13: mov qword [rbp-9], rax mov rax, qword [rbp-9] cmp rax, 0 - jz __36_26 + jz __36_10 mov byte [rbp-1], 0 - jmp __36_27 - __36_26: + jmp __36_11 + __36_10: mov byte [rbp-1], 1 - __36_27: + __36_11: cmp byte [rbp-1], 0 - jz _13_28 + jz _18_12 mov rax, [rbp+16] - add rax, 0x0000000000000000 + add rax, 0x0000000000000008 mov qword [rbp-49], rax mov rdx, qword [rbp-49] mov rax, qword [rdx+0] @@ -247,7 +483,7 @@ _13: mov rax, qword [rdx+0] mov qword [rbp-41], rax mov rax, [rbp+16] - add rax, 0x0000000000000000 + add rax, 0x0000000000000008 mov qword [rbp-81], rax mov rdx, qword [rbp-81] mov rax, qword [rdx+0] @@ -258,7 +494,7 @@ _13: call free add rsp, 81 mov rax, [rbp+16] - add rax, 0x0000000000000000 + add rax, 0x0000000000000008 mov qword [rbp-89], rax mov qword [rbp-97], 0 mov rdx, qword [rbp-89] @@ -268,10 +504,10 @@ _13: mov qword [rbp+24], rax leave ret - _13_29: - _13_28: + _18_13: + _18_12: mov rax, [rbp+16] - add rax, 0x0000000000000000 + add rax, 0x0000000000000008 mov qword [rbp-41], rax mov rdx, qword [rbp-41] mov rax, qword [rdx+0] @@ -287,130 +523,6 @@ _13: ret -_14: - push rbp - mov rbp, rsp - mov rax, [rbp+16] - add rax, 0x0000000000000000 - mov qword [rbp-18], rax - mov rdx, qword [rbp-18] - mov rax, qword [rdx+0] - mov qword [rbp-10], rax - mov rax, qword [rbp-10] - cmp rax, 0 - jz __36_4 - mov byte [rbp-2], 0 - jmp __36_5 - __36_4: - mov byte [rbp-2], 1 - __36_5: - mov al, byte [rbp-2] - cmp al, 0 - jz __23_6 - mov byte [rbp-1], 0 - jmp __23_7 - __23_6: - mov byte [rbp-1], 1 - __23_7: - cmp byte [rbp-1], 0 - jz _14_8 - mov rax, [rbp+16] - add rax, 0x0000000000000000 - mov qword [rbp-26], rax - mov rdx, qword [rbp-26] - mov rax, qword [rdx+0] - mov qword [rbp-34], rax - mov rax, qword [rbp-34] - mov qword [rbp-42], rax - sub rsp, 0x000000000000002a - call _19 - add rsp, 0x000000000000002a - _14_9: - _14_8: - -leave -ret - -_15: - push rbp - mov rbp, rsp - mov rax, qword [rbp+16] - mov qword [rbp-16], rax - mov qword [rbp-8], 0 - mov rdi, 16 - sub rsp, 16 - extern malloc - call malloc - add rsp, 16 - mov qword [rbp-24], rax - mov rdx, qword [rbp-24] - mov rax, qword [rbp-16] - mov qword [rdx+0], rax - mov rax, qword [rbp-8] - mov qword [rdx+8], rax - mov rax, qword [rbp-24] - mov qword [rbp+24], rax - leave - ret - - -_16: - push rbp - mov rbp, rsp - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-17], rax - mov rdx, qword [rbp-17] - mov rax, qword [rdx+0] - mov qword [rbp-9], rax - mov rax, qword [rbp-9] - cmp rax, 0 - jz __36_21 - mov byte [rbp-1], 0 - jmp __36_22 - __36_21: - mov byte [rbp-1], 1 - __36_22: - cmp byte [rbp-1], 0 - jz _16_24 - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-25], rax - mov rax, qword [rbp+24] - mov qword [rbp-41], rax - mov rax, qword [rbp-41] - mov qword [rbp-57], rax - sub rsp, 0x0000000000000039 - call _15 - add rsp, 0x0000000000000039 - mov rax, qword [rbp-49] - mov qword [rbp-33], rax - mov rdx, qword [rbp-25] - mov rax, qword [rbp-33] - mov qword [rdx+0], rax - jmp _16_23 - _16_24: - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-25], rax - mov rdx, qword [rbp-25] - mov rax, qword [rdx+0] - mov qword [rbp-33], rax - mov rax, qword [rbp+24] - mov qword [rbp-41], rax - mov rax, qword [rbp-41] - mov qword [rbp-65], rax - mov rax, qword [rbp-33] - mov qword [rbp-73], rax - sub rsp, 0x0000000000000049 - call _16 - add rsp, 0x0000000000000049 - _16_25: - _16_23: - -leave -ret - _17: push rbp mov rbp, rsp @@ -419,14 +531,14 @@ _17: mov qword [rbp-17], 0 mov rax, qword [rbp-9] cmp rax, qword [rbp-17] - jz __16_0 + jz __16_14 mov byte [rbp-1], 0 - jmp __16_1 - __16_0: + jmp __16_15 + __16_14: mov byte [rbp-1], 1 - __16_1: + __16_15: cmp byte [rbp-1], 0 - jz _17_2 + jz _17_16 mov rax, [rbp+16] add rax, 0x0000000000000000 mov qword [rbp-25], rax @@ -435,8 +547,8 @@ _17: mov qword [rbp+32], rax leave ret - _17_3: - _17_2: + _17_17: + _17_16: mov rax, [rbp+16] add rax, 0x0000000000000008 mov qword [rbp-25], rax @@ -462,141 +574,29 @@ _17: ret -_18: +_15: push rbp mov rbp, rsp - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-17], rax - mov rdx, qword [rbp-17] - mov rax, qword [rdx+0] - mov qword [rbp-25], rax - mov rax, [rbp-25] - add rax, 0x0000000000000008 - mov qword [rbp-33], rax - mov rdx, qword [rbp-33] - mov rax, qword [rdx+0] - mov qword [rbp-9], rax - mov rax, qword [rbp-9] - cmp rax, 0 - jz __36_30 - mov byte [rbp-1], 0 - jmp __36_31 - __36_30: - mov byte [rbp-1], 1 - __36_31: - cmp byte [rbp-1], 0 - jz _18_32 - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-49], rax - mov rdx, qword [rbp-49] - mov rax, qword [rdx+0] - mov qword [rbp-57], rax - mov rax, [rbp-57] - add rax, 0x0000000000000000 - mov qword [rbp-65], rax - mov rdx, qword [rbp-65] - mov rax, qword [rdx+0] - mov qword [rbp-41], rax - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-81], rax - mov rdx, qword [rbp-81] - mov rax, qword [rdx+0] - mov qword [rbp-73], rax - mov rdi, qword [rbp-73] - sub rsp, 81 - extern free - call free - add rsp, 81 - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-89], rax - mov qword [rbp-97], 0 - mov rdx, qword [rbp-89] - mov rax, qword [rbp-97] + mov rax, qword [rbp+16] + mov qword [rbp-16], rax + mov qword [rbp-8], 0 + mov rdi, 16 + sub rsp, 16 + extern malloc + call malloc + add rsp, 16 + mov qword [rbp-24], rax + mov rdx, qword [rbp-24] + mov rax, qword [rbp-16] mov qword [rdx+0], rax - mov rax, qword [rbp-41] - mov qword [rbp+24], rax - leave - ret - _18_33: - _18_32: - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-41], rax - mov rdx, qword [rbp-41] - mov rax, qword [rdx+0] - mov qword [rbp-49], rax - mov rax, qword [rbp-49] - mov qword [rbp-65], rax - sub rsp, 0x0000000000000041 - call _18 - add rsp, 0x0000000000000041 - mov rax, qword [rbp-57] + mov rax, qword [rbp-8] + mov qword [rdx+8], rax + mov rax, qword [rbp-24] mov qword [rbp+24], rax leave ret -_19: - push rbp - mov rbp, rsp - mov rax, [rbp+16] - add rax, 0x0000000000000000 - mov qword [rbp-16], rax - mov rdx, qword [rbp-16] - mov rax, qword [rdx+0] - mov qword [rbp-8], rax - mov rdi, __8_fstr - mov rsi, [rbp-8] - mov al, 0 - sub rsp, 16 - extern printf - call printf - add rsp, 16 - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-34], rax - mov rdx, qword [rbp-34] - mov rax, qword [rdx+0] - mov qword [rbp-26], rax - mov rax, qword [rbp-26] - cmp rax, 0 - jz __36_10 - mov byte [rbp-18], 0 - jmp __36_11 - __36_10: - mov byte [rbp-18], 1 - __36_11: - mov al, byte [rbp-18] - cmp al, 0 - jz __23_12 - mov byte [rbp-17], 0 - jmp __23_13 - __23_12: - mov byte [rbp-17], 1 - __23_13: - cmp byte [rbp-17], 0 - jz _19_14 - mov rax, [rbp+16] - add rax, 0x0000000000000008 - mov qword [rbp-42], rax - mov rdx, qword [rbp-42] - mov rax, qword [rdx+0] - mov qword [rbp-50], rax - mov rax, qword [rbp-50] - mov qword [rbp-58], rax - sub rsp, 0x000000000000003a - call _19 - add rsp, 0x000000000000003a - _19_15: - _19_14: - -leave -ret - section .data_readonly __42_fstr db `\n`,0 __8_fstr db `Integer: %ld\n`,0 \ No newline at end of file diff --git a/build/out.o b/build/out.o index 03258740e0763071c2f4d20097444117535c1209..713f9791faf1313aea32efb1864398a9c76e614d 100644 GIT binary patch literal 4688 zcmbW4ZD>X7A#B+z{jiPUq&8{on^IJWT!%1)W#|SAagA1JtF#ey;7kd1 z%K{twFpx1&VZ)6%lnrUw2isvWicB3F>h@u}57P?iX7OKMh-f;te?tb}+{0*$G~%iBY-yzEA4lJYIkU z8XYpg8JXU3U^L>(CF*0qXvCvVdhaMI-r&v8h7#QoClflT=PeyR0)Eg*)xcbapa1Ns z5+QtOCp!FYB@8;E6`hX^1M{X?IB~P7{|2(&<8QtJzL> zH`Y7ybOJIt<}OU(RTO-41v=h(1LOeHK~ok8^F%#nB$-|7{)|nAfNSN6C9{6FWmZ2@ zKXhE5Gfv9IG{c0hVV;ZDb~EyD_C1WapV4c0lKrA1g$YZzAKTIs7WN7D$Z$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pV!A$Z>o4{At+WE`U~NCbrFm zRA;7HM59r-WA#9lb3L4M^+1R70)IUPS+4zX!?J=`O~Fgc(a1jclgw}nF3VUNyKN20 zWbV^WykFsch9ixQDtv(WXN3qL#t-*@_;upT6@Nc1)THoi@?TbXf#gf@7hh9^HB|5kcH;#tb%x>_8L^C1l|L}l zH0DwK8_B;>;nl<|6~2vleT@ITpdE?A+){68@I$51F7lgPp*gQi>WD8;_yOXb2^{Ai z`KQ3xQ=@Gfdz4VXSTp%^+#$meKh6-(S9m9JUEvoc_u&Qk72zrsG$_0$&Lic4AeXPi z)9ZeQ{Y(h2UueZlXqwPUjG!0Ao&qsZCzCEsUZG1922y=7(^?F=S4b-c>GTO{^oe*E zjk@Vb{X)k&%^wyz7RpC2su*#y4CvL01u{I*FIV(RNk*v!gjb3fNYzNy, ) -> Result<(GlobalDefinitionTable, HashMap), WErr> { let mut global_table = GlobalDefinitionTable::new(); + register_builtin(&mut global_table); let unprocessed_functions = resolve_names(ast, &mut global_table)?; diff --git a/src/root/parser/parse.rs b/src/root/parser/parse.rs index 9a95fb1..eb61ed4 100644 --- a/src/root/parser/parse.rs +++ b/src/root/parser/parse.rs @@ -35,7 +35,8 @@ pub fn parse(path_storage: &mut PathStorage) -> Result, WErr let base = Span::new_extra(&text, file_id); - let (after_use, new_files) = handle_error(parse_imports(base, path_storage, file_id), path_storage)?; + let (after_use, new_files) = + handle_error(parse_imports(base, path_storage, file_id), path_storage)?; path_queue.extend(new_files); let res = parse_toplevel::parse_toplevel(after_use); diff --git a/src/root/parser/parse_imports.rs b/src/root/parser/parse_imports.rs index 26a3078..897a5b6 100644 --- a/src/root/parser/parse_imports.rs +++ b/src/root/parser/parse_imports.rs @@ -44,7 +44,7 @@ pub fn parse_imports<'a>( } let (_, ids) = path_storage.get_id_and_add_to_file(current_file, is_use, path)?; - + for id in ids { found_paths.push((id, Location::from_span(&path))); } diff --git a/src/root/parser/path_storage.rs b/src/root/parser/path_storage.rs index 0c69666..ddd5604 100644 --- a/src/root/parser/path_storage.rs +++ b/src/root/parser/path_storage.rs @@ -1,11 +1,11 @@ -use std::collections::HashMap; -use std::fs; use crate::root::errors::parser_errors::create_custom_error; use crate::root::errors::WErr; use crate::root::parser::parse::{ErrorTree, ParseResult, Span}; use crate::root::utils::identify_first_last::IdentifyLast; use nom::character::complete::anychar; use nom::InputTake; +use std::collections::HashMap; +use std::fs; #[derive(Hash, Copy, Clone, Debug, Eq, PartialEq)] pub struct FileID(usize); @@ -52,7 +52,9 @@ pub struct PathStorage { impl PathStorage { pub fn new(main: &str) -> Result { // TODO: Only allow certain characters in base - if !main.ends_with(".why") { todo!() } + if !main.ends_with(".why") { + todo!() + } let main = &main[..main.len() - ".why".len()]; let mut folders = vec![CodeFolder::root()]; @@ -195,24 +197,38 @@ impl PathStorage { if is_folder { let folder = self.add_folder(section, current); if !is_use { - self.get_file_mut(current_file).imported_folders.push(folder); + self.get_file_mut(current_file) + .imported_folders + .push(folder); } let folder_path = self.reconstruct_folder(folder); let mut new_files = Vec::new(); - let Ok(subpaths) = fs::read_dir(folder_path) else { todo!() }; + let Ok(subpaths) = fs::read_dir(folder_path) else { + todo!() + }; for path in subpaths { let Ok(path) = path else { todo!() }; let Ok(t) = path.file_type() else { todo!() }; - if !t.is_file() { continue; } + if !t.is_file() { + continue; + } let path = path.path(); - if !path.extension().and_then(|e| e.to_str()).is_some_and(|e| e == "why") { + if !path + .extension() + .and_then(|e| e.to_str()) + .is_some_and(|e| e == "why") + { continue; } - let Some(name) = path.file_stem().and_then(|f| f.to_str()) else { todo!() }; + let Some(name) = path.file_stem().and_then(|f| f.to_str()) else { + todo!() + }; let (file, is_new) = self.add_file(name, folder); - if is_new { new_files.push(file); } + if is_new { + new_files.push(file); + } if is_use { self.get_file_mut(current_file).imported_files.push(file); } @@ -235,7 +251,7 @@ impl PathStorage { Ok(((), vec![file])) } else { Ok(((), vec![])) - } + }; } } else { current = self.add_folder(section, current);