Version 3.6 - 4th April 2021
This commit is contained in:
parent
212f37829d
commit
358a44e7ba
|
@ -1,5 +1,5 @@
|
||||||
/* uLisp ARM Version 3.5a - www.ulisp.com
|
/* uLisp ARM Version 3.6 - www.ulisp.com
|
||||||
David Johnson-Davies - www.technoblogy.com - 19th March 2021
|
David Johnson-Davies - www.technoblogy.com - 4th April 2021
|
||||||
|
|
||||||
Licensed under the MIT license: https://opensource.org/licenses/MIT
|
Licensed under the MIT license: https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
@ -330,7 +330,7 @@ char LastChar = 0;
|
||||||
char LastPrint = 0;
|
char LastPrint = 0;
|
||||||
|
|
||||||
// Flags
|
// 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
|
volatile uint8_t Flags = 0b00001; // PRINTREADABLY set by default
|
||||||
|
|
||||||
// Forward references
|
// Forward references
|
||||||
|
@ -795,7 +795,7 @@ int loadimage (object *arg) {
|
||||||
else error(LOADIMAGE, PSTR("illegal argument"), arg);
|
else error(LOADIMAGE, PSTR("illegal argument"), arg);
|
||||||
if (!file) error2(LOADIMAGE, PSTR("problem loading from SD card"));
|
if (!file) error2(LOADIMAGE, PSTR("problem loading from SD card"));
|
||||||
SDReadInt(file);
|
SDReadInt(file);
|
||||||
int imagesize = SDReadInt(file);
|
unsigned int imagesize = SDReadInt(file);
|
||||||
GlobalEnv = (object *)SDReadInt(file);
|
GlobalEnv = (object *)SDReadInt(file);
|
||||||
GCStack = (object *)SDReadInt(file);
|
GCStack = (object *)SDReadInt(file);
|
||||||
#if SYMBOLTABLESIZE > BUFFERSIZE
|
#if SYMBOLTABLESIZE > BUFFERSIZE
|
||||||
|
@ -804,7 +804,7 @@ int loadimage (object *arg) {
|
||||||
for (int i=0; i<SymbolUsed; i++) SymbolTable[i] = file.read();
|
for (int i=0; i<SymbolUsed; i++) SymbolTable[i] = file.read();
|
||||||
#endif
|
#endif
|
||||||
for (int i=0; i<CODESIZE; i++) MyCode[i] = file.read();
|
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];
|
object *obj = &Workspace[i];
|
||||||
car(obj) = (object *)SDReadInt(file);
|
car(obj) = (object *)SDReadInt(file);
|
||||||
cdr(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."));
|
if (!FlashSetup()) error2(LOADIMAGE, PSTR("no DataFlash found."));
|
||||||
FlashBeginRead();
|
FlashBeginRead();
|
||||||
FlashReadInt(); // Skip eval address
|
FlashReadInt(); // Skip eval address
|
||||||
int imagesize = FlashReadInt();
|
unsigned int imagesize = FlashReadInt();
|
||||||
if (imagesize == 0 || imagesize == 0xFFFFFFFF) error2(LOADIMAGE, PSTR("no saved image"));
|
if (imagesize == 0 || imagesize == 0xFFFFFFFF) error2(LOADIMAGE, PSTR("no saved image"));
|
||||||
GlobalEnv = (object *)FlashReadInt();
|
GlobalEnv = (object *)FlashReadInt();
|
||||||
GCStack = (object *)FlashReadInt();
|
GCStack = (object *)FlashReadInt();
|
||||||
|
@ -826,7 +826,7 @@ int loadimage (object *arg) {
|
||||||
for (int i=0; i<SymbolUsed; i++) SymbolTable[i] = FlashReadByte();
|
for (int i=0; i<SymbolUsed; i++) SymbolTable[i] = FlashReadByte();
|
||||||
#endif
|
#endif
|
||||||
for (int i=0; i<CODESIZE; i++) MyCode[i] = FlashReadByte();
|
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];
|
object *obj = &Workspace[i];
|
||||||
car(obj) = (object *)FlashReadInt();
|
car(obj) = (object *)FlashReadInt();
|
||||||
cdr(obj) = (object *)FlashReadInt();
|
cdr(obj) = (object *)FlashReadInt();
|
||||||
|
@ -2506,7 +2506,7 @@ object *sp_defcode (object *args, object *env) {
|
||||||
object *globals = GlobalEnv;
|
object *globals = GlobalEnv;
|
||||||
while (globals != NULL) {
|
while (globals != NULL) {
|
||||||
object *pair = car(globals);
|
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);
|
object *codeid = second(pair);
|
||||||
if (codeid->type == CODE) {
|
if (codeid->type == CODE) {
|
||||||
codesize = codesize + endblock(codeid) - startblock(codeid);
|
codesize = codesize + endblock(codeid) - startblock(codeid);
|
||||||
|
@ -2526,7 +2526,7 @@ object *sp_defcode (object *args, object *env) {
|
||||||
globals = GlobalEnv;
|
globals = GlobalEnv;
|
||||||
while (globals != NULL) {
|
while (globals != NULL) {
|
||||||
object *pair = car(globals);
|
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);
|
object *codeid = second(pair);
|
||||||
if (codeid->type == CODE) {
|
if (codeid->type == CODE) {
|
||||||
if (startblock(codeid) < smallest && startblock(codeid) >= origin) {
|
if (startblock(codeid) < smallest && startblock(codeid) >= origin) {
|
||||||
|
@ -3952,7 +3952,7 @@ object *fn_pinmode (object *args, object *env) {
|
||||||
int pin = checkinteger(PINMODE, first(args));
|
int pin = checkinteger(PINMODE, first(args));
|
||||||
PinMode pm = INPUT;
|
PinMode pm = INPUT;
|
||||||
object *arg = second(args);
|
object *arg = second(args);
|
||||||
if (keywordp(arg)) pm = checkkeyword(PINMODE, arg);
|
if (keywordp(arg)) pm = (PinMode)checkkeyword(PINMODE, arg);
|
||||||
else if (integerp(arg)) {
|
else if (integerp(arg)) {
|
||||||
int mode = arg->integer;
|
int mode = arg->integer;
|
||||||
if (mode == 1) pm = OUTPUT; else if (mode == 2) pm = INPUT_PULLUP;
|
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);
|
error(0, PSTR("undefined"), form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CODESIZE)
|
||||||
if (form->type == CODE) error2(0, PSTR("can't evaluate CODE header"));
|
if (form->type == CODE) error2(0, PSTR("can't evaluate CODE header"));
|
||||||
|
#endif
|
||||||
|
|
||||||
// It's a list
|
// It's a list
|
||||||
object *function = car(form);
|
object *function = car(form);
|
||||||
|
@ -5603,9 +5605,10 @@ int gserial () {
|
||||||
WritePtr = 0;
|
WritePtr = 0;
|
||||||
return '\n';
|
return '\n';
|
||||||
#else
|
#else
|
||||||
while (!Serial.available());
|
unsigned long start = millis();
|
||||||
|
while (!Serial.available()) if (millis() - start > 1000) clrflag(NOECHO);
|
||||||
char temp = Serial.read();
|
char temp = Serial.read();
|
||||||
if (temp != '\n') pserial(temp);
|
if (temp != '\n' && !tstflag(NOECHO)) pserial(temp);
|
||||||
return temp;
|
return temp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5615,8 +5618,8 @@ object *nextitem (gfun_t gfun) {
|
||||||
while(issp(ch)) ch = gfun();
|
while(issp(ch)) ch = gfun();
|
||||||
|
|
||||||
if (ch == ';') {
|
if (ch == ';') {
|
||||||
while(ch != '(') ch = gfun();
|
do { ch = gfun(); if (ch == ';' || ch == '(') setflag(NOECHO); }
|
||||||
ch = '(';
|
while(ch != '(');
|
||||||
}
|
}
|
||||||
if (ch == '\n') ch = gfun();
|
if (ch == '\n') ch = gfun();
|
||||||
if (ch == -1) return nil;
|
if (ch == -1) return nil;
|
||||||
|
@ -5795,7 +5798,7 @@ void setup () {
|
||||||
initenv();
|
initenv();
|
||||||
initsleep();
|
initsleep();
|
||||||
initgfx();
|
initgfx();
|
||||||
pfstring(PSTR("uLisp 3.5 "), pserial); pln(pserial);
|
pfstring(PSTR("uLisp 3.6 "), pserial); pln(pserial);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read/Evaluate/Print loop
|
// Read/Evaluate/Print loop
|
||||||
|
@ -5846,4 +5849,4 @@ void loop () {
|
||||||
if (!tstflag(LIBRARYLOADED)) { setflag(LIBRARYLOADED); loadfromlibrary(NULL); }
|
if (!tstflag(LIBRARYLOADED)) { setflag(LIBRARYLOADED); loadfromlibrary(NULL); }
|
||||||
#endif
|
#endif
|
||||||
repl(NULL);
|
repl(NULL);
|
||||||
}
|
}
|
Loading…
Reference in New Issue