diff options
| author | Chouser <chouser@n01se.net> | 2015-02-15 13:33:44 -0500 |
|---|---|---|
| committer | Chouser <chouser@n01se.net> | 2015-02-21 13:22:44 -0500 |
| commit | 60801ed68d5b2c6630c83883de150ccce98767f9 (patch) | |
| tree | 5f37431cd6610050e456401be5990004a70dfea6 /forth/core.fs | |
| parent | 79feb89f9c75d30e79b9ef13fa40d2f8e22f4b9b (diff) | |
| download | mal-60801ed68d5b2c6630c83883de150ccce98767f9.tar.gz mal-60801ed68d5b2c6630c83883de150ccce98767f9.zip | |
forth: Add step 4, but not varargs
Diffstat (limited to 'forth/core.fs')
| -rw-r--r-- | forth/core.fs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/forth/core.fs b/forth/core.fs new file mode 100644 index 0000000..6e8ccfb --- /dev/null +++ b/forth/core.fs @@ -0,0 +1,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 = |
