19 |
int type; |
int type; |
20 |
|
|
21 |
/* Symbol value. */ |
/* Symbol value. */ |
22 |
int val; |
integer_t val; |
23 |
|
|
24 |
/* For function symbols; type of value returned by function. */ |
/* For function symbols; type of value returned by function. */ |
25 |
int ret_type; |
int ret_type; |
46 |
int type; |
int type; |
47 |
|
|
48 |
/* Argument value. */ |
/* Argument value. */ |
49 |
int val; |
integer_t val; |
50 |
}; |
}; |
51 |
|
|
52 |
/* List of commands. */ |
/* List of commands. */ |
93 |
/* List of builtin symbols. */ |
/* List of builtin symbols. */ |
94 |
static struct sym builtin_symbols[] = |
static struct sym builtin_symbols[] = |
95 |
{ |
{ |
96 |
{ "task-create", VAL_FUNC, (int) create_task, VAL_TASK, 0 }, |
{ "task-create", VAL_FUNC, (integer_t) create_task, VAL_TASK, 0 }, |
97 |
{ "task-resume", VAL_FUNC, (int) resume_task, VAL_NONE, 1 }, |
{ "task-resume", VAL_FUNC, (integer_t) resume_task, VAL_NONE, 1 }, |
98 |
{ "prompt-task-resume", VAL_FUNC, (int) prompt_resume_task, VAL_NONE, 1 }, |
{ "prompt-task-resume", |
99 |
|
VAL_FUNC, (integer_t) prompt_resume_task, VAL_NONE, 1 }, |
100 |
}; |
}; |
101 |
#define NUM_BUILTIN (sizeof (builtin_symbols) / sizeof (builtin_symbols[0])) |
#define NUM_BUILTIN (sizeof (builtin_symbols) / sizeof (builtin_symbols[0])) |
102 |
|
|
297 |
for (p += 2;;) |
for (p += 2;;) |
298 |
{ |
{ |
299 |
char c; |
char c; |
300 |
int i, val, type; |
int i, type; |
301 |
|
integer_t val; |
302 |
struct sym *s; |
struct sym *s; |
303 |
|
|
304 |
/* Parse symbol name. */ |
/* Parse symbol name. */ |
353 |
if (! s->run_on_exec) |
if (! s->run_on_exec) |
354 |
{ |
{ |
355 |
(error |
(error |
356 |
= ((*((int (*) (struct cmd *, int *)) s->val)) |
= ((*((int (*) (struct cmd *, integer_t *)) s->val)) |
357 |
(cmd, &val))); |
(cmd, &val))); |
358 |
if (error) |
if (error) |
359 |
goto bad; |
goto bad; |
375 |
else if (s->type == VAL_NONE) |
else if (s->type == VAL_NONE) |
376 |
{ |
{ |
377 |
type = VAL_SYM; |
type = VAL_SYM; |
378 |
val = (int) s; |
val = (integer_t) s; |
379 |
} |
} |
380 |
else |
else |
381 |
{ |
{ |
645 |
for (i = 0; i < cmd->exec_funcs_index; i++) |
for (i = 0; i < cmd->exec_funcs_index; i++) |
646 |
{ |
{ |
647 |
struct sym *sym = cmd->exec_funcs[i]; |
struct sym *sym = cmd->exec_funcs[i]; |
648 |
int error = ((*((int (*) (struct cmd *, int *)) sym->val)) |
int error = ((*((int (*) (struct cmd *, integer_t *)) sym->val)) |
649 |
(cmd, 0)); |
(cmd, 0)); |
650 |
if (error) |
if (error) |
651 |
{ |
{ |
662 |
/* Create an entry for the variable NAME with TYPE and value VAL, |
/* Create an entry for the variable NAME with TYPE and value VAL, |
663 |
in the symbol table. */ |
in the symbol table. */ |
664 |
int |
int |
665 |
boot_script_set_variable (const char *name, int type, int val) |
boot_script_set_variable (const char *name, int type, integer_t val) |
666 |
{ |
{ |
667 |
struct sym *sym = sym_enter (name); |
struct sym *sym = sym_enter (name); |
668 |
|
|
678 |
/* Define the function NAME, which will return type RET_TYPE. */ |
/* Define the function NAME, which will return type RET_TYPE. */ |
679 |
int |
int |
680 |
boot_script_define_function (const char *name, int ret_type, |
boot_script_define_function (const char *name, int ret_type, |
681 |
int (*func) (const struct cmd *cmd, int *val)) |
int (*func) (const struct cmd *cmd, |
682 |
|
integer_t *val)) |
683 |
{ |
{ |
684 |
struct sym *sym = sym_enter (name); |
struct sym *sym = sym_enter (name); |
685 |
|
|
686 |
if (sym) |
if (sym) |
687 |
{ |
{ |
688 |
sym->type = VAL_FUNC; |
sym->type = VAL_FUNC; |
689 |
sym->val = (int) func; |
sym->val = (integer_t) func; |
690 |
sym->ret_type = ret_type; |
sym->ret_type = ret_type; |
691 |
sym->run_on_exec = ret_type == VAL_NONE; |
sym->run_on_exec = ret_type == VAL_NONE; |
692 |
} |
} |