1 /* yForth? - A Forth interpreter written in ANSI C
2 * Copyright (C) 2012 Luca Padovani
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * ------------------------------------------------------------------------
25 /**************************************************************************/
26 /* VARIABLES **************************************************************/
27 /**************************************************************************/
29 struct vocabulary *list[WORD_LISTS];
30 Cell top; /* indice primo vocabolario sulla pila */
31 struct vocabulary *voc; /* ptr al vocabolario usato per le definzioni */
32 struct vocabulary *forth_wid;
34 /**************************************************************************/
35 /* WORDS ******************************************************************/
36 /**************************************************************************/
42 void _forth_wordlist() {
43 *--sp = (Cell) forth_wid;
52 for (i = 0; i <= top; i++) *--sp = (Cell) list[i];
56 void _search_wordlist() {
57 register struct vocabulary *wid = (struct vocabulary *) *sp++;
58 register Cell len = *sp++;
59 register Char *addr = (Char *) *sp;
60 register struct word_def *xt = search_wordlist(addr, len, wid);
61 set_find_stack(addr, xt);
66 voc = (struct vocabulary *) *sp++;
70 register Cell n = *sp++;
72 for (i = 0; i < n; i++)
73 if (i < WORD_LISTS) list[i] = (struct vocabulary *) *sp++;
79 register struct vocabulary *v;
82 v = (struct vocabulary *) _dp;
83 _dp += sizeof(struct vocabulary);
84 for (i = 0; i < VOC_HASH; i++) v->voc[i] = NULL;
89 /**************************************************************************/
90 /* AUXILIARY FUNCTIONS ****************************************************/
91 /**************************************************************************/
93 void save_vocabulary(struct voc_marker *vm) {
95 for (i = 0; i < WORD_LISTS; i++) {
96 vm->list[i] = list[i];
97 if (list[i]) vm->v_list[i] = *list[i];
105 void load_vocabulary(struct voc_marker *vm) {
107 for (i = 0; i < WORD_LISTS; i++) {
108 list[i] = vm->list[i];
109 if (list[i]) *list[i] = vm->v_list[i];