forked from kanaka/mal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.fs
36 lines (29 loc) · 1.01 KB
/
core.fs
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
35
36
require env.fs
0 MalEnv. constant core
: args-as-native drop { argv argc -- entry*argc... }
argc 0 ?do
argv i cells + @ as-native
loop ;
: defcore ( xt )
parse-allot-name MalSymbol. ( xt sym )
swap MalFn. core env/set ;
:noname args-as-native + MalInt. ; defcore +
:noname args-as-native - MalInt. ; defcore -
:noname args-as-native * MalInt. ; defcore *
:noname args-as-native / MalInt. ; defcore /
:noname args-as-native < mal-bool ; defcore <
:noname args-as-native > mal-bool ; defcore >
:noname args-as-native <= mal-bool ; defcore <=
:noname args-as-native >= mal-bool ; defcore >=
:noname drop { argv argc }
MalList new { list }
argc cells allocate throw { start }
argv start argc cells cmove
argc list MalList/count !
start list MalList/start !
list
; defcore list
:noname 2drop @ mal-type @ MalList = mal-bool ; defcore list?
:noname 2drop @ empty? ; defcore empty?
:noname 2drop @ mal-count ; defcore count
:noname 2drop dup @ swap cell+ @ swap m= mal-bool ; defcore =