author | Stefan Vogel <sv@exept.de> |
Fri, 03 Aug 2012 17:53:28 +0200 | |
changeset 2896 | b94f53848481 |
parent 2604 | d5a9c6f694df |
child 4131 | 73ab5306cf93 |
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 |
||
14 | 14 |
PrimaryNode subclass:#SelfNode |
261 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'System-Compiler-Support' |
|
14 | 19 |
! |
20 |
||
20 | 21 |
!SelfNode class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
104 | 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 self |
|
261 | 40 |
This is a helper class for the compiler. |
263 | 41 |
|
42 |
[author:] |
|
43 |
Claus Gittinger |
|
20 | 44 |
" |
45 |
! ! |
|
14 | 46 |
|
47 |
!SelfNode class methodsFor:'instance creation'! |
|
48 |
||
49 |
value:val |
|
50 |
^ (self basicNew) value:val |
|
51 |
! ! |
|
52 |
||
53 |
!SelfNode methodsFor:'accessing'! |
|
54 |
||
542 | 55 |
name |
56 |
^ 'self' |
|
57 |
||
58 |
"Created: 19.6.1997 / 17:20:22 / cg" |
|
59 |
! |
|
60 |
||
14 | 61 |
value:val |
62 |
type := #Self. |
|
63 |
value := val. |
|
64 |
! ! |
|
65 |
||
140 | 66 |
!SelfNode methodsFor:'code generation'! |
67 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
68 |
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
69 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
70 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
71 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
72 |
aStream nextPut:#retSelf |
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 |
|
140 | 75 |
codeOn:aStream inBlock:codeBlock for:aCompiler |
76 |
aStream nextPut:#pushSelf |
|
77 |
! |
|
78 |
||
79 |
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
80 |
"not reached - parser has already checked this" |
|
81 |
||
82 |
^ self error:'store into self - cannot happen' |
|
83 |
! ! |
|
84 |
||
1035 | 85 |
!SelfNode methodsFor:'enumerating'! |
542 | 86 |
|
87 |
nodeDo:anEnumerator |
|
88 |
"helper for parse tree walking" |
|
89 |
||
90 |
^ anEnumerator doVariable:self name:'self' |
|
91 |
||
92 |
"Created: 19.6.1997 / 17:20:02 / cg" |
|
93 |
! ! |
|
94 |
||
1035 | 95 |
!SelfNode methodsFor:'evaluation'! |
14 | 96 |
|
1384 | 97 |
evaluateIn:anEnvironment |
98 |
anEnvironment notNil ifTrue:[ |
|
99 |
^ anEnvironment receiver. |
|
100 |
]. |
|
14 | 101 |
^ value |
102 |
! |
|
103 |
||
104 |
store:aValue |
|
105 |
"not reached - parser has already checked this" |
|
106 |
||
107 |
self error:'store into self - cannot happen' |
|
108 |
! ! |
|
109 |
||
1080 | 110 |
!SelfNode methodsFor:'printing & storing'! |
14 | 111 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
112 |
displayOn:aGCOrStream |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
113 |
"Compatibility |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
114 |
append a printed desription on some stream (Dolphin, Squeak) |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
115 |
OR: |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
116 |
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
|
117 |
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
|
118 |
(although the fallBack is to display its printString ...)" |
612 | 119 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
120 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
121 |
"/ ST/X (and some old ST80's) mean: draw-yourself on a GC. |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
122 |
aGCOrStream isStream ifFalse:[ |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
123 |
^ super displayOn:aGCOrStream. |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
124 |
]. |
612 | 125 |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
126 |
aGCOrStream |
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
127 |
nextPutAll:'InterpreterVariable(self)'. |
14 | 128 |
! |
129 |
||
130 |
printOn:aStream indent:i |
|
131 |
aStream nextPutAll:'self' |
|
132 |
! ! |
|
140 | 133 |
|
2323 | 134 |
!SelfNode methodsFor:'testing'! |
862 | 135 |
|
136 |
isSelf |
|
137 |
"return true, if this is a self-node" |
|
138 |
||
139 |
^ self class == SelfNode |
|
140 |
||
141 |
||
142 |
! ! |
|
143 |
||
2604 | 144 |
!SelfNode methodsFor:'visiting'! |
145 |
||
146 |
acceptVisitor:aVisitor |
|
147 |
"Double dispatch back to the visitor, passing my type encoded in |
|
148 |
the selector (visitor pattern)" |
|
149 |
||
150 |
"stub code automatically generated - please change if required" |
|
151 |
||
152 |
^ aVisitor visitSelfNode:self |
|
153 |
! ! |
|
154 |
||
148 | 155 |
!SelfNode class methodsFor:'documentation'! |
156 |
||
157 |
version |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
158 |
^ '$Header: /cvs/stx/stx/libcomp/SelfNode.st,v 1.22 2012-08-03 15:53:28 stefan Exp $' |
2323 | 159 |
! |
160 |
||
161 |
version_CVS |
|
2896
b94f53848481
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2604
diff
changeset
|
162 |
^ '$Header: /cvs/stx/stx/libcomp/SelfNode.st,v 1.22 2012-08-03 15:53:28 stefan Exp $' |
148 | 163 |
! ! |