summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp_builtin.c
Commit message (Collapse)AuthorAge
* altos/scheme: Rename to 'scheme', clean up buildKeith Packard2017-12-05
| | | | | | | | | Constant block is now built in a subdir to avoid messing up source directory. Renamed to ao_scheme to reflect language target. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Switch to scheme formal syntax for varargsKeith Packard2017-12-03
| | | | | | | | | | Scheme uses bare symbols to indicate a varargs parameter; any bare (i.e., not wrapped in a cons cell) parameter will get the 'rest' of the parameter list. This works for lambdas, nlambdas and macros. As a result, the 'lexpr' form has been removed as it is equivalent to a lambda with a varargs formal. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Split out read debug, add memory validationKeith Packard2017-12-03
| | | | | | | | Split read debug into a separate #define to reduce debug noise Add some memory validation -- validate stash API, and validate cons_free calls. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Overflow int computations to floatKeith Packard2017-12-02
| | | | | | When an int computation overflows, switch to float. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: split set/def. Add def support to lambdasKeith Packard2017-12-01
| | | | | | | | In scheme, set can only re-define existing variables while def cannot redefine existing variables in lambda context. Def within lambda creates a new variable at the nearest enclosing scope. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix pairp builtinKeith Packard2017-12-01
| | | | | | Pairs are non-nil cons values; add an explicit check for nil here Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Rename progn to beginKeith Packard2017-11-25
| | | | | | Match scheme name. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add floatsKeith Packard2017-11-19
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix some scheme compat issuesKeith Packard2017-11-18
| | | | | | | | | | flush -> flush-output nth -> list-ref (oh, and add list-tail) add let* (same as let for now) write control chars in octal make hanoi example work Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add 'big' ints -- 24 bits wideKeith Packard2017-11-18
| | | | | | | With the default ints being only 14 bits, having a larger type with more precision seems useful. This is not exposed to the application. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Finish first pass through r7rsKeith Packard2017-11-17
| | | | | | | | | | * print -> write, patom -> display * Add read-char, write-char * Add exit, current-jiffy, current-second, jiffies-per-second * Add for-each and string-for-each * Avoid duplicate builtins with different atoms Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add applyKeith Packard2017-11-17
| | | | | | And all of the library routines that use it, map, string-map and friends. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Character consts. String and assoc builtins.Keith Packard2017-11-17
| | | | | | Also add back escaped characters in strings. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Lots more scheme bitsKeith Packard2017-11-16
| | | | | | | | * Arithmetic functions and tests * append, reverse and list-tail * set-car! and set-cdr! Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: More schemismsKeith Packard2017-11-16
| | | | | | | | | | Add 'if'. setq -> set!, but doesn't define new variables def -> define Add pair? and list? Add eq? and eqv? as aliases for = Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add scheme-style bools (#t and #f)Keith Packard2017-11-16
| | | | | | Cond and while compare against #f, just like scheme says to. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add non-cons cdr supportKeith Packard2017-11-16
| | | | | | | The cdr of a cons can be any value; add support for lexing and printing them. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Not quite ready to start making it look like scheme yetKeith Packard2017-02-20
| | | | | | Lots more code to write before these symbols can be exposed. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Start adding scheme symbolsKeith Packard2017-02-20
| | | | | | Migrating to something more like scheme Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add builtin 'collect'Keith Packard2017-02-20
| | | | | | Collect memory, return amount free. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add continuationsKeith Packard2017-02-20
| | | | | | This provides call/cc and makes 'stacks' visible to the application. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix error atom name in ao_lisp_lengthKeith Packard2017-02-20
| | | | | | Cut&paste error. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Get lambdakey and nucleo-32 building againKeith Packard2017-02-20
| | | | | | Remove exti from the build list to make things fit. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Evaluate macros once, then smash them into placeKeith Packard2017-02-20
| | | | | | | This assumes that macros are all pure functions, which should be true for syntactic macros. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add save/restore infrastructure. Needs OS support to work.Keith Packard2017-02-20
| | | | | | | | This sticks a few globals past the end of the heap and then asks the OS to save the heap. On restore, the heap is re-populated by the OS and then various global variables reset. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: add length, pack, unpack and flushKeith Packard2017-02-20
| | | | | | lots more builtins Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: add progn, while, read and evalKeith Packard2017-02-20
| | | | | | | | Progn as a builtin will help with tail-recursion. while provides for loops until tail-recursion works :-) read and eval are kinda useful. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Clean up OS integration bits, add defunKeith Packard2017-02-20
| | | | | | | Provide an abstraction for the OS interface so that it can build more cleanly on Linux and AltOS. Add defun macro. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: working on lexical scopingKeith Packard2017-02-20
| | | | | | Not working yet Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: more GC issues. add patomKeith Packard2017-02-20
| | | | | | | Use global ao_lisp_stack instead of local stack so that gc moves of that item work. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Change GC move APIKeith Packard2017-02-20
| | | | | | | | Pass reference to move API so it can change the values in-place, then let it return '1' when the underlying object has already been moved to shorten GC times. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: get builtin macros working againKeith Packard2017-02-20
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Add lambda support to lispKeith Packard2017-02-20
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Separate out values from atomsKeith Packard2017-02-20
| | | | | | | | | | | This enables changing values of atoms declared as constants, should enable lets, and with some work, even lexical scoping. this required changing the constant computation to run ao_lisp_collect() before dumping the block of constant data, and that uncovered some minor memory manager bugs. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: add set/setq and ' in readerKeith Packard2017-02-20
| | | | | | Along with other small fixes Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Change lisp objects to use ao_poly everywhere. Add constKeith Packard2017-02-20
| | | | | | | | | | | This makes all lisp objects use 16-bit ints for references so we can hold more stuff in small amounts of memory. Also adds a separate constant pool of lisp objects for builtins, initial atoms and constant lisp code. Now builds (and runs!) on the nucleo-32 boards. Signed-off-by: Keith Packard <keithp@keithp.com>
* Add first lisp bitsKeith Packard2017-02-20
Signed-off-by: Keith Packard <keithp@keithp.com>