author | Claus Gittinger <cg@exept.de> |
Wed, 08 Feb 2006 20:15:55 +0100 | |
changeset 1672 | 56c0720718f4 |
parent 1654 | 8e793d0b9d83 |
child 1783 | f15e73db3077 |
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 |
||
0 | 78 |
name := aString |
79 |
! |
|
80 |
||
1382 | 81 |
type:typeSymbol name:aString |
82 |
type := typeSymbol. |
|
83 |
name := aString |
|
84 |
! |
|
85 |
||
140 | 86 |
used |
87 |
"return the flag marking that this variable has been used" |
|
11 | 88 |
|
140 | 89 |
^ used |
90 |
! |
|
91 |
||
92 |
used:aBoolean |
|
93 |
"set/clear the flag marking that this variable has been used" |
|
94 |
||
95 |
used := aBoolean |
|
0 | 96 |
! |
97 |
||
98 |
value |
|
11 | 99 |
"return the value of the variable" |
100 |
||
0 | 101 |
^ value |
102 |
! |
|
103 |
||
140 | 104 |
value:v |
105 |
"set the value of the (simulated) variable" |
|
106 |
||
107 |
value := v |
|
108 |
! |
|
109 |
||
31 | 110 |
variableValue |
111 |
"return the value of the variable" |
|
112 |
||
113 |
^ value |
|
140 | 114 |
! ! |
11 | 115 |
|
1035 | 116 |
!Variable methodsFor:'enumerating'! |
542 | 117 |
|
118 |
nodeDo:anEnumerator |
|
119 |
"helper for parse tree walking" |
|
120 |
||
121 |
^ anEnumerator doVariable:self name:name |
|
122 |
||
123 |
"Created: 19.6.1997 / 17:11:48 / cg" |
|
124 |
! ! |
|
125 |
||
1654 | 126 |
!Variable methodsFor:'printing & storing'! |
127 |
||
128 |
printOn:aStream |
|
129 |
aStream nextPutAll:name |
|
130 |
! ! |
|
131 |
||
1312 | 132 |
!Variable methodsFor:'special'! |
133 |
||
134 |
domain |
|
135 |
^ domain |
|
136 |
! |
|
137 |
||
138 |
domain:aDomain |
|
139 |
type := #FDVariable. |
|
140 |
domain := aDomain. |
|
141 |
! |
|
142 |
||
143 |
expressionForSetup |
|
144 |
|newDom| |
|
145 |
||
146 |
type isNil ifTrue:[^ nil]. |
|
147 |
type == #FDVariable ifTrue:[ |
|
148 |
"/ finite domain setup |
|
149 |
"/ var := FDVariable new domain:<domain-setup-message>. |
|
150 |
"/ var name:<name> |
|
151 |
||
152 |
newDom := domain instanceCreationMessage. |
|
153 |
||
154 |
^ MessageNode |
|
155 |
receiver:(VariableNode globalNamed:#FDVariable) |
|
156 |
selector:#'domain:name:' |
|
157 |
arg1:newDom |
|
158 |
arg2:(ConstantNode value:name). |
|
159 |
]. |
|
1462 | 160 |
self shouldImplement. |
1312 | 161 |
! |
162 |
||
163 |
type |
|
164 |
^ type |
|
165 |
! ! |
|
166 |
||
148 | 167 |
!Variable class methodsFor:'documentation'! |
168 |
||
169 |
version |
|
1654 | 170 |
^ '$Header: /cvs/stx/stx/libcomp/Variable.st,v 1.21 2006-01-31 16:14:49 cg Exp $' |
148 | 171 |
! ! |