author | Jan Vrany <jan.vrany@labware.com> |
Thu, 27 Oct 2022 14:53:59 +0100 | |
branch | jv |
changeset 4735 | 3b11fb3ede98 |
parent 4550 | 5b5e05164937 |
permissions | -rw-r--r-- |
4550 | 1 |
"{ Encoding: utf8 }" |
2 |
||
14 | 3 |
" |
4 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
104 | 5 |
All Rights Reserved |
14 | 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 |
" |
|
1080 | 14 |
"{ Package: 'stx:libcomp' }" |
15 |
||
4131 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
14 | 18 |
PrimaryNode subclass:#SelfNode |
261 | 19 |
instanceVariableNames:'' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'System-Compiler-Support' |
|
14 | 23 |
! |
24 |
||
20 | 25 |
!SelfNode class methodsFor:'documentation'! |
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
104 | 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 self |
|
261 | 44 |
This is a helper class for the compiler. |
263 | 45 |
|
46 |
[author:] |
|
47 |
Claus Gittinger |
|
20 | 48 |
" |
49 |
! ! |
|
14 | 50 |
|
51 |
!SelfNode class methodsFor:'instance creation'! |
|
52 |
||
53 |
value:val |
|
54 |
^ (self basicNew) value:val |
|
55 |
! ! |
|
56 |
||
57 |
!SelfNode methodsFor:'accessing'! |
|
58 |
||
542 | 59 |
name |
60 |
^ 'self' |
|
61 |
||
62 |
"Created: 19.6.1997 / 17:20:22 / cg" |
|
63 |
! |
|
64 |
||
14 | 65 |
value:val |
66 |
type := #Self. |
|
67 |
value := val. |
|
68 |
! ! |
|
69 |
||
140 | 70 |
!SelfNode methodsFor:'code generation'! |
71 |
||
4550 | 72 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
73 |
"no code at all" |
|
74 |
||
75 |
aCompiler |
|
76 |
warning:'Useless reference to this' |
|
77 |
position:startPosition to:endPosition. |
|
78 |
||
79 |
^ self |
|
80 |
! |
|
81 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
82 |
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
83 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
84 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
85 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
86 |
aStream nextPut:#retSelf |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
87 |
! |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
88 |
|
140 | 89 |
codeOn:aStream inBlock:codeBlock for:aCompiler |
90 |
aStream nextPut:#pushSelf |
|
91 |
! |
|
92 |
||
93 |
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
94 |
"not reached - parser has already checked this" |
|
95 |
||
96 |
^ self error:'store into self - cannot happen' |
|
97 |
! ! |
|
98 |
||
1035 | 99 |
!SelfNode methodsFor:'enumerating'! |
542 | 100 |
|
101 |
nodeDo:anEnumerator |
|
102 |
"helper for parse tree walking" |
|
103 |
||
104 |
^ anEnumerator doVariable:self name:'self' |
|
105 |
||
106 |
"Created: 19.6.1997 / 17:20:02 / cg" |
|
107 |
! ! |
|
108 |
||
1035 | 109 |
!SelfNode methodsFor:'evaluation'! |
14 | 110 |
|
1384 | 111 |
evaluateIn:anEnvironment |
112 |
anEnvironment notNil ifTrue:[ |
|
113 |
^ anEnvironment receiver. |
|
114 |
]. |
|
14 | 115 |
^ value |
116 |
! |
|
117 |
||
118 |
store:aValue |
|
119 |
"not reached - parser has already checked this" |
|
120 |
||
121 |
self error:'store into self - cannot happen' |
|
122 |
! ! |
|
123 |
||
1080 | 124 |
!SelfNode methodsFor:'printing & storing'! |
14 | 125 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
126 |
displayOn:aGCOrStream |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
127 |
"Compatibility |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
128 |
append a printed desription on some stream (Dolphin, Squeak) |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
129 |
OR: |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
130 |
display the receiver in a graphicsContext at 0@0 (ST80). |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
131 |
This method allows for any object to be displayed in some view |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
132 |
(although the fallBack is to display its printString ...)" |
612 | 133 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
134 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
4131 | 135 |
"/ old ST80 means: draw-yourself on a GC. |
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
136 |
aGCOrStream isStream ifFalse:[ |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
137 |
^ super displayOn:aGCOrStream. |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
138 |
]. |
612 | 139 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
140 |
aGCOrStream |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
141 |
nextPutAll:'InterpreterVariable(self)'. |
4131 | 142 |
|
143 |
"Modified (comment): / 22-02-2017 / 16:50:05 / cg" |
|
14 | 144 |
! |
145 |
||
146 |
printOn:aStream indent:i |
|
147 |
aStream nextPutAll:'self' |
|
148 |
! ! |
|
140 | 149 |
|
2323 | 150 |
!SelfNode methodsFor:'testing'! |
862 | 151 |
|
152 |
isSelf |
|
153 |
"return true, if this is a self-node" |
|
154 |
||
155 |
^ self class == SelfNode |
|
156 |
||
157 |
||
158 |
! ! |
|
159 |
||
2604 | 160 |
!SelfNode methodsFor:'visiting'! |
161 |
||
162 |
acceptVisitor:aVisitor |
|
163 |
"Double dispatch back to the visitor, passing my type encoded in |
|
164 |
the selector (visitor pattern)" |
|
165 |
||
166 |
"stub code automatically generated - please change if required" |
|
167 |
||
168 |
^ aVisitor visitSelfNode:self |
|
169 |
! ! |
|
170 |
||
148 | 171 |
!SelfNode class methodsFor:'documentation'! |
172 |
||
173 |
version |
|
4131 | 174 |
^ '$Header$' |
2323 | 175 |
! |
176 |
||
177 |
version_CVS |
|
4131 | 178 |
^ '$Header$' |
148 | 179 |
! ! |
4131 | 180 |