author | Claus Gittinger <cg@exept.de> |
Tue, 23 Apr 2019 23:14:55 +0200 | |
changeset 4407 | cf8780f42d7e |
parent 4294 | 827e6e3e113c |
permissions | -rw-r--r-- |
4294 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
4 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
135
aa4f7b8f121e
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
103
diff
changeset
|
5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1147 | 14 |
"{ Package: 'stx:libcomp' }" |
15 |
||
4294 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
Object subclass:#Variable |
1598 | 19 |
instanceVariableNames:'value name used type domain classHint' |
261 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'System-Compiler-Support' |
|
0 | 23 |
! |
24 |
||
20 | 25 |
!Variable class methodsFor:'documentation'! |
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
135
aa4f7b8f121e
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
103
diff
changeset
|
30 |
All Rights Reserved |
20 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
node for parse-trees, representing variables |
|
261 | 44 |
This is a helper class for the compiler. |
263 | 45 |
|
46 |
[author:] |
|
47 |
Claus Gittinger |
|
20 | 48 |
" |
49 |
! ! |
|
0 | 50 |
|
51 |
!Variable class methodsFor:'instance creation'! |
|
52 |
||
53 |
name:name |
|
11 | 54 |
"return a new node for a variable named name" |
0 | 55 |
^ (self new) name:name |
1382 | 56 |
! |
57 |
||
58 |
type:type name:name |
|
59 |
^ (self new) type:type name:name |
|
0 | 60 |
! ! |
61 |
||
62 |
!Variable methodsFor:'accessing'! |
|
63 |
||
1598 | 64 |
classHint |
65 |
^ classHint |
|
66 |
! |
|
67 |
||
68 |
classHint:something |
|
69 |
classHint := something. |
|
70 |
! |
|
71 |
||
140 | 72 |
name |
73 |
"return the name of the variable" |
|
11 | 74 |
|
140 | 75 |
^ name |
0 | 76 |
! |
77 |
||
4294 | 78 |
name:nameString |
11 | 79 |
"set the name of the variable" |
80 |
||
1783 | 81 |
"/ self assert:(aString isString). |
4294 | 82 |
"/ self assert:nameString notNil. |
83 |
name := nameString |
|
1783 | 84 |
|
85 |
"Modified: / 07-08-2006 / 12:18:12 / cg" |
|
4294 | 86 |
"Modified: / 27-08-2018 / 13:40:33 / Claus Gittinger" |
0 | 87 |
! |
88 |
||
4294 | 89 |
type:typeSymbol name:nameString |
90 |
"/ self assert:nameString notNil. |
|
1783 | 91 |
"/ self assert:(aString isString). |
1382 | 92 |
type := typeSymbol. |
4294 | 93 |
name := nameString |
1783 | 94 |
|
95 |
"Modified: / 07-08-2006 / 12:18:08 / cg" |
|
4294 | 96 |
"Modified: / 27-08-2018 / 13:40:37 / Claus Gittinger" |
1382 | 97 |
! |
98 |
||
140 | 99 |
used |
100 |
"return the flag marking that this variable has been used" |
|
11 | 101 |
|
140 | 102 |
^ used |
103 |
! |
|
104 |
||
105 |
used:aBoolean |
|
106 |
"set/clear the flag marking that this variable has been used" |
|
107 |
||
108 |
used := aBoolean |
|
0 | 109 |
! |
110 |
||
111 |
value |
|
11 | 112 |
"return the value of the variable" |
113 |
||
0 | 114 |
^ value |
115 |
! |
|
116 |
||
140 | 117 |
value:v |
118 |
"set the value of the (simulated) variable" |
|
119 |
||
120 |
value := v |
|
121 |
! |
|
122 |
||
31 | 123 |
variableValue |
124 |
"return the value of the variable" |
|
125 |
||
126 |
^ value |
|
140 | 127 |
! ! |
11 | 128 |
|
1035 | 129 |
!Variable methodsFor:'enumerating'! |
542 | 130 |
|
131 |
nodeDo:anEnumerator |
|
132 |
"helper for parse tree walking" |
|
133 |
||
134 |
^ anEnumerator doVariable:self name:name |
|
135 |
||
136 |
"Created: 19.6.1997 / 17:11:48 / cg" |
|
137 |
! ! |
|
138 |
||
1654 | 139 |
!Variable methodsFor:'printing & storing'! |
140 |
||
141 |
printOn:aStream |
|
142 |
aStream nextPutAll:name |
|
143 |
! ! |
|
144 |
||
1312 | 145 |
!Variable methodsFor:'special'! |
146 |
||
147 |
domain |
|
148 |
^ domain |
|
149 |
! |
|
150 |
||
151 |
domain:aDomain |
|
152 |
type := #FDVariable. |
|
153 |
domain := aDomain. |
|
154 |
! |
|
155 |
||
156 |
expressionForSetup |
|
157 |
|newDom| |
|
158 |
||
159 |
type isNil ifTrue:[^ nil]. |
|
160 |
type == #FDVariable ifTrue:[ |
|
161 |
"/ finite domain setup |
|
162 |
"/ var := FDVariable new domain:<domain-setup-message>. |
|
163 |
"/ var name:<name> |
|
164 |
||
165 |
newDom := domain instanceCreationMessage. |
|
166 |
||
167 |
^ MessageNode |
|
168 |
receiver:(VariableNode globalNamed:#FDVariable) |
|
169 |
selector:#'domain:name:' |
|
170 |
arg1:newDom |
|
171 |
arg2:(ConstantNode value:name). |
|
172 |
]. |
|
1462 | 173 |
self shouldImplement. |
1312 | 174 |
! |
175 |
||
176 |
type |
|
177 |
^ type |
|
178 |
! ! |
|
179 |
||
148 | 180 |
!Variable class methodsFor:'documentation'! |
181 |
||
182 |
version |
|
4294 | 183 |
^ '$Header$' |
148 | 184 |
! ! |
4294 | 185 |