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