author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 16:31:47 +0100 | |
changeset 135 | aa4f7b8f121e |
parent 117 | 3736a828cb50 |
child 140 | 1ef1d1395146 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
52 | 3 |
All Rights Reserved |
0 | 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 |
||
13 |
ParseNode subclass:#AssignmentNode |
|
14 |
instanceVariableNames:'variable expression' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'System-Compiler-Support' |
|
18 |
! |
|
19 |
||
20 | 20 |
!AssignmentNode class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
52 | 25 |
All Rights Reserved |
20 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
version |
|
135
aa4f7b8f121e
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
117
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.13 1995-11-11 15:29:49 cg Exp $' |
20 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
node for parse-trees, representing assignments |
|
43 |
" |
|
44 |
! ! |
|
0 | 45 |
|
46 |
!AssignmentNode class methodsFor:'instance creation'! |
|
47 |
||
48 |
variable:v expression:e |
|
49 |
^ (self basicNew) variable:v expression:e |
|
50 |
! ! |
|
51 |
||
52 |
!AssignmentNode methodsFor:'evaluating'! |
|
53 |
||
54 |
evaluate |
|
55 |
|value| |
|
56 |
value := expression evaluate. |
|
57 |
variable store:value. |
|
58 |
^ value |
|
59 |
! ! |
|
60 |
||
17 | 61 |
!AssignmentNode methodsFor:'queries'! |
62 |
||
63 |
isAssignment |
|
64 |
"return true, if this is a node for an assignment" |
|
65 |
||
66 |
^ true |
|
67 |
! ! |
|
68 |
||
0 | 69 |
!AssignmentNode methodsFor:'accessing'! |
70 |
||
71 |
variable:v expression:e |
|
72 |
variable := v. |
|
73 |
expression := e |
|
17 | 74 |
! |
75 |
||
76 |
expression |
|
77 |
^ expression |
|
0 | 78 |
! ! |
79 |
||
80 |
!AssignmentNode methodsFor:'code generation'! |
|
81 |
||
117 | 82 |
checkIncDecOn:aStream |
83 |
|sel erec arg code| |
|
0 | 84 |
|
85 |
(variable type == #MethodVariable) ifTrue:[ |
|
52 | 86 |
expression isBinaryMessage ifTrue:[ |
87 |
sel := expression selector. |
|
117 | 88 |
erec := expression receiver. |
52 | 89 |
((sel == #+) or:[sel == #-]) ifTrue:[ |
117 | 90 |
(erec type == #MethodVariable) ifTrue:[ |
91 |
(erec index == variable index) ifTrue:[ |
|
52 | 92 |
arg := expression arg1. |
93 |
arg isConstant ifTrue:[ |
|
94 |
(arg value == 1) ifTrue:[ |
|
95 |
(sel == #+) ifTrue:[ |
|
117 | 96 |
code := #incMethodVar |
52 | 97 |
] ifFalse:[ |
117 | 98 |
code := #decMethodVar |
52 | 99 |
]. |
117 | 100 |
aStream nextPut:code; nextPut:(expression lineNumber); nextPut:(variable index). |
101 |
^ true |
|
52 | 102 |
] |
103 |
] |
|
104 |
] |
|
105 |
] |
|
106 |
] |
|
107 |
] |
|
0 | 108 |
]. |
117 | 109 |
^ false |
110 |
! |
|
111 |
||
112 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
113 |
(self checkIncDecOn:aStream) ifTrue:[^ self]. |
|
104 | 114 |
expression codeOn:aStream inBlock:b for:aCompiler. |
115 |
variable codeStoreOn:aStream inBlock:b valueNeeded:false for:aCompiler |
|
117 | 116 |
|
117 |
"Modified: 4.9.1995 / 14:38:10 / claus" |
|
0 | 118 |
! |
119 |
||
104 | 120 |
codeOn:aStream inBlock:b for:aCompiler |
117 | 121 |
(self checkIncDecOn:aStream) ifTrue:[ |
122 |
expression receiver codeOn:aStream inBlock:b for:aCompiler. |
|
123 |
^ self |
|
124 |
]. |
|
104 | 125 |
expression codeOn:aStream inBlock:b for:aCompiler. |
126 |
variable codeStoreOn:aStream inBlock:b valueNeeded:true for:aCompiler |
|
0 | 127 |
! ! |
128 |
||
129 |
!AssignmentNode methodsFor:'printing'! |
|
130 |
||
131 |
printOn:aStream indent:i |
|
132 |
variable printOn:aStream. |
|
133 |
aStream nextPutAll:' := '. |
|
134 |
expression printOn:aStream |
|
135 |
! ! |