[gforth] / gforth / moofglos.fs  

gforth: gforth/moofglos.fs


1 : crook 1.3 \ This contains the same Forth source as mini-oof.fs, but
2 :     \ also contains glossary information for the manual.
3 :    
4 : anton 1.4 : method ( m v "name" -- m' v ) \ mini-oof
5 :     \G Define a selector.
6 : pazsan 1.2 Create over , swap cell+ swap
7 :     DOES> ( ... o -- ... ) @ over @ + @ execute ;
8 :    
9 : anton 1.4 : var ( m v size "name" -- m v' ) \ mini-oof
10 : pazsan 1.2 \G Define a variable with @var{size} bytes.
11 :     Create over , +
12 :     DOES> ( o -- addr ) @ + ;
13 :    
14 : anton 1.4 : class ( class -- class selectors vars ) \ mini-oof
15 : pazsan 1.2 \G Start the definition of a class.
16 :     dup 2@ ;
17 :    
18 : anton 1.4 : end-class ( class selectors vars "name" -- ) \ mini-oof
19 : pazsan 1.2 \G End the definition of a class.
20 :     Create here >r , dup , 2 cells ?DO ['] noop , 1 cells +LOOP
21 :     cell+ dup cell+ r> rot @ 2 cells /string move ;
22 :    
23 :     : defines ( xt class "name" -- ) \ mini-oof
24 : anton 1.4 \G Bind @var{xt} to the selector @var{name} in class @var{class}.
25 : pazsan 1.2 ' >body @ + ! ;
26 :    
27 :     : new ( class -- o ) \ mini-oof
28 :     \G Create a new incarnation of the class @var{class}.
29 :     here over @ allot swap over ! ;
30 :    
31 :     : :: ( class "name" -- ) \ mini-oof colon-colon
32 : anton 1.4 \G Compile the method for the selector @var{name} of the class
33 :     \G @var{class} (not immediate!).
34 : pazsan 1.2 ' >body @ + @ compile, ;
35 :    
36 :     Create object ( -- a-addr ) \ mini-oof
37 :     1 cells , 2 cells ,
38 :     \G @var{object} is the base class of all objects.

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help