Annotation of gforth/moofglos.fs, revision 1.2

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>