aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2018-04-02 12:29:22 -0400
committerClyne Sullivan <clyne@bitgloo.com>2018-04-02 12:29:22 -0400
commit275677dd44b18b1cef3acfa30f52d8afa562b639 (patch)
tree7f4caee794fdcbb016e04676790acf4ecaec43b8
parent769b3dbcea116b83f913a6aae00b4e43633be82c (diff)
libinterp changes
-rw-r--r--libinterp.abin65754 -> 66016 bytes
-rw-r--r--src/main.c26
2 files changed, 17 insertions, 9 deletions
diff --git a/libinterp.a b/libinterp.a
index 04391e1..46f2a26 100644
--- a/libinterp.a
+++ b/libinterp.a
Binary files differ
diff --git a/src/main.c b/src/main.c
index b39053a..79f3e92 100644
--- a/src/main.c
+++ b/src/main.c
@@ -90,12 +90,14 @@ void task_interpreter(void)
instance *it = inewinstance();
script_loadlib(it);
+ // load '/init' file
char *s = initrd_readfile("init");
if (s == 0) {
dsp_puts("can't find init");
goto end;
}
+ // read in, parse into script code
char *linebuf = (char *)malloc(120);
uint32_t i = 0, prev = 0, lc;
uint32_t size = initrd_filesize("init");
@@ -109,21 +111,27 @@ void task_interpreter(void)
}
strncpy(linebuf, s + prev, lc + 1);
linebuf[lc] = '\0';
- ret = idoline(it, linebuf);
- if (ret < 0)
- break;
+ ret = iaddline(it, linebuf);
+ if (ret != 0)
+ goto fail;
prev = ++i;
}
-
- if (ret < 0) {
- dsp_puts("\nError: ");
- dsp_puts(itoa(ret, linebuf, 10));
- }
free(linebuf);
- //iend(&it); // nah
+
+ // run the script
+ ret = irun(it);
+ if (ret != 0)
+ goto fail;
+ idelinstance(it);
end:
while (1)
delay(10);
+fail:
+ if (ret < 0) {
+ dsp_puts("\nError: ");
+ dsp_puts(itoa(ret, linebuf, 10));
+ }
+ goto end;
}