Version 3.6 - 4th April 2021

This commit is contained in:
David Johnson-Davies 2021-04-04 09:16:28 +01:00 committed by GitHub
parent 212f37829d
commit 358a44e7ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 16 deletions

View File

@ -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; i<SymbolUsed; i++) SymbolTable[i] = file.read();
#endif
for (int i=0; i<CODESIZE; i++) MyCode[i] = file.read();
for (int i=0; i<imagesize; i++) {
for (unsigned int i=0; i<imagesize; i++) {
object *obj = &Workspace[i];
car(obj) = (object *)SDReadInt(file);
cdr(obj) = (object *)SDReadInt(file);
@ -816,7 +816,7 @@ int loadimage (object *arg) {
if (!FlashSetup()) error2(LOADIMAGE, PSTR("no DataFlash found."));
FlashBeginRead();
FlashReadInt(); // Skip eval address
int imagesize = FlashReadInt();
unsigned int imagesize = FlashReadInt();
if (imagesize == 0 || imagesize == 0xFFFFFFFF) error2(LOADIMAGE, PSTR("no saved image"));
GlobalEnv = (object *)FlashReadInt();
GCStack = (object *)FlashReadInt();
@ -826,7 +826,7 @@ int loadimage (object *arg) {
for (int i=0; i<SymbolUsed; i++) SymbolTable[i] = FlashReadByte();
#endif
for (int i=0; i<CODESIZE; i++) MyCode[i] = FlashReadByte();
for (int i=0; i<imagesize; i++) {
for (unsigned int i=0; i<imagesize; i++) {
object *obj = &Workspace[i];
car(obj) = (object *)FlashReadInt();
cdr(obj) = (object *)FlashReadInt();
@ -2506,7 +2506,7 @@ object *sp_defcode (object *args, object *env) {
object *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) {
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