version 1.5, 1999/02/16 06:32:28
|
version 1.6, 1999/02/28 22:58:26
|
Line 1
|
Line 1
|
: method ( m v -- m' v ) \ mini-oof |
\ Mini-OOF 12apr98py |
\G Define a method. |
: method ( m v -- m' v ) Create over , swap cell+ swap |
Create over , swap cell+ swap |
|
DOES> ( ... o -- ... ) @ over @ + @ execute ; |
DOES> ( ... o -- ... ) @ over @ + @ execute ; |
|
: var ( m v size -- m v' ) Create over , + |
: var ( m v size -- m v' ) \ mini-oof |
|
\G Define a variable with @var{size} bytes. |
|
Create over , + |
|
DOES> ( o -- addr ) @ + ; |
DOES> ( o -- addr ) @ + ; |
|
: class ( class -- class methods vars ) dup 2@ ; |
: class ( class -- class methods vars ) \ mini-oof |
: end-class ( class methods vars -- ) |
\G Start the definition of a class. |
Create here >r , dup , 2 cells ?DO ['] noop , 1 cells +LOOP |
dup 2@ ; |
cell+ dup cell+ r> rot @ 2 cells /string move ; |
|
: defines ( xt class -- ) ' >body @ + ! ; |
: end-class ( class methods vars -- ) \ mini-oof |
: new ( class -- o ) here over @ allot swap over ! ; |
\G End the definition of a class. |
: :: ( class "name" -- ) ' >body @ + @ compile, ; |
Create here >r , dup , 2 cells ?DO ['] noop , 1 cells +LOOP |
Create object 1 cells , 2 cells , |
cell+ dup cell+ r> rot @ 2 cells /string move ; |
|
|
|
: defines ( xt class "name" -- ) \ mini-oof |
|
\G Bind @var{xt} to the method @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 @var{name} of the class @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. |
|