aboutsummaryrefslogtreecommitdiff
path: root/src/bootstrap/verify.bqn
blob: 6a24dcebd0c9dc5ba30b120a01bbdc27fc1d1efc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
glyphs  •Import "../glyphs.bqn"
gl  ("⟨""⟩"«∾","¨'"'(⊣∾∾˜)¨glyphs)      # Has to replace •args in c.bqn

f  "../c.bqn"("boot"∾∾".bqn")¨'1'+↕3   # Files to test
c  (13/glyphs•Import,•Import) {𝕎𝕩}¨ f  # Resulting compilers
c  (glyphs){𝕗𝕏}¨ c
t  (∾∾(@+10)¨)¨ (¯5↓∾gl˙) •FLines¨ f # Compiler source

# Check that compiler 𝕩 compiles 𝕩-1 same as full compiler
Ver  {
  norm  {𝕎𝕏}˜´ 𝕩  
    4                  # Strip source info, always
    =¨(2¨2)     # Turn only-dyadic functions to ambivalent if ≥2
    NormVar(⊑⋈2¯13⊑⊢) # Normalize variable opcodes if =3, defined below
  
  ! Norm´ (0𝕩c) {𝕎𝕩}¨ (𝕩-1)t
  •Out "Boot -",'0'+𝕩," verified!"
}
NormVar  {
  ba  /´'0'-˜ # For each instruction, number of:
    "11411311121111111315114131131111=111"  # Codes until next opcode
    "111000111100000000002221100000000111"  # Arguments
  
  Se(>/⊢){(˜𝕨)𝕊((¯1))𝕩𝕩𝕨}0˙
  m  (𝕩)↑/ Se (↕≠𝕩)+1+ba(⊣⊏˜>×⊢)𝕩  # Mask of opcode starts
  𝕩 (⊢-m2×34=) # VARU to VARO
  ((-3)𝕨)((00»m𝕩3233)/) 𝕩,↕≠𝕨
}˜´

Ver¨ 1+↕3

•Out ""
•Out "Compile times, in milliseconds:"
•Show 1e3÷˜1e6× ((3>)1≥-){30(𝕨c)•_timed𝕩t}⌜˜ ↕≠c