author | Claus Gittinger <cg@exept.de> |
Tue, 06 May 2003 14:24:35 +0200 | |
changeset 1406 | cb80600efd76 |
parent 1384 | 0db9682870d9 |
child 2323 | e6bb6ed129a9 |
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 |
" |
|
12 |
||
1080 | 13 |
"{ Package: 'stx:libcomp' }" |
14 |
||
14 | 15 |
PrimaryNode subclass:#SelfNode |
261 | 16 |
instanceVariableNames:'' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'System-Compiler-Support' |
|
14 | 20 |
! |
21 |
||
20 | 22 |
!SelfNode class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
104 | 27 |
All Rights Reserved |
20 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
node for parse-trees, representing self |
|
261 | 41 |
This is a helper class for the compiler. |
263 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
20 | 45 |
" |
46 |
! ! |
|
14 | 47 |
|
48 |
!SelfNode class methodsFor:'instance creation'! |
|
49 |
||
50 |
value:val |
|
51 |
^ (self basicNew) value:val |
|
52 |
! ! |
|
53 |
||
54 |
!SelfNode methodsFor:'accessing'! |
|
55 |
||
542 | 56 |
name |
57 |
^ 'self' |
|
58 |
||
59 |
"Created: 19.6.1997 / 17:20:22 / cg" |
|
60 |
! |
|
61 |
||
14 | 62 |
value:val |
63 |
type := #Self. |
|
64 |
value := val. |
|
65 |
! ! |
|
66 |
||
140 | 67 |
!SelfNode methodsFor:'code generation'! |
68 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
69 |
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
70 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
71 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
72 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
73 |
aStream nextPut:#retSelf |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
74 |
! |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
711
diff
changeset
|
75 |
|
140 | 76 |
codeOn:aStream inBlock:codeBlock for:aCompiler |
77 |
aStream nextPut:#pushSelf |
|
78 |
! |
|
79 |
||
80 |
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
81 |
"not reached - parser has already checked this" |
|
82 |
||
83 |
^ self error:'store into self - cannot happen' |
|
84 |
! ! |
|
85 |
||
1035 | 86 |
!SelfNode methodsFor:'enumerating'! |
542 | 87 |
|
88 |
nodeDo:anEnumerator |
|
89 |
"helper for parse tree walking" |
|
90 |
||
91 |
^ anEnumerator doVariable:self name:'self' |
|
92 |
||
93 |
"Created: 19.6.1997 / 17:20:02 / cg" |
|
94 |
! ! |
|
95 |
||
1035 | 96 |
!SelfNode methodsFor:'evaluation'! |
14 | 97 |
|
1384 | 98 |
evaluateIn:anEnvironment |
99 |
anEnvironment notNil ifTrue:[ |
|
100 |
^ anEnvironment receiver. |
|
101 |
]. |
|
14 | 102 |
^ value |
103 |
! |
|
104 |
||
105 |
store:aValue |
|
106 |
"not reached - parser has already checked this" |
|
107 |
||
108 |
self error:'store into self - cannot happen' |
|
109 |
! ! |
|
110 |
||
1080 | 111 |
!SelfNode methodsFor:'printing & storing'! |
14 | 112 |
|
113 |
displayString |
|
612 | 114 |
"return a string for display in inspectors etc." |
115 |
||
14 | 116 |
^ 'InterpreterVariable(self)' |
612 | 117 |
|
118 |
"Modified: 20.9.1997 / 11:41:41 / cg" |
|
14 | 119 |
! |
120 |
||
121 |
printOn:aStream indent:i |
|
122 |
aStream nextPutAll:'self' |
|
123 |
! ! |
|
140 | 124 |
|
862 | 125 |
!SelfNode methodsFor:'queries'! |
126 |
||
127 |
isSelf |
|
128 |
"return true, if this is a self-node" |
|
129 |
||
130 |
^ self class == SelfNode |
|
131 |
||
132 |
||
133 |
! ! |
|
134 |
||
148 | 135 |
!SelfNode class methodsFor:'documentation'! |
136 |
||
137 |
version |
|
1384 | 138 |
^ '$Header: /cvs/stx/stx/libcomp/SelfNode.st,v 1.19 2003-03-28 14:41:13 cg Exp $' |
148 | 139 |
! ! |