diff --git a/README.md b/README.md index 2d3009a9..49a41c71 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ build/run: Time safe prim tests with self-hosted compiler: -`time ./primSafe.bqn path/to/mlochbaum/BQN | ./BQN` +`time ./test.bqn path/to/mlochbaum/BQN -s prim | ./BQN` Test precompiled safe prim tests: 1. uncomment [this](https://github.com/dzaima/CBQN/blob/528279b8e3e0fb108868f47b7bdfe772c26f10c3/src/main.c#L101-L106) -2. `./test.bqn path/to/mlochbaum/BQN "$PATH"` +2. `./precompiled.bqn path/to/mlochbaum/BQN "$PATH"` Any file without an explicit copyright message is copyright (c) 2021 dzaima, GNU GPLv3 - see LICENSE \ No newline at end of file diff --git a/precompiled.bqn b/precompiled.bqn new file mode 100755 index 00000000..b01f86d4 --- /dev/null +++ b/precompiled.bqn @@ -0,0 +1,29 @@ +#! /usr/bin/env dbqn +"Usage: ./precompiled.bqn path/to/mlochbaum/BQN ""$PATH"" [expressions, else prim tests]"!2≤≠•args +path←0⊑•args +envP←1⊑•args + +tests ← •FLines path∾"/test/cases/prim.bqn" +# tests ← •FLines path∾"/test/cases/identity.bqn" +# tests ← •FLines path∾"/test/cases/undo.bqn" +# tests ← •FLines path∾"/test/cases/under.bqn" +# tests ← •FLines path∾"/test/cases/fill.bqn" +{tests↩𝕩}⍟(×≠) 2↓•args + +('#'≠ ·⊑ ∾⟜"#")◶@‿{ + '%'⊸∊◶{𝕤 + •Out 𝕩 + "src/interp" •FChars ⟨1,path,𝕩⟩ •Import "cc.bqn" + (×⊑)◶@‿{𝕤⋄•Out "############ Failed to compile! ############" ⋄ •Out¨1↓𝕩}{env⇐<"PATH="∾envP}•SH"./debugBuild" + code‿out‿err←•SH"./BQN" + •Out out + {𝕤⋄•Out"exit code "∾(⍕code) ⋄ •Out err}⍟(×code) err + }‿{𝕤 + # •Out 𝕩 + # "src/interp" •FChars ⟨1,path,3↓𝕩⟩ •Import "cc.bqn" + # (×⊑)◶@‿{𝕤⋄•Out "############ Failed to compile! ############" ⋄ •Out¨1↓𝕩}{env⇐<"PATH="∾envP}•SH"./debugBuild" + # code‿out‿err←•SH"./BQN" + # •Out out + # {𝕤⋄•Out"exit code "∾(⍕code) ⋄ •Out err}⍟(×code) err + } +}¨tests \ No newline at end of file diff --git a/primSafe.bqn b/primSafe.bqn deleted file mode 100755 index 2f28a573..00000000 --- a/primSafe.bqn +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dbqn -"Usage: ./primSafe.bqn path/to/mlochbaum/BQN | ./BQN"!1≤≠•args -path←⊑•args -case←"prim" -{case↩⊑𝕩}⍟(×≠) 1↓•args -case∾↩".bqn" - - -('%'⊸∊∨ '#'= ·⊑ ∾⟜"#")◶•Out‿@¨•FLines path∾"/test/cases/"∾case -•Out """finished""" -•Out "" \ No newline at end of file diff --git a/src/vm.c b/src/vm.c index c6b92d2d..734fd2e8 100644 --- a/src/vm.c +++ b/src/vm.c @@ -295,7 +295,7 @@ B evalBC(Body* b, Scope* sc) { // doesn't consume vmStack[stackNum] = bcPos; for(i32 i = 0; i < bcDepth; i++) printf(" "); printBC(sbc); printf("@%d << ", bcPos); - for (i32 i = 0; i < sh; i++) { if(i)printf(" ⋄ "); print(stack[i]); } puts(""); fflush(stdout); + for (i32 i = 0; i < b->maxStack; i++) { if(i)printf(" ⋄ "); print(gStack[i]); } puts(""); fflush(stdout); bcCtr++; for (i32 i = 0; i < sc->varAm; i++) validate(sc->vars[i]); #endif @@ -384,7 +384,7 @@ B evalBC(Body* b, Scope* sc) { // doesn't consume #ifdef DEBUG_VM for(i32 i = 0; i < bcDepth; i++) printf(" "); printBC(sbc); printf("@%ld: ", sbc-c(I32Arr,b->comp->bc)->a); - for (i32 i = 0; i < sh; i++) { if(i)printf(" ⋄ "); print(stack[i]); } puts(""); fflush(stdout); + for (i32 i = 0; i < b->maxStack; i++) { if(i)printf(" ⋄ "); print(gStack[i]); } puts(""); fflush(stdout); #endif } end:; diff --git a/test.bqn b/test.bqn index 0a47afb4..b205baab 100755 --- a/test.bqn +++ b/test.bqn @@ -1,29 +1,20 @@ #! /usr/bin/env dbqn -"Usage: ./test.bqn path/to/mlochbaum/BQN ""$PATH"" [optional expressions to evaluate]"!2≤≠•args -path←0⊑•args -envP←1⊑•args +"Usage: ./test.bqn path/to/mlochbaum/BQN [-sme] name | ./BQN"!2≤≠•args +path←⊑•args +args←1↓•args +opt←"" +{𝕊: opt↩𝕩 ⋄ args↓˜↩1}⍟('-'≡⊑) ⊑args -tests ← •FLines path∾"/test/cases/prim.bqn" -# tests ← •FLines path∾"/test/cases/identity.bqn" -# tests ← •FLines path∾"/test/cases/undo.bqn" -# tests ← •FLines path∾"/test/cases/under.bqn" -# tests ← •FLines path∾"/test/cases/fill.bqn" -{tests↩𝕩}⍟(×≠) 2↓•args +"Missing argument!"!1=≠args +case←⊑args +case∾↩".bqn" +tests ← •FLines path∾"/test/cases/"∾case +tests/˜↩ (('#'≢⊑)∧0<≠)¨tests +{𝕊: tests/˜↩{"! %"≢3↑𝕩}¨tests}⍟⊑ 's'∊opt +{𝕊: tests/˜↩{"! %"≡3↑𝕩}¨tests}⍟⊑ 'e'∊opt +Out ← {•Out'%'⊸∊◶⊢‿{𝕩↓˜1+⊑𝕩⊐'%'}𝕩} -('#'≠ ·⊑ ∾⟜"#")◶@‿{ - '%'⊸∊◶{𝕤 - •Out 𝕩 - "src/interp" •FChars ⟨1,path,𝕩⟩ •Import "cc.bqn" - (×⊑)◶@‿{𝕤⋄•Out "############ Failed to compile! ############" ⋄ •Out¨1↓𝕩}{env⇐<"PATH="∾envP}•SH"./debugBuild" - code‿out‿err←•SH"./BQN" - •Out out - {𝕤⋄•Out"exit code "∾(⍕code) ⋄ •Out err}⍟(×code) err - }‿{𝕤 - # •Out 𝕩 - # "src/interp" •FChars ⟨1,path,3↓𝕩⟩ •Import "cc.bqn" - # (×⊑)◶@‿{𝕤⋄•Out "############ Failed to compile! ############" ⋄ •Out¨1↓𝕩}{env⇐<"PATH="∾envP}•SH"./debugBuild" - # code‿out‿err←•SH"./BQN" - # •Out out - # {𝕤⋄•Out"exit code "∾(⍕code) ⋄ •Out err}⍟(×code) err - } -}¨tests \ No newline at end of file +((⊑'m'∊opt)⊑Out‿{•Show𝕩⋄Out𝕩})¨tests +# ('%'⊸∊∨ '#'= ·⊑ ∾⟜"#")◶•Out‿@¨tests +•Out """finished""" +•Out "" \ No newline at end of file