File: moofglos.fs

package info (click to toggle)
gforth 0.6.2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,268 kB
  • ctags: 1,534
  • sloc: ansic: 6,256; sh: 3,044; lisp: 1,788; makefile: 873; yacc: 186; sed: 141; lex: 104; awk: 21
file content (38 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
\ This contains the same Forth source as mini-oof.fs, but
\ also contains glossary information for the manual.

: method ( m v "name" -- m' v ) \ mini-oof
    \G Define a selector.
    Create  over , swap cell+ swap
  DOES> ( ... o -- ... ) @ over @ + @ execute ;

: var ( m v size "name" -- m v' ) \ mini-oof
    \G Define a variable with @var{size} bytes.
    Create  over , +
  DOES> ( o -- addr ) @ + ;

: class ( class -- class selectors vars ) \ mini-oof
    \G Start the definition of a class.
    dup 2@ ;

: end-class  ( class selectors vars "name" -- ) \ mini-oof
    \G End the definition of a class.
    Create  here >r , dup , 2 cells ?DO ['] noop , 1 cells +LOOP
    cell+ dup cell+ r> rot @ 2 cells /string move ;

: defines ( xt class "name" -- ) \ mini-oof
    \G Bind @var{xt} to the selector @var{name} in class @var{class}.
    ' >body @ + ! ;

: new ( class -- o ) \ mini-oof
    \G Create a new incarnation of the class @var{class}.
    here over @ allot swap over ! ;

: :: ( class "name" -- ) \ mini-oof colon-colon
    \G Compile the method for the selector @var{name} of the class
    \G @var{class} (not immediate!).
    ' >body @ + @ compile, ;

Create object ( -- a-addr ) \ mini-oof
1 cells , 2 cells ,
\G @var{object} is the base class of all objects.