1 ;; Native x86 GNU
/Linux Forth System
, Direct Threaded Code
2 ;; advanced vocabulary manipulation and creation words
4 ;; Copyright
(C
) 2020 Ketmar Dark
// Invisible Vector
6 ;; This
program is free software
: you can redistribute it and
/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation
, version
3 of the License ONLY
.
10 ;; This
program is distributed in the hope that it will be useful
,
11 ;; but WITHOUT ANY WARRANTY
; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE
. See the
13 ;; GNU General Public License
for more details
.
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this
program. If not
, see
<http
://www
.gnu
.org
/licenses
/>.
18 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 ;; returns vocabulary latest
-ptr
20 : VOCID
: ( -- addr
) \ name
22 dup word
-type? WORD
-TYPE
-VOC
<> ERR
-VOCABULARY
-EXPECTED ?error
26 compile voc
-cfa
->vocid
33 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34 ;; word overriding mechanics
35 ;; this is different from REPLACE
-- you can
call old word
if you want
to
37 ;; get xtoken
for the previous override
, to use in override chain
38 ;; if the word is not overriden
, returns
0
39 : (GET
-OVERRIDE
-OLDCFA
) ( oldcfa
-- xtoken
// 0 )
40 dup word
-type? WORD
-TYPE
-OVERRIDEN
=
48 : (OVERRIDE
-OLDCFA
-NEWCFA
) ( oldcfa newcfa
-- )
49 ;; check
if newcfa is a Forth word
50 dup word
-type? WORD
-TYPE
-FORTH
<> err
-cannot
-override ?error
51 ;; check
if oldcfa is a Forth word
, or an overriden word
52 ;; override chain works right
for overriden words
53 over word
-type? dup WORD
-TYPE
-FORTH
=
54 ;; ( oldcfa newcfa wtype forth
-flag
)
57 ;; fix new word CFA
to use par_urforth_nocall_dooverride
58 ['] (URFORTH-DOOVERRIDE-CODEBLOCK) over (call!)
59 ;; fix old word CFA so it will call new CFA instead
63 ;; ( oldcfa newcfa wtype )
64 WORD-TYPE-OVERRIDEN <> err-cannot-override ?error
65 ;; fix new word CFA to use par_urforth_nocall_dooverride
66 ['] (URFORTH
-DOOVERRIDE
-CODEBLOCK
) over
(call!)
67 ;; fix old word CFA so it will
call new CFA instead
72 : OVERRIDE
( -- ) \ oldword newword
75 (override
-oldcfa
-newcfa
)
78 ;; get xtoken
for the previous override
, to use in override chain
79 ;; if the word is not overriden
, returns
0
80 : GET
-OVERRIDE
( -- xtoken
// 0 ) \ oldword