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