![]() ![]() | ![]() |
1.1 anton 1: \ EXTEND.FS CORE-EXT Word not fully tested! 12may93jaw
2:
3: \ May be cross-compiled
4:
5: decimal
6:
7: \ .( 12may93jaw
8:
9: : .( [char] ) parse type ;
10:
11: \ VALUE 2>R 2R> 2R@ 17may93jaw
12:
1.3 anton 13: : value ( n -- )
14: (constant) , ;
15: \ !! 2value
1.1 anton 16:
1.2 pazsan 17: : 2Literal swap postpone Literal postpone Literal ;
18: immediate restrict
19:
1.4 pazsan 20: : m*/ ( d1 n2 u3 -- dqout ) >r s>d >r abs -rot
21: s>d r> xor r> swap >r >r dabs rot tuck um* 2swap um*
22: swap >r 0 d+ r> -rot r@ um/mod -rot r> um/mod nip swap
23: r> IF dnegate THEN ;
24:
1.1 anton 25: \ CASE OF ENDOF ENDCASE 17may93jaw
26:
27: \ just as described in dpANS5
28:
29: 0 CONSTANT case immediate
30:
31: : of
32: 1+ >r
33: postpone over postpone = postpone if postpone drop
34: r> ; immediate
35:
36: : endof
37: >r postpone else r> ; immediate
38:
39: : endcase
40: postpone drop
41: 0 ?do postpone then loop ; immediate
42:
43: \ C" 17may93jaw
44:
45: : (c") "lit ;
46:
47: : CLiteral postpone (c") here over char+ allot place align ;
48: immediate restrict
49: : C" [char] " parse postpone CLiteral ; immediate restrict
50:
51: \ UNUSED 17may93jaw
52:
1.4 pazsan 53: : unused s0 @ 512 - \ for stack
54: here - ;
1.1 anton 55:
56: \ [COMPILE] 17may93jaw
57:
58: : [compile]
59: ' compile, ; immediate
60:
61: \ MARKER 17may93jaw
62:
63: \ : marker here last @ create , , DOES> dup @ last ! cell+ @ dp ! ;
64: \ doesn't work now. vocabularies?
65:
66: \ CONVERT 17may93jaw
67:
68: : convert true >number drop ;
69:
70: \ ERASE 17may93jaw
71:
1.2 pazsan 72: : erase ( 0 1 chars um/mod nip ) 0 fill ;
73: : blank ( 0 1 chars um/mod nip ) bl fill ;
1.1 anton 74:
75: \ ROLL 17may93jaw
76:
77: : roll dup 1+ pick >r
1.6 ! pazsan 78: cells sp@ cell+ dup cell+ rot move drop r> ;
1.1 anton 79:
80: \ SOURCE-ID SAVE-INPUT RESTORE-INPUT 11jun93jaw
81:
82: : source-id ( -- 0 | -1 | fileid )
1.4 pazsan 83: loadfile @ dup 0= IF drop loadline @ 0 min THEN ;
1.1 anton 84:
85: : save-input ( -- x1 .. xn n )
86: >in @
87: loadfile @ ?dup
1.4 pazsan 88: IF dup file-position throw loadline @ >tib @ 6
89: #tib @ >tib +!
90: ELSE loadline @ blk @ linestart @ >tib @ 5 THEN
91: ;
1.1 anton 92:
93: : restore-input ( x1 .. xn n -- flag )
1.4 pazsan 94: swap >tib !
95: 6 = IF loadline ! rot dup loadfile !
1.1 anton 96: reposition-file IF drop true EXIT THEN
97: ELSE linestart ! blk !
98: dup loadline @ <> IF 2drop true EXIT THEN
99: loadline !
100: THEN
101: >in ! false ;
102:
103:
104:
105: \ This things we don't need, but for being complete... jaw
106:
107: \ EXPECT SPAN 17may93jaw
108:
109: variable span
110:
111: : expect ( c-addr +len -- )
112: 0 rot over
113: BEGIN key decode >r 2over = r> or UNTIL
114: 2drop nip span ! ;
115: