Changeset View
Changeset View
Standalone View
Standalone View
head/sys/boot/common/interp_forth.c
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
/* | /* | ||||
* BootForth Interface to Ficl Forth interpreter. | * BootForth Interface to Ficl Forth interpreter. | ||||
*/ | */ | ||||
FICL_SYSTEM *bf_sys; | FICL_SYSTEM *bf_sys; | ||||
FICL_VM *bf_vm; | FICL_VM *bf_vm; | ||||
FICL_WORD *pInterp; | |||||
/* | /* | ||||
* Shim for taking commands from BF and passing them out to 'standard' | * Shim for taking commands from BF and passing them out to 'standard' | ||||
* argv/argc command functions. | * argv/argc command functions. | ||||
*/ | */ | ||||
static void | static void | ||||
bf_command(FICL_VM *vm) | bf_command(FICL_VM *vm) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | ficlExec(bf_vm, "builtins definitions"); | ||||
} | } | ||||
ficlExec(bf_vm, "only forth definitions"); | ficlExec(bf_vm, "only forth definitions"); | ||||
/* Export some version numbers so that code can detect the loader/host version */ | /* Export some version numbers so that code can detect the loader/host version */ | ||||
ficlSetEnv(bf_sys, "FreeBSD_version", __FreeBSD_version); | ficlSetEnv(bf_sys, "FreeBSD_version", __FreeBSD_version); | ||||
ficlSetEnv(bf_sys, "loader_version", | ficlSetEnv(bf_sys, "loader_version", | ||||
(bootprog_rev[0] - '0') * 10 + (bootprog_rev[2] - '0')); | (bootprog_rev[0] - '0') * 10 + (bootprog_rev[2] - '0')); | ||||
pInterp = ficlLookup(bf_sys, "interpret"); | |||||
/* try to load and run init file if present */ | /* try to load and run init file if present */ | ||||
if (rc == NULL) | if (rc == NULL) | ||||
rc = "/boot/boot.4th"; | rc = "/boot/boot.4th"; | ||||
if (*rc != '\0') { | if (*rc != '\0') { | ||||
fd = open(rc, O_RDONLY); | fd = open(rc, O_RDONLY); | ||||
if (fd != -1) { | if (fd != -1) { | ||||
(void)ficlExecFD(bf_vm, fd); | (void)ficlExecFD(bf_vm, fd); | ||||
close(fd); | close(fd); | ||||
} | } | ||||
} | } | ||||
/* Do this again, so that interpret can be redefined. */ | |||||
pInterp = ficlLookup(bf_sys, "interpret"); | |||||
} | } | ||||
/* | /* | ||||
* Feed a line of user input to the Forth interpreter | * Feed a line of user input to the Forth interpreter | ||||
*/ | */ | ||||
int | int | ||||
bf_run(char *line) | bf_run(char *line) | ||||
{ | { | ||||
Show All 33 Lines |