diff --git a/ulisp-arm.ino b/ulisp-arm.ino index 291a848..81bd04a 100644 --- a/ulisp-arm.ino +++ b/ulisp-arm.ino @@ -1,5 +1,5 @@ -/* uLisp ARM Version 3.5a - www.ulisp.com - David Johnson-Davies - www.technoblogy.com - 19th March 2021 +/* uLisp ARM Version 3.6 - www.ulisp.com + David Johnson-Davies - www.technoblogy.com - 4th April 2021 Licensed under the MIT license: https://opensource.org/licenses/MIT */ @@ -330,7 +330,7 @@ char LastChar = 0; char LastPrint = 0; // Flags -enum flag { PRINTREADABLY, RETURNFLAG, ESCAPE, EXITEDITOR, LIBRARYLOADED, NOESC }; +enum flag { PRINTREADABLY, RETURNFLAG, ESCAPE, EXITEDITOR, LIBRARYLOADED, NOESC, NOECHO }; volatile uint8_t Flags = 0b00001; // PRINTREADABLY set by default // Forward references @@ -795,7 +795,7 @@ int loadimage (object *arg) { else error(LOADIMAGE, PSTR("illegal argument"), arg); if (!file) error2(LOADIMAGE, PSTR("problem loading from SD card")); SDReadInt(file); - int imagesize = SDReadInt(file); + unsigned int imagesize = SDReadInt(file); GlobalEnv = (object *)SDReadInt(file); GCStack = (object *)SDReadInt(file); #if SYMBOLTABLESIZE > BUFFERSIZE @@ -804,7 +804,7 @@ int loadimage (object *arg) { for (int i=0; itype == CODE) { codesize = codesize + endblock(codeid) - startblock(codeid); @@ -2526,7 +2526,7 @@ object *sp_defcode (object *args, object *env) { globals = GlobalEnv; while (globals != NULL) { object *pair = car(globals); - if (pair != NULL && car(pair) != var) { // Exclude me if I already exist + if (pair != NULL && car(pair) != var && consp(cdr(pair))) { // Exclude me if I already exist object *codeid = second(pair); if (codeid->type == CODE) { if (startblock(codeid) < smallest && startblock(codeid) >= origin) { @@ -3952,7 +3952,7 @@ object *fn_pinmode (object *args, object *env) { int pin = checkinteger(PINMODE, first(args)); PinMode pm = INPUT; object *arg = second(args); - if (keywordp(arg)) pm = checkkeyword(PINMODE, arg); + if (keywordp(arg)) pm = (PinMode)checkkeyword(PINMODE, arg); else if (integerp(arg)) { int mode = arg->integer; if (mode == 1) pm = OUTPUT; else if (mode == 2) pm = INPUT_PULLUP; @@ -5150,7 +5150,9 @@ object *eval (object *form, object *env) { error(0, PSTR("undefined"), form); } + #if defined(CODESIZE) if (form->type == CODE) error2(0, PSTR("can't evaluate CODE header")); + #endif // It's a list object *function = car(form); @@ -5603,9 +5605,10 @@ int gserial () { WritePtr = 0; return '\n'; #else - while (!Serial.available()); + unsigned long start = millis(); + while (!Serial.available()) if (millis() - start > 1000) clrflag(NOECHO); char temp = Serial.read(); - if (temp != '\n') pserial(temp); + if (temp != '\n' && !tstflag(NOECHO)) pserial(temp); return temp; #endif } @@ -5615,8 +5618,8 @@ object *nextitem (gfun_t gfun) { while(issp(ch)) ch = gfun(); if (ch == ';') { - while(ch != '(') ch = gfun(); - ch = '('; + do { ch = gfun(); if (ch == ';' || ch == '(') setflag(NOECHO); } + while(ch != '('); } if (ch == '\n') ch = gfun(); if (ch == -1) return nil; @@ -5795,7 +5798,7 @@ void setup () { initenv(); initsleep(); initgfx(); - pfstring(PSTR("uLisp 3.5 "), pserial); pln(pserial); + pfstring(PSTR("uLisp 3.6 "), pserial); pln(pserial); } // Read/Evaluate/Print loop @@ -5846,4 +5849,4 @@ void loop () { if (!tstflag(LIBRARYLOADED)) { setflag(LIBRARYLOADED); loadfromlibrary(NULL); } #endif repl(NULL); -} +} \ No newline at end of file