1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-11 00:52:44 +03:00
mal/forth/core.fs

37 lines
1.0 KiB
Forth
Raw Normal View History

2015-02-15 21:33:44 +03:00
require env.fs
0 MalEnv. constant core
: args-as-native { argv argc -- entry*argc... }
2015-02-15 21:33:44 +03:00
argc 0 ?do
argv i cells + @ as-native
loop ;
: defcore ( xt )
parse-allot-name MalSymbol. ( xt sym )
swap MalNativeFn. core env/set ;
2015-02-15 21:33:44 +03:00
: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 { argv argc }
2015-02-15 21:33:44 +03:00
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 drop @ mal-type @ MalList = mal-bool ; defcore list?
:noname drop @ empty? ; defcore empty?
:noname drop @ mal-count ; defcore count
2015-02-15 21:33:44 +03:00
:noname drop dup @ swap cell+ @ swap m= mal-bool ; defcore =