File:
[gforth] /
gforth /
wordinfo.fs
Revision
1.14:
download - view:
text,
annotated -
select for diffs
Sun Jul 6 14:29:34 1997 UTC (26 years, 9 months ago) by
jwilke
Branches:
MAIN
CVS tags:
HEAD
See got some more bug fixes.
Quick changes to let all cross-compile, and fit into ec-version.
These files are still on my ToDo list, changes are not complete now.
Jens
1: \ WORDINFO.FS V1.0 17may93jaw
2:
3: \ Copyright (C) 1995 Free Software Foundation, Inc.
4:
5: \ This file is part of Gforth.
6:
7: \ Gforth is free software; you can redistribute it and/or
8: \ modify it under the terms of the GNU General Public License
9: \ as published by the Free Software Foundation; either version 2
10: \ of the License, or (at your option) any later version.
11:
12: \ This program is distributed in the hope that it will be useful,
13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: \ GNU General Public License for more details.
16:
17: \ You should have received a copy of the GNU General Public License
18: \ along with this program; if not, write to the Free Software
19: \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20:
21: \ May be cross-compiled
22: \ If you want check values then exclude comments,
23: \ but keep in mind that this can't be cross-compiled
24:
25: \ INCLUDE look.fs
26:
27: \ Wordinfo is a tool that checks a nfa
28: \ and finds out what wordtype we have
29: \ it is used in SEE.FS
30:
31: \ the old alias? did not work and it is not used, so I changed
32: \ it in many respects - anton
33: : alias? ( nfa1 -- nfa2|0 )
34: \ if nfa1 is an alias, nfa2 is the name of the original word
35: dup cell+ c@ alias-mask and 0=
36: IF ( nfa1 )
37: ((name>)) @ >name ( use look instead? )
38: ELSE
39: drop 0
40: THEN ;
41:
42: : var? ( nfa -- flag )
43: ((name>)) >code-address dovar: = ;
44:
45: : con? ( nfa -- flag )
46: ((name>)) >code-address docon: = ;
47:
48: : user? ( nfa -- flag )
49: ((name>)) >code-address douser: = ;
50:
51: : does? ( nfa -- flag )
52: ((name>))
53: >does-code 0<> ;
54:
55: : defered? ( nfa -- flag )
56: ((name>)) >code-address dodefer: = ;
57:
58: : colon? ( nfa -- flag )
59: ((name>)) >code-address docol: = ;
60:
61: \ the above words could be factored with create-does>, but this would
62: \ probably make this file incompatible with cross.
63:
64: [IFDEF] forthstart
65: : xtprim? ( xt -- flag )
66: forthstart u< ;
67: [ELSE]
68: : xtprim? ( xt -- flag )
69: dup >body swap >code-address = ;
70: [THEN]
71: : prim? ( nfa -- flag )
72: name>int xtprim? ;
73:
74: \ None nestable IDs:
75:
76: 1 CONSTANT Pri# \ Primitives
77: 2 CONSTANT Con# \ Constants
78: 3 CONSTANT Var# \ Variables
79: 4 CONSTANT Val# \ Values
80:
81: \ Nestabe IDs:
82:
83: 5 CONSTANT Doe# \ Does part
84: 6 CONSTANT Def# \ Defer
85: 7 CONSTANT Col# \ Colon def
86: 8 CONSTANT Use# \ User variable
87:
88: \ Nobody knows:
89:
90: 9 CONSTANT Ali# \ Alias
91:
92: 10 CONSTANT Str# \ Structure words
93:
94: 11 CONSTANT Com# \ Compiler directives : ; POSTPONE
95:
96: CREATE InfoTable
97: ' Prim? A, Pri# ,
98: ' Alias? A, Ali# ,
99: ' Con? A, Con# ,
100: ' Var? A, Var# ,
101: \ ' Value? A, Val# ,
102: ' Defered? A, Def# ,
103: ' Does? A, Doe# ,
104: ' Colon? A, Col# ,
105: ' User? A, Use# ,
106: 0 ,
107:
108: : WordInfo ( nfa --- code )
109: InfoTable
110: BEGIN dup @ dup
111: WHILE swap 2 cells + swap
112: 2 pick swap execute
113: UNTIL
114: 1 cells - @ nip
115: ELSE
116: 2drop drop 0
117: THEN ;
118:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>