|
1 | 1 |
|
| 2 | +cr .( Starting bootstrap stage 2... ) cr |
| 3 | + |
2 | 4 | s" d-core.f" included |
3 | 5 | s" d-core-ext.f" included |
4 | 6 | s" d-file.f" included |
| 7 | + s" d-search.f" included |
5 | 8 |
|
6 | | -:noname ; is autoboot \ TODO could use decimal to save a few bytes |
| 9 | +' decimal is autoboot |
7 | 10 |
|
8 | 11 | : savesystem ( "<spaces>name" -- ) parse-name w/o open-file drop \ TODO check status from open-file |
9 | 12 | >r ( R: fid ) |
|
21 | 24 | then |
22 | 25 | again ; is (quit) |
23 | 26 |
|
| 27 | +:noname ( -- ) |
| 28 | + '<' emit depth 0 u.r '>' emit space depth |
| 29 | + if 0 depth 2- do i pick . -1 +loop then ; is .s |
| 30 | + |
24 | 31 | \ Before saving a system, the following deferred words MUST be defined: |
25 | | -\ . .S AUTOBOOT (QUIT) |
| 32 | +\ . .S AUTOBOOT (QUIT) FIND-NAME |
| 33 | + |
| 34 | +forth-wordlist 1 set-order |
26 | 35 |
|
27 | | -.( ... saving forth-minimal ) cr |
| 36 | +.( ... saving forth-minimal ) |
28 | 37 | savesystem forth-minimal,p,w |
| 38 | +unused . s" bytes free" type cr \ 28194 |
| 39 | + |
| 40 | +environment-wordlist forth-wordlist internals-wordlist 3 set-order |
29 | 41 |
|
30 | 42 | s" d-block.f" included |
31 | 43 | s" d-block-ext.f" included |
|
42 | 54 | s" d-locals-ext.f" included |
43 | 55 | s" d-memory.f" included |
44 | 56 | \ s" d-memory-ext.f" included \ TODO no need for one yet |
45 | | - s" d-search.f" included |
46 | 57 | s" d-search-ext.f" included |
47 | 58 | s" d-string.f" included |
48 | 59 | s" d-string-ext.f" included |
|
51 | 62 | s" d-xchar.f" included |
52 | 63 | s" d-xchar-ext.f" included |
53 | 64 |
|
| 65 | +\ TODO should prompt text be separate from prompt colour? |
54 | 66 | :noname |
55 | 67 | case |
56 | | - 3 of 4 foreground endof \ error - purple |
57 | | - 2 of 14 foreground ." ok" cr endof \ prompt - lt blue |
58 | | - 1 of 7 foreground endof \ input - yellow |
| 68 | + 3 of 4 foreground endof \ error - purple |
| 69 | + 2 of 14 foreground space ." ok" cr endof \ prompt - lt blue |
| 70 | + 1 of 7 foreground endof \ input - yellow |
59 | 71 | ( 0 ) 1 foreground \ output - white |
60 | 72 | endcase ; is theme |
61 | 73 |
|
62 | | -.( ... saving forth-complete ) cr |
| 74 | +: marker ( "<spaces>name" -- ) ( -- ) |
| 75 | + here |
| 76 | + create |
| 77 | + , \ save here |
| 78 | + get-current , \ save current |
| 79 | + get-order dup , 0 ?do , loop \ save order |
| 80 | + \ save fixup to account for head of current wordlist changing when |
| 81 | + \ we did the create |
| 82 | + get-current @ @ get-current forth-wordlist - here + |
| 83 | + forth-wordlist here 20 dup allot cmove \ save wordlist table |
| 84 | + ! \ do the fixup |
| 85 | + does> |
| 86 | + dup @ to here cell+ \ restore here |
| 87 | + dup @ set-current cell+ \ restore current |
| 88 | + dup dup @ 0 ?do dup dup @ i - cells + @ swap loop @ set-order dup @ 1+ cells + \ restore order |
| 89 | + forth-wordlist 20 cmove \ restore wordlist table |
| 90 | + ; |
| 91 | + |
| 92 | +: type-file ( fileid -- ) |
| 93 | + cr >r r@ fileid>buffer |
| 94 | + begin |
| 95 | + ( c-addr u ) ( R: fileid ) |
| 96 | + 2dup r@ read-line throw ( c-addr u u2 flag ior ) ( R: fileid ) |
| 97 | + while |
| 98 | + ( c-addr u u2 ) |
| 99 | + 2 pick swap type cr |
| 100 | + repeat 2drop r> drop ; |
| 101 | + |
| 102 | +: cat ( "<spaces>name" ) parse-name r/o open-file 0<> -38 and throw |
| 103 | + dup type-file close-file drop ; |
| 104 | + |
| 105 | +only forth definitions |
| 106 | + |
| 107 | +.( ... saving forth-complete ) |
63 | 108 | savesystem forth-complete,p,w |
| 109 | +unused . s" bytes free" type cr \ 24754 |
64 | 110 |
|
65 | 111 | .( ... bootstrap stage 2 complete ) cr cr |
66 | 112 |
|
67 | | -unused . s" bytes free" type cr \ 26693 |
68 | | - |
69 | 113 | : test s" test.f" included ; |
70 | 114 |
|
71 | 115 | : bm s" benchmark.f" included ; |
72 | 116 |
|
73 | | -1 2 3 asdjfklj 4 5 6 |
| 117 | +\ see marker |
| 118 | + |
| 119 | +\ 1 2 3 asdjfklj 4 5 6 |
| 120 | + |
| 121 | +\ .( pre marker ) cr |
| 122 | +\ .( here= ) here . cr |
| 123 | +\ |
| 124 | +\ marker foo |
| 125 | +\ |
| 126 | +\ 100 allot |
| 127 | +\ |
| 128 | +\ cr |
| 129 | +\ .( after creating marker ) cr |
| 130 | +\ .s cr |
| 131 | +\ .( here= ) here . cr |
| 132 | +\ .( foo= ) s" foo" find-name . cr |
| 133 | +\ |
| 134 | +\ foo |
| 135 | +\ |
| 136 | +\ cr |
| 137 | +\ .( after running marker ) cr |
| 138 | +\ .s cr |
| 139 | +\ .( here= ) here . cr |
| 140 | +\ .( foo= ) s" foo" find-name . cr |
74 | 141 |
|
75 | 142 | .( end of bootstrap2.f ) cr |
0 commit comments