author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 28 Jul 2011 16:57:44 +0200 | |
changeset 2617 | 160ca364f3d3 |
parent 2604 | d5a9c6f694df |
child 2896 | b94f53848481 |
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 |
|
112 |
displayString |
|
612 | 113 |
"return a string for display in inspectors etc." |
114 |
||
14 | 115 |
^ 'InterpreterVariable(self)' |
612 | 116 |
|
117 |
"Modified: 20.9.1997 / 11:41:41 / cg" |
|
14 | 118 |
! |
119 |
||
120 |
printOn:aStream indent:i |
|
121 |
aStream nextPutAll:'self' |
|
122 |
! ! |
|
140 | 123 |
|
2323 | 124 |
!SelfNode methodsFor:'testing'! |
862 | 125 |
|
126 |
isSelf |
|
127 |
"return true, if this is a self-node" |
|
128 |
||
129 |
^ self class == SelfNode |
|
130 |
||
131 |
||
132 |
! ! |
|
133 |
||
2604 | 134 |
!SelfNode methodsFor:'visiting'! |
135 |
||
136 |
acceptVisitor:aVisitor |
|
137 |
"Double dispatch back to the visitor, passing my type encoded in |
|
138 |
the selector (visitor pattern)" |
|
139 |
||
140 |
"stub code automatically generated - please change if required" |
|
141 |
||
142 |
^ aVisitor visitSelfNode:self |
|
143 |
! ! |
|
144 |
||
148 | 145 |
!SelfNode class methodsFor:'documentation'! |
146 |
||
147 |
version |
|
2604 | 148 |
^ '$Header: /cvs/stx/stx/libcomp/SelfNode.st,v 1.21 2011-07-25 22:36:02 vrany Exp $' |
2323 | 149 |
! |
150 |
||
151 |
version_CVS |
|
2604 | 152 |
^ '$Header: /cvs/stx/stx/libcomp/SelfNode.st,v 1.21 2011-07-25 22:36:02 vrany Exp $' |
148 | 153 |
! ! |