author | Claus Gittinger <cg@exept.de> |
Wed, 10 Apr 2019 06:00:19 +0200 | |
changeset 4404 | 6e531fff6ba8 |
parent 4131 | 73ab5306cf93 |
child 4550 | 5b5e05164937 |
permissions | -rw-r--r-- |
14 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
104 | 3 |
All Rights Reserved |
14 | 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 |
" |
|
1080 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
4131 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
14 | 16 |
PrimaryNode subclass:#SelfNode |
261 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler-Support' |
|
14 | 21 |
! |
22 |
||
20 | 23 |
!SelfNode class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
104 | 28 |
All Rights Reserved |
20 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
node for parse-trees, representing self |
|
261 | 42 |
This is a helper class for the compiler. |
263 | 43 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
20 | 46 |
" |
47 |
! ! |
|
14 | 48 |
|
49 |
!SelfNode class methodsFor:'instance creation'! |
|
50 |
||
51 |
value:val |
|
52 |
^ (self basicNew) value:val |
|
53 |
! ! |
|
54 |
||
55 |
!SelfNode methodsFor:'accessing'! |
|
56 |
||
542 | 57 |
name |
58 |
^ 'self' |
|
59 |
||
60 |
"Created: 19.6.1997 / 17:20:22 / cg" |
|
61 |
! |
|
62 |
||
14 | 63 |
value:val |
64 |
type := #Self. |
|
65 |
value := val. |
|
66 |
! ! |
|
67 |
||
140 | 68 |
!SelfNode methodsFor:'code generation'! |
69 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
70 |
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
71 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
72 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
73 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
74 |
aStream nextPut:#retSelf |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
75 |
! |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
76 |
|
140 | 77 |
codeOn:aStream inBlock:codeBlock for:aCompiler |
78 |
aStream nextPut:#pushSelf |
|
79 |
! |
|
80 |
||
81 |
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
82 |
"not reached - parser has already checked this" |
|
83 |
||
84 |
^ self error:'store into self - cannot happen' |
|
85 |
! ! |
|
86 |
||
1035 | 87 |
!SelfNode methodsFor:'enumerating'! |
542 | 88 |
|
89 |
nodeDo:anEnumerator |
|
90 |
"helper for parse tree walking" |
|
91 |
||
92 |
^ anEnumerator doVariable:self name:'self' |
|
93 |
||
94 |
"Created: 19.6.1997 / 17:20:02 / cg" |
|
95 |
! ! |
|
96 |
||
1035 | 97 |
!SelfNode methodsFor:'evaluation'! |
14 | 98 |
|
1384 | 99 |
evaluateIn:anEnvironment |
100 |
anEnvironment notNil ifTrue:[ |
|
101 |
^ anEnvironment receiver. |
|
102 |
]. |
|
14 | 103 |
^ value |
104 |
! |
|
105 |
||
106 |
store:aValue |
|
107 |
"not reached - parser has already checked this" |
|
108 |
||
109 |
self error:'store into self - cannot happen' |
|
110 |
! ! |
|
111 |
||
1080 | 112 |
!SelfNode methodsFor:'printing & storing'! |
14 | 113 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
114 |
displayOn:aGCOrStream |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
115 |
"Compatibility |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
116 |
append a printed desription on some stream (Dolphin, Squeak) |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
117 |
OR: |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
118 |
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
|
119 |
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
|
120 |
(although the fallBack is to display its printString ...)" |
612 | 121 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
122 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
4131 | 123 |
"/ old ST80 means: draw-yourself on a GC. |
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
124 |
aGCOrStream isStream ifFalse:[ |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
125 |
^ super displayOn:aGCOrStream. |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
126 |
]. |
612 | 127 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
128 |
aGCOrStream |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
129 |
nextPutAll:'InterpreterVariable(self)'. |
4131 | 130 |
|
131 |
"Modified (comment): / 22-02-2017 / 16:50:05 / cg" |
|
14 | 132 |
! |
133 |
||
134 |
printOn:aStream indent:i |
|
135 |
aStream nextPutAll:'self' |
|
136 |
! ! |
|
140 | 137 |
|
2323 | 138 |
!SelfNode methodsFor:'testing'! |
862 | 139 |
|
140 |
isSelf |
|
141 |
"return true, if this is a self-node" |
|
142 |
||
143 |
^ self class == SelfNode |
|
144 |
||
145 |
||
146 |
! ! |
|
147 |
||
2604 | 148 |
!SelfNode methodsFor:'visiting'! |
149 |
||
150 |
acceptVisitor:aVisitor |
|
151 |
"Double dispatch back to the visitor, passing my type encoded in |
|
152 |
the selector (visitor pattern)" |
|
153 |
||
154 |
"stub code automatically generated - please change if required" |
|
155 |
||
156 |
^ aVisitor visitSelfNode:self |
|
157 |
! ! |
|
158 |
||
148 | 159 |
!SelfNode class methodsFor:'documentation'! |
160 |
||
161 |
version |
|
4131 | 162 |
^ '$Header$' |
2323 | 163 |
! |
164 |
||
165 |
version_CVS |
|
4131 | 166 |
^ '$Header$' |
148 | 167 |
! ! |
4131 | 168 |