VolksForth/sources/generic/minioof.fth

35 lines
644 B
Forth
Raw Normal View History

2017-04-23 22:25:49 +00:00
\ Mini-OOF by Bernd Paysan
CR .( loading Mini-OOF ... )
2020-07-15 06:46:48 +00:00
2017-04-23 22:25:49 +00:00
: METHOD ( m v -- m' v )
CREATE OVER , SWAP 2+ SWAP
DOES> ( ... o -- ... )
@ OVER @ + @ EXECUTE ;
2020-07-15 06:46:48 +00:00
: VAR ( m v size -- )
2017-04-23 22:25:49 +00:00
CREATE OVER , +
2020-07-15 06:46:48 +00:00
DOES> ( o -- addr )
2017-04-23 22:25:49 +00:00
@ + ;
: CLASS ( class -- class methods vars )
DUP 2@ ;
: END-CLASS ( -- class methods vars )
2020-07-15 06:46:48 +00:00
CREATE HERE >R , DUP ,
4 ?DO ['] NOOP , 2 +LOOP
2017-04-23 22:25:49 +00:00
2+ DUP 2+ R> ROT @ 4 /STRING MOVE ;
: DEFINES ( xt class -- )
' >BODY @ + ! ;
: NEW ( class -- o )
HERE OVER @ ALLOT SWAP OVER ! ;
: :: ( class "name" -- )
' >BODY @ + @ , ;
CREATE OBJECT 2 , 4 ,
CR .( Mini-OOF loaded. )