Skip to content

Commit c62acf5

Browse files
committed
- remove hello (merge with help)
- improve help with more key binding
1 parent 690a5d4 commit c62acf5

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ Optimize more for storage/simplify and avoid using malloc here are some ideas fr
141141
- https://github.com/obdev/v-usb
142142
- https://github.com/denilsonsa/atmega8-magnetometer-usb-mouse
143143
- http://blog.tynemouthsoftware.co.uk/2012/02/arduino-based-zx81-usb-keyboard.html
144-
144+
- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.109.6660&rep=rep1&type=pdf
145+
145146
## Flash based filesystems or flash database log systems
146147

147148
- http://research.microsoft.com/en-us/um/people/moscitho/Publications/USENIX_ATC_2015.pdf

lisp.c

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,10 +1566,12 @@ static inline lisp eval_hlp(lisp e, lisp* envp) {
15661566
inline lisp reduce_immediate(lisp x) {
15671567
while (x && IS(x, immediate)) {
15681568
lisp tofree = x;
1569+
15691570
if (trace) // make it visible
15701571
x = evalGC(ATTR(thunk, x, e), &ATTR(thunk, x, env));
15711572
else
15721573
x = eval_hlp(ATTR(thunk, x, e), &ATTR(thunk, x, env));
1574+
15731575
// immediates are immediately consumed after evaluation, so they can be free:d directly
15741576
tofree->tag = 0;
15751577
sfree((void*)tofree, sizeof(thunk), immediate_TAG);
@@ -1612,7 +1614,6 @@ inline int needGC() {
16121614
}
16131615

16141616

1615-
#define MAX_STACK 80
16161617
// (de rec (n) (print n) (rec (+ n 1)) nil) // not tail recursive!
16171618
// === optimized:
16181619
// ...
@@ -1625,13 +1626,16 @@ inline int needGC() {
16251626
// #772 0x08052d58 in readeval ()
16261627
// #773 0x08048b57 in main ()
16271628

1629+
#define MAX_STACK 80
1630+
16281631
static struct stack {
16291632
lisp e;
16301633
lisp* envp;
16311634
} stack[MAX_STACK];
16321635

16331636
static int level = 0;
16341637

1638+
// TODO: because of tail call optimization, we can't tell where the error occurred as it's not relevant on the stack???
16351639
PRIM print_detailed_stack() {
16361640
int l;
16371641
// TODO: DONE but too much: using fargs of f can use .envp to print actual arguments!
@@ -2073,7 +2077,7 @@ PRIM heap() {
20732077

20742078

20752079
////////////////////////////////////////////////////////////////////////////////
2076-
// flash fielesystem
2080+
// flash file access
20772081
//
20782082
// - https://blog.cesanta.com/esp8266_using_flash
20792083
// ~/GIT/Espruino-on-ESP8266/user/user_main.c
@@ -2097,6 +2101,20 @@ PRIM scan(lisp s) {
20972101
return nil;
20982102
}
20992103

2104+
// Highlevel
2105+
2106+
// (save '(http boot) (lambda (x) (init-web-server)) (lambda (x) (print "Done")))
2107+
//lisp save(lisp key, lisp data, lisp cb) {
2108+
//}
2109+
2110+
// tail-recurses on: cb(key, info, cb)
2111+
//lisp dir(lisp matchkey, lisp cb) {
2112+
//}
2113+
2114+
// tail-recurses on: cb(key, info, data, cb, end?)
2115+
//lisp load(lisp matchkey, lisp cb) {
2116+
//}
2117+
21002118
#else
21012119

21022120
// http://www.esp8266.com/wiki/doku.php?id=esp8266_memory_map
@@ -2587,21 +2605,15 @@ lisp lisp_init() {
25872605
return env;
25882606
}
25892607

2590-
void hello() {
2608+
void help(lisp* envp) {
25912609
printf("\n\nWelcome to esp-lisp!\n");
25922610
printf("2015 (c) Jonas S Karlsson under MPL 2.0\n");
2593-
printf("Read more on https://github.com/yesco/esp-lisp/\n");
2594-
printf("\n");
2595-
}
2596-
2597-
void help(lisp* envp) {
2598-
hello();
2611+
printf("Read more on https://github.com/yesco/esp-lisp/\n\n");
25992612
printf("Global/SYMBOLS: ");
26002613
PRINT((syms (lambda (x) (princ x) (princ " "))));
2601-
terpri();
2602-
printf("COMMANDS: hello/help/trace on/trace off/gc on/gc off/wifi SSID PSWD/wget SERVER URL/mem EXPR/quit/exit\n");
2603-
terpri();
2604-
printf("CTRL-T: shows current time/load status\n");
2614+
printf("\nCOMMANDS: help/trace on/trace off/gc on/gc off/wifi SSID PSWD/wget SERVER URL/mem EXPR/quit/exit\n\n");
2615+
printf("CTRL-C: to break execution, CTRL-T: shows current time/load status, CTRL-D: to exit\n\n");
2616+
printf("Type 'help' to get this message again\n");
26052617
}
26062618

26072619
#include <setjmp.h>
@@ -2623,6 +2635,8 @@ void error(char* msg) {
26232635
printf("\n%% error(): error inside error... recovering...\n");
26242636
}
26252637

2638+
printf("\n%%%% type 'help' to get help\n");
2639+
26262640
if (memcmp(lisp_break, empty, sizeof(empty))) { // contains valid value
26272641
// reset stack
26282642
level = 0;
@@ -2764,7 +2778,7 @@ int lispreadchar(char *chp) {
27642778
}
27652779

27662780
void readeval(lisp* envp) {
2767-
hello();
2781+
help(envp);
27682782

27692783
while(1) {
27702784
global_envp = envp; // allow idle to gc
@@ -2775,8 +2789,6 @@ void readeval(lisp* envp) {
27752789
break;
27762790
} else if (strncmp(ln, ";", 1) == 0) {
27772791
; // comment - ignore
2778-
} else if (strcmp(ln, "hello") == 0) {
2779-
hello();
27802792
} else if (strcmp(ln, "help") == 0 || ln[0] == '?') {
27812793
help(envp);
27822794
} else if (strcmp(ln, "gc on") == 0) {

0 commit comments

Comments
 (0)