Skip to content

Commit

Permalink
Restructure and put everything under LINK
Browse files Browse the repository at this point in the history
This also removes the need for a BUILD or ROOT variable. Should be more agnostic to platform.
  • Loading branch information
arcfide committed Aug 18, 2021
1 parent e31c499 commit fd72d78
Show file tree
Hide file tree
Showing 101 changed files with 370 additions and 148 deletions.
2 changes: 0 additions & 2 deletions Script.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
)RESET
BUILD ROOT
)SAVE
codfns.AF∆LIB←'cpu'
TEST'ALL'
Binary file modified codfns.dws
Binary file not shown.
413 changes: 289 additions & 124 deletions codfns.dyalog

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions src/DISPLAY.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DISPLAY←{⎕IO ⎕ML←0 ⍝ Boxed display of array.

⍺←1 ⋄ chars←⍺⊃'..''''|-' '┌┐└┘│─' ⍝ ⍺: 0-clunky, 1-smooth.

tl tr bl br vt hz←chars ⍝ Top left, top right, ...

box←{ ⍝ Box with type and axes.
vrt hrz←(¯1+⍴⍵)⍴¨vt hz ⍝ Vert. and horiz. lines.
top←(hz,'⊖→')[¯1↑⍺],hrz ⍝ Upper border with axis.
bot←(⊃⍺),hrz ⍝ Lower border with type.
rgt←tr,vt,vrt,br ⍝ Right side with corners.
lax←(vt,'⌽↓')[¯1↓1↓⍺],¨⊂vrt ⍝ Left side(s) with axes,
lft←⍉tl,(↑lax),bl ⍝ ... and corners.
lft,(top⍪⍵⍪bot),rgt ⍝ Fully boxed array.
}

deco←{⍺←type open ⍵ ⋄ ⍺,axes ⍵} ⍝ Type and axes vector.
axes←{(-2⌈⍴⍴⍵)↑1+×⍴⍵} ⍝ Array axis types.
open←{(1⌈⍴⍵)⍴⍵} ⍝ Expose null axes.
trim←{(~1 1⍷∧⌿⍵=' ')/⍵} ⍝ Remove extra blank cols.
type←{{(1=⍴⍵)⊃'+'⍵}∪,char¨⍵} ⍝ Simple array type.
char←{⍬≡⍴⍵:hz ⋄ (⊃⍵∊'¯',⎕D)⊃'#~'}∘⍕ ⍝ Simple scalar type.
line←{(6≠10|⎕DR' '⍵)⊃' -'} ⍝ underline for atom.

{ ⍝ Recursively box arrays:
0=≡⍵:' '⍪(open ⎕FMT ⍵)⍪line ⍵ ⍝ Simple scalar.
1 ⍬≡(≡⍵)(⍴⍵):'∇' 0 0 box ⎕FMT ⍵ ⍝ Object rep: ⎕OR.
1=≡⍵:(deco ⍵)box open ⎕FMT open ⍵ ⍝ Simple array.
('∊'deco ⍵)box trim ⎕FMT ∇¨open ⍵ ⍝ Nested array.
}⍵
}
3 changes: 3 additions & 0 deletions src/INIT.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INIT
LINK
UT.sac←1
3 changes: 3 additions & 0 deletions src/LINK.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LINK;opts;root
root←(⊃⎕NPARTS ⎕WSID),'src'
'#' root ⎕SE.Link.Create⍨opts⊣opts.(source watch)←⊂'dir'⊣opts←⎕NS ⍬
4 changes: 4 additions & 0 deletions src/MK∆UCMD.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MK∆UCMD
UNLINK
⎕SE.SALT.Save'codfns ',(⊃⎕NPARTS ⎕WSID),'\codfns.dyalog'
LINK
1 change: 1 addition & 0 deletions src/PP.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PP←{⍵⊣⎕←#.DISPLAY ⍵}
2 changes: 2 additions & 0 deletions src/TEST.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TEST N
util.TEST N
2 changes: 2 additions & 0 deletions src/UNLINK.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
UNLINK
⎕SE.Link.Break'#'
24 changes: 24 additions & 0 deletions src/codfns/FNS.apln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
:Namespace FNS

##.P2D←{z←⍪⍳≢⍵ ⋄ d←⍵≠,z ⋄ _←{p⊣d+←⍵≠p←⍺[z,←⍵]}⍣≡⍨⍵ ⋄ d(⍋(-1+d)↑⍤0 1⊢⌽z)}

Xml←{⍺←0 ⋄ ast←⍺{d i←P2D⊃⍵ ⋄ i∘{⍵[⍺]}¨(⊂d),1↓⍺↓⍵}⍣(0≠⍺)⊢⍵ ⋄ d t k n←4↑ast
cls←N∆[t],¨('-..'[1+×k]),¨⍕¨|k ⋄ fld←{((≢⍵)↑3↓f∆),⍪⍵}¨↓⍉↑3↓ast
⎕XML⍉↑d cls(⊂'')fld}
##.Xml←Xml

##.dct←{⍺[(2×2≠/n,0)+(1↑⍨≢m)+m+n←⌽∨\⌽m←' '≠⍺⍺ ⍵]⍵⍵ ⍵}
##.dlk←{((x⌷⍴⍵)↑[x←2|1+⍵⍵]⍺),[⍵⍵]⍺⍺@(⊂0 0)⍣('┌'=⊃⍵)⊢⍵}
##.dwh←{⍵('┬'dlk 1)' │├┌└─'(0⌷⍉)dct,⊃⍪/((≢¨⍺),¨⊂⌈/≢∘⍉¨⍺)↑¨⍺}
##.dwv←{⍵('├'dlk 0)' ─┬┌┐│'(0⌷⊢)dct(⊣⍪1↓⊢)⊃{⍺,' ',⍵}/(1+⌈/≢¨⍺){⍺↑⍵⍪⍨'│'↑⍨≢⍉⍵}¨⍺}

pp3←{⍺←'○' ⋄ d←(⍳≢⍵)≠⍵ ⋄ _←{z⊣d+←⍵≠z←⍺[⍵]}⍣≡⍨⍵ ⋄ lbl←⍺⍴⍨≢⍵
lyr←{i←⍸⍺=d ⋄ k v←↓⍉⍵⍵[i],∘⊂⌸i ⋄ (⍵∘{⍺[⍵]}¨v)⍺⍺¨@k⊢⍵}⍵
(⍵=⍳≢⍵)⌿⊃⍺⍺ lyr⌿(1+⍳⌈/d),⊂⍉∘⍪∘⍕¨lbl}
##.pp3←pp3

lb3←{⍺←⍳≢⊃⍵
'(',¨')',¨⍨{⍺,';',⍵}⌿⍕¨(N∆{⍺[⍵]}@2⊢(2⊃⍵){⍺[|⍵]}@{0>⍵}@4↑⊃⍵)[⍺;]}
##.lb3←lb3

:EndNamespace
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/codfns/GLOBAL.apln
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:Namespace GLOBAL

##.(⎕IO ⎕ML ⎕WX VERSION AF∆PREFIX AF∆LIB)←0 1 3 (3 1 0) '/opt/arrayfire' 'cuda'

:EndNamespace
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 6 additions & 22 deletions cmp/BUILD.aplf → src/codfns/RTM.apln
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
 BUILD ROOT;rtm;initsrc;files;sclsyms
⍝ Parameters
⍝ nams Name codes for each symbol in syms
⍝ rtn Runtime code for each symbol in syms
⍝ rth Runtime header for every module
⍝ syms Runtime instruction set
⎕IO ⎕ML ⎕WX VERSION AF∆PREFIX AF∆LIB←0 1 3 (3 1 0) '/opt/arrayfire' 'cuda'

P2D←{z←⍪⍳≢⍵ ⋄ d←⍵≠,z ⋄ _←{p⊣d+←⍵≠p←⍺[z,←⍵]}⍣≡⍨⍵ ⋄ d(⍋(-1+d)↑⍤0 1⊢⌽z)}
Xml←{⍺←0 ⋄ ast←⍺{d i←P2D⊃⍵ ⋄ i∘{⍵[⍺]}¨(⊂d),1↓⍺↓⍵}⍣(0≠⍺)⊢⍵ ⋄ d t k n←4↑ast
cls←N∆[t],¨('-..'[1+×k]),¨⍕¨|k ⋄ fld←{((≢⍵)↑3↓f∆),⍪⍵}¨↓⍉↑3↓ast
⎕XML⍉↑d cls(⊂'')fld}
dct←{⍺[(2×2≠/n,0)+(1↑⍨≢m)+m+n←⌽∨\⌽m←' '≠⍺⍺ ⍵]⍵⍵ ⍵}
dlk←{((x⌷⍴⍵)↑[x←2|1+⍵⍵]⍺),[⍵⍵]⍺⍺@(⊂0 0)⍣('┌'=⊃⍵)⊢⍵}
dwh←{⍵('┬'dlk 1)' │├┌└─'(0⌷⍉)dct,⊃⍪/((≢¨⍺),¨⊂⌈/≢∘⍉¨⍺)↑¨⍺}
dwv←{⍵('├'dlk 0)' ─┬┌┐│'(0⌷⊢)dct(⊣⍪1↓⊢)⊃{⍺,' ',⍵}/(1+⌈/≢¨⍺){⍺↑⍵⍪⍨'│'↑⍨≢⍉⍵}¨⍺}
pp3←{⍺←'○' ⋄ d←(⍳≢⍵)≠⍵ ⋄ _←{z⊣d+←⍵≠z←⍺[⍵]}⍣≡⍨⍵ ⋄ lbl←⍺⍴⍨≢⍵
lyr←{i←⍸⍺=d ⋄ k v←↓⍉⍵⍵[i],∘⊂⌸i ⋄ (⍵∘{⍺[⍵]}¨v)⍺⍺¨@k⊢⍵}⍵
(⍵=⍳≢⍵)⌿⊃⍺⍺ lyr⌿(1+⍳⌈/d),⊂⍉∘⍪∘⍕¨lbl}
lb3←{⍺←⍳≢⊃⍵
'(',¨')',¨⍨{⍺,';',⍵}⌿⍕¨(N∆{⍺[⍵]}@2⊢(2⊃⍵){⍺[|⍵]}@{0>⍵}@4↑⊃⍵)[⍺;]}
:Namespace RTM

syms ←,¨'+' '-' '×' '÷' '*' '⍟' '|' '○' '⌊' '⌈' '!'
nams ← 'add' 'sub' 'mul' 'div' 'exp' 'log' 'res' 'cir' 'min' 'max' 'fac'
Expand All @@ -41,7 +21,11 @@
deps[syms⍳,¨'⊆']←,¨¨⊂'⊂⊆'
deps[syms⍳⊂'∘.']←⊂(,¨'¨' '∘.')

rtm←ROOT,'/rtm/'
rtm←(⊃⎕NPARTS ⎕WSID),'src/rtm/'
initsrc←'0inc' '1mac' '2obj' '3ftp' '4utl' '5dat' '6dwa' '7api'
rth←∊(⎕UCS 10),⍨⍪⊃,⌿⊃¨⎕NGET¨(⊂¨rtm∘,¨initsrc,¨⊂'.c'),¨1
rtn←{∊(⊃⍵),¨⎕UCS 10}¨⎕NGET¨(⊂¨rtm∘,¨(nams~'this' 'span' ''),¨⊂'.c'),¨1

##.(syms nams deps rth rtn)←syms nams deps rth rtn

:EndNamespace
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added tests/codfns.dws
Binary file not shown.

0 comments on commit fd72d78

Please sign in to comment.