2015-02-15 21:33:44 +03:00
|
|
|
require env.fs
|
|
|
|
|
|
|
|
0 MalEnv. constant core
|
|
|
|
|
2015-02-15 22:10:47 +03:00
|
|
|
: 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 )
|
2015-02-15 22:10:47 +03:00
|
|
|
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 >=
|
|
|
|
|
2015-02-15 22:10:47 +03:00
|
|
|
: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
|
|
|
|
|
2015-02-15 22:10:47 +03:00
|
|
|
: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
|
|
|
|
2015-02-15 22:10:47 +03:00
|
|
|
:noname drop dup @ swap cell+ @ swap m= mal-bool ; defcore =
|